/* Triple Dragon Fortune - cabinet layout.
   Frame art is applied with border-image rather than a stretched background
   so the carved corners stay undistorted at any container size. Every slice
   below was measured from the asset's own transparent window. */

*,
*::before,
*::after { box-sizing: border-box; }

/* The hidden attribute must beat every display:flex/grid rule below --
   #modalOverlay, the modal cards, #bigWinBanner and #toast all rely on it. */
[hidden] { display: none !important; }

:root {
  --gold: #f2c14e;
  --gold-bright: #ffe6a3;
  --ivory: #f6efe2;
  --lacquer-deep: #2a0508;

  --cell-w: 140px;
  --cell-h: 132px;
  --panel-w: 250px;

  /* border-image-slice stays at the art's native pixels; border-WIDTH must
     be scaled to how big the element actually renders, or the content box
     collapses. Each set below is the native inset x (rendered width / art
     width). cabinet-frame 669x373, reel-bezel 669x373, panel 403x536. */
  --cab-t: 62px; --cab-r: 70px; --cab-b: 52px; --cab-l: 70px;
  --bez-t: 28px; --bez-r: 40px; --bez-b: 27px; --bez-l: 40px;
  --pan-t: 56px; --pan-r: 50px; --pan-b: 46px; --pan-l: 51px;
}

html { background: #170305; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ivory);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: #170305 url("/assets/art/background.jpg") center / cover no-repeat;
  /* scroll, not fixed: a fixed attachment clips below the first viewport
     height in full-page screenshots. */
  background-attachment: scroll;
  display: flex;
  justify-content: center;
  padding: 12px 10px 24px;
}

.cabinet-wrap {
  width: min(1000px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.logo {
  width: min(320px, 62vw);
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.7));
}

/* ---- cabinet frame ---- */

.cabinet {
  width: 100%;
  border-style: solid;
  border-width: var(--cab-t) var(--cab-r) var(--cab-b) var(--cab-l);
  border-image-source: url("/assets/art/cabinet-frame.png");
  border-image-slice: 89 101 75 101;
  border-image-repeat: stretch;
  filter: drop-shadow(0 14px 34px rgba(0, 0, 0, 0.6));
}

.playfield {
  display: flex;
  gap: 10px;
  align-items: stretch;
  justify-content: center;
}

/* ---- prize panel ---- */

.paytable {
  flex: 0 0 auto;
  width: var(--panel-w);
  border-style: solid;
  border-width: var(--pan-t) var(--pan-r) var(--pan-b) var(--pan-l);
  border-image-source: url("/assets/art/paytable-panel.png");
  border-image-slice: 91 80 74 82 fill;
  border-image-repeat: stretch;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 2px;
}

.pay-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.pay-symbols {
  display: flex;
  justify-content: center;
  gap: 2px;
}

.pay-symbols img {
  width: 38px;
  height: 46px;
  object-fit: contain;
}

.pay-any {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Sits on the dragon's feet rather than its centre: three centred labels
   on narrow art run together into one unreadable string. */
.pay-any span {
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 7px;
  font-weight: 900;
  line-height: 1;
  padding: 1px 2px;
  border-radius: 3px;
  background: rgba(8, 2, 3, 0.85);
  color: var(--gold-bright);
  letter-spacing: 0.3px;
}

.pay-prize {
  font-weight: 800;
  font-size: 15px;
  color: var(--gold-bright);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
}

/* ---- reels ---- */

.reel-frame {
  position: relative;
  flex: 0 0 auto;
  border-style: solid;
  border-width: var(--bez-t) var(--bez-r) var(--bez-b) var(--bez-l);
  border-image-source: url("/assets/art/reel-bezel.png");
  border-image-slice: 37 55 36 55;
  border-image-repeat: stretch;
  background: rgba(6, 1, 2, 0.82);
  background-clip: padding-box;
}

.reels {
  display: grid;
  grid-template-columns: repeat(3, var(--cell-w));
  gap: 4px;
}

/* Outline, not border: under border-box a 1px border would shrink the
   visible window below three whole cells and clip the bottom row. */
.reel-col {
  overflow: hidden;
  height: calc(var(--cell-h) * 3);
  border-radius: 8px;
  background: rgba(10, 2, 3, 0.55);
  outline: 1px solid rgba(242, 193, 78, 0.18);
  outline-offset: -1px;
}

/* The strip carries one hidden cell above the window and one below, so a
   wrapping recycle is never visible at the edges. */
.reel-strip {
  will-change: transform;
  margin-top: calc(var(--cell-h) * -1);
}

.cell {
  height: var(--cell-h);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell img {
  max-width: 100%;
  height: 98%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

/* Motion blur goes on the child images, never on the strip: the filler
   strip is ~12 cells tall and a filter on the translating strip itself
   blacks the whole column out mid-tween. */
.reel-strip.spinning .cell img { filter: blur(2px); }

/* The only payline: dead centre of the middle row. */
.payline {
  position: absolute;
  left: calc(var(--bez-l) - 10px);
  right: calc(var(--bez-r) - 10px);
  top: 50%;
  transform: translateY(-50%);
  height: 3px;
  pointer-events: none;
  display: flex;
  align-items: center;
}

.payline span {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-bright) 12%, var(--gold) 50%, var(--gold-bright) 88%, transparent);
  box-shadow: 0 0 10px rgba(242, 193, 78, 0.85);
}

.cell.win { animation: pulse 0.7s ease-in-out 2; border-radius: 8px; }
.cell.win-RED   { box-shadow: inset 0 0 0 3px #d9342b, 0 0 20px rgba(217, 52, 43, 0.7); }
.cell.win-GREEN { box-shadow: inset 0 0 0 3px #2f9e6f, 0 0 20px rgba(47, 158, 111, 0.7); }
.cell.win-AZURE { box-shadow: inset 0 0 0 3px #2f7fd1, 0 0 20px rgba(47, 127, 209, 0.7); }
.cell.win-MIX   { box-shadow: inset 0 0 0 3px var(--gold), 0 0 20px rgba(242, 193, 78, 0.7); }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

.reel-frame.win-flash { animation: frame-flash 0.7s ease-out 1; }

@keyframes frame-flash {
  0%   { filter: brightness(1); }
  35%  { filter: brightness(1.5) drop-shadow(0 0 18px rgba(242, 193, 78, 0.8)); }
  100% { filter: brightness(1); }
}

/* ---- big win ---- */

.big-win {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: url("/assets/art/bigwin-plaque.png") center / contain no-repeat;
  z-index: 4;
  animation: bigwin-pop 0.35s ease-out 1;
}

.big-win-label {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--gold-bright);
  text-shadow: 0 2px 6px #000;
}

.big-win-amount {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 6px #000;
}

@keyframes bigwin-pop {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ---- win sparks ---- */

.spark {
  position: absolute;
  width: 34px;
  height: 34px;
  left: 50%;
  top: 50%;
  margin: -17px 0 0 -17px;
  background: url("/assets/art/spark.png") center / contain no-repeat;
  pointer-events: none;
  z-index: 5;
  animation: spark-fly 900ms ease-out forwards;
}

@keyframes spark-fly {
  0%   { transform: translate(0, 0) scale(0.3) rotate(0deg); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.1) rotate(var(--rot)); opacity: 0; }
}

/* ---- bottom bar ---- */

.bottom-bar {
  width: 100%;
  border-style: solid;
  border-width: 16px 8px 8px;
  border-image-source: url("/assets/art/bottom-bar.png");
  border-image-slice: 16 8 8 8 fill;
  border-image-repeat: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 14px;
  min-height: 58px;
}

.bar-left,
.bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.bar-readouts {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.readout {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  flex: 0 0 auto;
}

.readout-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: rgba(246, 239, 226, 0.65);
}

.readout-value {
  font-size: 15px;
  font-weight: 800;
  color: var(--gold-bright);
  white-space: nowrap;
}

.message {
  flex: 1 1 auto;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--gold);
  text-shadow: 0 1px 3px #000;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message.win { color: #7dffb0; }

/* ---- buttons ---- */

.round-btn {
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: url("/assets/art/btn-round-small.png") center / contain no-repeat;
  color: var(--gold-bright);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 900;
  text-shadow: 0 1px 3px #000;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.round-btn:hover { filter: brightness(1.15); }
.round-btn:active { transform: scale(0.93); }
.round-btn[disabled] { opacity: 0.45; cursor: default; }
.round-btn[aria-pressed="false"] { filter: grayscale(0.75) brightness(0.8); }

.spin-btn {
  width: 66px;
  height: 66px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: url("/assets/art/btn-spin.png") center / contain no-repeat;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
  animation: spin-breathe 2.8s ease-in-out infinite;
}

.spin-btn:hover { filter: brightness(1.12); }
.spin-btn:active { transform: scale(0.94); }
.spin-btn[disabled] { opacity: 0.6; cursor: default; animation: none; }

@keyframes spin-breathe {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(242, 193, 78, 0.35)); }
  50%      { filter: drop-shadow(0 0 14px rgba(242, 193, 78, 0.8)); }
}

.footer-line {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: rgba(246, 239, 226, 0.5);
  letter-spacing: 1px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
  text-decoration: underline;
  padding: 2px 4px;
}

.link-btn[disabled] { color: rgba(246, 239, 226, 0.3); cursor: default; text-decoration: none; }

/* ---- modals ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 1, 2, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.modal-card {
  width: min(460px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px 20px 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, #4a080e, #1b0406);
  border: 2px solid var(--gold);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  text-align: center;
}

.modal-card h2 {
  margin: 0 0 10px;
  font-size: 16px;
  letter-spacing: 3px;
  color: var(--gold-bright);
}

.rules-lead {
  font-size: 12px;
  color: rgba(246, 239, 226, 0.8);
  margin: 0 0 12px;
}

.rules-paytable {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

.rules-paytable td {
  padding: 3px 4px;
  border-bottom: 1px solid rgba(242, 193, 78, 0.18);
  vertical-align: middle;
}

.rules-paytable td:last-child {
  text-align: right;
  font-weight: 800;
  color: var(--gold-bright);
  white-space: nowrap;
}

.rules-paytable .pay-symbols img { width: 26px; height: 34px; }

.payline-diagram {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 10px;
}

.payline-diagram-label {
  font-weight: 900;
  color: var(--gold-bright);
}

.diagram-grid {
  display: grid;
  grid-template-columns: repeat(3, 18px);
  grid-auto-rows: 14px;
  gap: 2px;
}

.diagram-cell { background: rgba(246, 239, 226, 0.18); border-radius: 2px; }
.diagram-cell.on { background: #ff3ea5; }

.rules-rtp { font-size: 12px; margin: 0; }
.rules-rtp strong { color: var(--gold-bright); }

.rules-list {
  text-align: left;
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
  padding-left: 18px;
  color: rgba(246, 239, 226, 0.85);
}

.rules-meta {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 12px;
  justify-content: center;
  font-size: 12px;
  margin: 12px 0 0;
}

.rules-meta dt { color: rgba(246, 239, 226, 0.6); text-align: right; }
.rules-meta dd { margin: 0; color: var(--gold-bright); font-weight: 700; text-align: left; }

.rules-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  position: relative;
}

.round-btn.close { filter: hue-rotate(-25deg) brightness(1.1); }

.rules-pageno {
  position: absolute;
  right: 0;
  font-size: 11px;
  color: rgba(246, 239, 226, 0.55);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px;
  border-bottom: 1px solid rgba(242, 193, 78, 0.15);
  font-size: 13px;
}

.setting-row code {
  font-size: 11px;
  color: var(--gold-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
  white-space: nowrap;
}

.wide-btn {
  margin-top: 14px;
  width: 100%;
  padding: 9px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffb020, #b8420c);
  color: #2a0508;
  font-weight: 900;
  letter-spacing: 2px;
  cursor: pointer;
}

.verify-seed {
  font-size: 11px;
  color: rgba(246, 239, 226, 0.75);
  word-break: break-all;
  white-space: pre-wrap;
  text-align: left;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(20, 3, 5, 0.95);
  border: 1px solid var(--gold);
  color: var(--ivory);
  font-size: 13px;
  z-index: 30;
}

/* ---- responsive ---- */

@media (max-width: 900px) {
  :root {
    --cell-w: 112px;
    --cell-h: 106px;
    --panel-w: 190px;
    --cab-t: 46px; --cab-r: 52px; --cab-b: 39px; --cab-l: 52px;
    --bez-t: 21px; --bez-r: 30px; --bez-b: 20px; --bez-l: 30px;
    --pan-t: 43px; --pan-r: 38px; --pan-b: 35px; --pan-l: 39px;
  }
  .pay-symbols img { width: 30px; height: 36px; }
  .pay-prize { font-size: 12px; }
  .spin-btn { width: 54px; height: 54px; }
}

@media (max-width: 660px) {
  :root {
    --cell-w: 94px;
    --cell-h: 90px;
    --panel-w: 124px;
    --cab-t: 34px; --cab-r: 38px; --cab-b: 28px; --cab-l: 38px;
    --bez-t: 15px; --bez-r: 22px; --bez-b: 15px; --bez-l: 22px;
    --pan-t: 28px; --pan-r: 25px; --pan-b: 23px; --pan-l: 25px;
  }
  .pay-symbols img { width: 21px; height: 26px; }
  .pay-prize { font-size: 10px; }
  .readout-value { font-size: 12px; }
  .message { font-size: 10px; letter-spacing: 0; }
  .spin-btn { width: 46px; height: 46px; }
  .round-btn { width: 28px; height: 28px; font-size: 13px; }
  .logo { width: min(230px, 60vw); }
}

@media (prefers-reduced-motion: reduce) {
  .spin-btn { animation: none; }
  .cell.win { animation: none; }
  .reel-frame.win-flash { animation: none; }
  .big-win { animation: none; }
  .spark { display: none; }
}
