/* the game's fonts (Google Fonts, SIL OFL 1.1; licences in web-hoard/fonts/): Lilita One for numbers, ZCOOL KuaiLe for titles */
@font-face { font-family: "HoardNum"; src: url(fonts/hoard-num.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "HoardTitle"; src: url(fonts/hoard-title.woff2) format("woff2"); font-display: swap; }
/* Page elements carry text and buttons only: no shadows, no filters, no animations (docs/game3-render-budget.md §1).
   Everything that moves is drawn on the one canvas (#cv). */
:root {
  --bg: #0b1020; --panel: #141b33; --line: #2a3560; --text: #eef1ff; --dim: #8e98c4;
  --gold: #f2c14e; --teal: #2ec4a6; --silver: #c9d1e6;
  --cell: min(17.4vw, 86px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px -apple-system, "PingFang SC", "Noto Sans SC", sans-serif; overscroll-behavior: none; touch-action: manipulation; }
body { overflow-x: hidden; }
#cv { position: fixed; left: 0; top: 0; z-index: 0; pointer-events: none; }
#app { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; padding: 10px 12px 24px; display: flex; flex-direction: column; gap: 10px; min-height: 100%; }
.hidden { display: none !important; }
.lab { color: var(--dim); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 17px; }
button { font: inherit; color: inherit; cursor: pointer; min-height: 32px; }
.pill { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; white-space: nowrap; }
.pill.on { border-color: var(--gold); color: var(--gold); }

/* the top (11-25, owner): no game buttons, no title. With the delivered control bar nothing stands up here at all (its ≡
   and ? carry the menu and the rules) and the room belongs to the free-game panel; the plain buttons are the fallback */
#top { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.topbtns { display: flex; gap: 6px; }
#app.barSkin #top { display: none; }
/* owner 11-25: the whole game sits at the bottom of the screen as one piece (panel's place, board, control bar, close
   together); what is left over is at the top, where the background has its picture (the gate, the dragon). Tried first and
   dropped the same day: the bar alone at the bottom, which tore the bar from the board and left a hole in the middle. */
#app.barSkin { justify-content: flex-end; }

/* free-spin bar: the frame, the dragon and the meter are drawn on the canvas under these spots */
#fsbar { display: flex; gap: 10px; align-items: center; padding: 8px 10px; min-height: 108px; }
#emberSpot { position: relative; width: 92px; height: 92px; flex: none; }
/* owner 11-23: the stage shows as four dots drawn under the dragon; the words stay for screen readers only */
#stageTag { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#fsinfo { flex: 1; display: flex; flex-direction: column; gap: 4px; }
#fsinfo .row { display: flex; align-items: baseline; gap: 6px; }
#fsinfo b { font-size: 18px; font-variant-numeric: tabular-nums; }
#fsMult { color: var(--gold); }
#meterSpot { height: 14px; }
/* with the delivered free-spin bar picture (art batch 4): every piece sits on its place in the picture (layout.json "fsbar") */
#fsbar.skin { display: block; position: relative; padding: 0; min-height: 0; }
#fsbar.skin #fsinfo { display: contents; }
#fsbar.skin #emberSpot, #fsbar.skin .row, #fsbar.skin #meterSpot, #fsbar.skin #meterLab { position: absolute; }
#fsbar.skin .row, #fsbar.skin #meterLab { white-space: nowrap; overflow: hidden; }
#fsbar.skin .row { justify-content: center; align-items: center; gap: 5px; font-size: clamp(11px, 3.2vw, 14px); }
#fsbar.skin #fsinfo b { font-size: clamp(13px, 3.8vw, 17px); }
#fsbar.skin #meterLab { display: flex; align-items: center; justify-content: center; font-size: clamp(10px, 2.9vw, 13px); }
#fsbar.nest #stageTag { display: none; }
/* the new free-game panel (art batch 5, docs/game3-fsbar-plan.md, layout.json "fsbar2"): this element is the FRAME's box;
   the picture is drawn larger on the canvas, so its crest hangs above the box and its gem below. The three numbers, the
   medal and the lit slots are drawn on the canvas; the page keeps two small labels, the nameplate's words and one line.
   --crest: the crest's height as a share of the box's width: the room kept above the box for it. */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#fsbar.skin2 { margin-top: var(--crest, 0%); }
/* the panel keeps its place when it is not shown (the base game): the background shows there and the board never moves
   when a free game starts or ends (before 11-25 it dropped by the panel's height and came back) */
#fsbar.skin2.hidden { display: block !important; visibility: hidden; }
/* ...and there the logo stands, drawn on the canvas (drawLogo) so that the shine can run over it */
#fsbar.skin2 .row { flex-direction: column; justify-content: flex-start; gap: 0; overflow: visible; }
#fsbar.skin2 .row .lab, #fsbar.skin2 #meterLab, #fsbar.skin2 .lastLab, #fsbar.skin2 #stageTag { font-family: "HoardTitle", -apple-system, "PingFang SC", sans-serif; }
#fsbar.skin2 .row .lab { margin-top: 0.35em; font-size: clamp(10px, 2.9vw, 13px); line-height: 1.2; letter-spacing: 1px; color: #a9e6d6; }
#fsbar.skin2 .lastLab { display: none; font-size: clamp(14px, 4.4vw, 20px); line-height: 1.12; text-align: center; color: #ffe08a; }
#fsbar.skin2 .row.last { justify-content: center; }
#fsbar.skin2 .row.last .lab { display: none; }
#fsbar.skin2 .row.last .lastLab { display: block; }
#fsbar.skin2 #stageTag { clip: auto; overflow: visible; display: flex; align-items: center; justify-content: center; font-size: clamp(8px, 2.5vw, 11px); line-height: 1; color: #3a2204; }
#fsbar.skin2 #meterLab { font-size: clamp(11px, 3.3vw, 15px); letter-spacing: 0.5px; color: #d6f3ea; }
#fsbar.skin2 #meterLab b { font-weight: 400; color: #ffe08a; }

#boardSpot { align-self: center; width: calc(var(--cell) * 5 + 4px * 4 + 20px); height: calc(var(--cell) * 3 + 4px * 2 + 20px); }
#note { text-align: center; font-size: 13px; color: var(--gold); min-height: 18px; margin-top: -4px; }
#boardSpot.framed + #note { margin-top: -8px; margin-bottom: -8px; }

#controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto minmax(0, 1fr); gap: 8px; align-items: center; margin-top: 4px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 4px; text-align: center; min-width: 0; }
.box .num { font-size: 15px; }
.box.bet { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.mini { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #0d1428; font-size: 18px; }
#spin { width: 78px; height: 78px; border-radius: 50%; border: 3px solid var(--gold); background: #241a07; color: var(--gold); font-size: 24px; font-weight: 900; }
#spin:disabled { opacity: .5; }
.side { grid-column: 1 / -1; display: flex; justify-content: center; gap: 8px; }
.barOnly { display: none; }

/* delivered frame: the board takes the picture's shape and a little of the side margins */
#boardSpot.framed { width: calc(100% + 24px); height: auto; margin: 0 -12px; }

/* delivered control bar: the picture is drawn on the canvas under #controls; these are invisible buttons
   and plain text laid over the drawn ones (positions measured on art/hoard/bar.webp, in % of the bar) */
#controls.skin { display: block; position: relative; width: calc(100% + 16px); margin: 4px -8px 0; }
#controls.skin .box, #controls.skin .side { display: contents; }
#controls.skin > *, #controls.skin .box > *, #controls.skin .side > * { position: absolute; }
#controls.skin button { background: none; border: 0; color: transparent; font-size: 0; padding: 0; min-height: 0; border-radius: 50%; }
#controls.skin .barOnly { display: block; }
#controls.skin .lab { display: none; }
#controls.skin .num { position: absolute; color: var(--gold); font-size: clamp(11px, 3.4vw, 15px); display: flex; align-items: center; justify-content: center; }
#controls.skin.numsCv .num { color: transparent; } /* the three numbers are drawn on the canvas (drawBarNums); these keep the place and the value */
#controls.skin .bet > div { display: contents; }
#controls.skin #balance { left: 12.5%; top: 17%; width: 24%; height: 23%; }
#controls.skin #win { left: 63.5%; top: 17%; width: 24%; height: 23%; }
#controls.skin #bet { left: 25%; top: 54%; width: 8.5%; height: 20%; font-size: clamp(10px, 2.8vw, 13px); }
#controls.skin #barMenu { left: 1.5%; top: 47%; width: 8%; height: 34%; }
#controls.skin #barHelp { left: 10.5%; top: 47%; width: 8%; height: 34%; }
#controls.skin #betDown { left: 18%; top: 47%; width: 8%; height: 34%; }
#controls.skin #betUp { left: 33%; top: 47%; width: 8%; height: 34%; }
#controls.skin #spin { left: 41%; top: 27.5%; width: 18%; height: auto; aspect-ratio: 1; }
#controls.skin #spin:disabled { opacity: 1; background: rgba(0, 0, 0, .4); }
#spin.skip { font-size: 17px; }
#controls.skin #spin.skip { background: rgba(0, 0, 0, .35); } /* no words on the drawn key (owner 11-22): only a little darker while a show plays */
#controls.skin #auto { left: 66%; top: 47%; width: 8%; height: 34%; }
#controls.skin #turbo { left: 80%; top: 47%; width: 8%; height: 34%; }
#controls.skin #turbo.on { border: 3px solid #fff3b0; } /* autoplay shows no ring (owner 11-23): the line under the board already says it is on */

#msg { text-align: center; color: var(--dim); font-size: 12px; min-height: 16px; }
#tally { text-align: center; min-height: 16px; margin-top: -6px; }
/* under a full-screen layer the page words step aside (they sit above the canvas, the veil cannot cover them); taps still
   go through to skip */
#app.veiled #controls, #app.veiled #msg, #app.veiled #tally, #app.veiled #note, #app.veiled #fsbar .row, #app.veiled #meterLab, #app.veiled #fsbar.skin2 #stageTag { visibility: hidden; }
/* the game's name too: the epic win's title picture (horns and a pearl on top) reaches it on a short phone */

#shade { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 20; }
#panel { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 21; min-width: 260px; max-width: 90vw; text-align: center; background: var(--panel); border: 2px solid var(--gold); border-radius: 18px; padding: 18px 22px; }
#panel.floor { border-color: var(--silver); background: #252b3d; }
#panel.grow { border-color: var(--teal); }
#panel h2 { margin: 0 0 6px; font-size: 22px; }
#panel .big { font-size: 34px; font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; }
#panel.floor .big { color: var(--silver); }
#panel .sub { color: var(--dim); font-size: 13px; margin-top: 6px; line-height: 1.5; }
#panel .shield { font-size: 13px; display: inline-block; border: 1px solid var(--silver); border-radius: 6px; padding: 2px 8px; margin-bottom: 6px; color: var(--silver); }
#panel .tap { margin-top: 10px; font-size: 12px; color: var(--dim); }
/* over the canvas layer (growing, big win, intro): lower, so the dragon / picture above stays in view */
#panel.low { top: 74%; }
#panel.bigwin { border-color: var(--gold); background: rgba(20, 14, 4, .92); }
#panel.bigwin h2.bw { font-size: 38px; font-weight: 900; color: var(--gold); letter-spacing: 4px; }
#panel.bigwin .big { font-size: 40px; }
#panel.end .big { font-size: 42px; }

/* the pages behind ≡ and ? (menu, rules, rating). Owner 11-25: in the game's own design language: the deep teal body
   and the gold rims of the panel and the board frame, the game's title and number fonts, the symbols' own pictures.
   Page elements still carry no shadows, filters or animations (render budget §1): borders, flat fills and gradients only. */
#modal { position: fixed; inset: 0; z-index: 30; background: rgba(2, 14, 18, .86); overflow-y: auto; padding: 16px; -webkit-user-select: text; user-select: text; }
#modalBody { position: relative; max-width: 460px; margin: 0 auto; padding: 18px 16px 16px; line-height: 1.65; color: #d6f3ea;
  background: linear-gradient(#0f4a46, #0a2e33 22%, #071c24); border: 4px double #f1c453; border-radius: 22px; outline: 1px solid #5d3d0c; outline-offset: -8px; }
#modalBody h2 { margin: 2px 40px 12px; text-align: center; font: 400 24px/1.2 "HoardTitle", -apple-system, "PingFang SC", sans-serif; letter-spacing: 3px; color: #ffe08a; }
#modalBody h2::before, #modalBody h2::after { content: ""; display: inline-block; width: 9px; height: 9px; margin: 0 12px 3px; background: #23c48f; border: 2px solid #f1c453; transform: rotate(45deg); }
#modalBody h3 { margin: 18px 0 6px; padding-bottom: 4px; font: 400 18px/1.3 "HoardTitle", -apple-system, "PingFang SC", sans-serif; letter-spacing: 1px; color: #ffd64d; border-bottom: 1px solid rgba(241, 196, 83, .45); }
#modalBody p { margin: 8px 0; }
#modalBody .lab { color: #8fbfb3; font-size: 12.5px; }
#modalBody table { border-collapse: collapse; width: 100%; font-size: 14px; }
#modalBody th { font: 400 14px "HoardTitle", -apple-system, "PingFang SC", sans-serif; color: #a9e6d6; padding: 6px 4px; border-bottom: 1px solid rgba(241, 196, 83, .55); }
#modalBody td { border-bottom: 1px solid rgba(120, 190, 180, .22); padding: 4px; text-align: center; font-family: "HoardNum", -apple-system, sans-serif; font-size: 17px; color: #ffd64d; }
#modalBody td.symCell { font: 400 14px "HoardTitle", -apple-system, "PingFang SC", sans-serif; color: #d6f3ea; text-align: left; white-space: nowrap; }
#modalBody .sym { width: 38px; height: 38px; object-fit: contain; vertical-align: middle; margin-right: 6px; }
#modalBody .pill { min-height: 44px; padding: 8px 18px; font: 400 16px "HoardTitle", -apple-system, "PingFang SC", sans-serif; letter-spacing: 1px; color: #fff3bf; background: linear-gradient(#17685f, #0c3a40); border: 2px solid #f1c453; border-radius: 999px; }
#modalBody textarea { width: 100%; min-height: 90px; background: #04141b; color: #eef1ff; border: 1px solid rgba(241, 196, 83, .55); border-radius: 12px; padding: 10px; font: inherit; -webkit-user-select: text; user-select: text; }
.stars { text-align: center; }
.stars button { font-size: 34px; background: none; border: 0; color: #2c5a58; padding: 0 3px; }
.stars button.on { color: #ffd64d; }
.close { position: absolute; right: 12px; top: 12px; width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 50%; font-size: 16px; line-height: 1; color: #ffe08a; background: #0c3a40; border: 2px solid #f1c453; }

#benchBox { position: fixed; left: 8px; right: 8px; top: 8px; z-index: 40; background: rgba(0, 0, 0, .85); border: 1px solid var(--gold); border-radius: 10px; padding: 10px; font: 13px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; }

.num, #fsinfo b { font-family: "HoardNum", -apple-system, sans-serif; font-weight: 400; letter-spacing: 0.5px; }

body.opening #app { visibility: hidden; } /* laid out (the canvas measures it) but not shown */
/* opening screen (11-24 night, the owner's art; docs/game3-start-page-plan.md): still pictures in layers and one button.
   Sizes follow the screen's height as well as its width, so the logo, the dragon and the button never meet on a short
   phone: --lw / --dw are the logo's and the dragon's widths (their heights are 0.5027 and 1.0589 of that). */
body.opening { background: #062823; }
#start { position: fixed; inset: 0; z-index: 35; overflow: hidden; background: transparent; --h: 1vh; --lw: min(96vw, calc(var(--h) * 52)); --dw: min(80vw, calc(var(--h) * 44)); }
@supports (height: 1dvh) { #start { --h: 1dvh; } }
#start .lay { position: absolute; pointer-events: none; } /* places only: the pictures are drawn on the canvas */
#startLogo { aspect-ratio: 1100 / 553; left: 50%; width: var(--lw); margin-left: calc(var(--lw) / -2); top: max(calc(var(--h) * 4), calc((var(--h) * 86.5 - var(--dw) * 1.0589 - var(--lw) * 0.5027) * 0.62)); }
#startDragon { aspect-ratio: 900 / 953; left: 50%; width: var(--dw); margin-left: calc(var(--dw) / -2); bottom: 13.5%; }
#startCoins { aspect-ratio: 1500 / 352; left: -11%; width: 122%; bottom: 1.5%; }
#startLoad { position: absolute; left: 0; right: 0; top: 90%; transform: translateY(-50%); text-align: center; font-size: 15px; color: #fff; text-shadow: 0 1px 3px #000, 0 0 10px #000; }
#startBtn { position: absolute; left: 50%; top: 90%; transform: translate(-50%, -50%); white-space: nowrap; font-family: "HoardTitle", -apple-system, sans-serif; font-size: 24px; letter-spacing: 2px; color: #3b2500; background: linear-gradient(#fff3b0, #f2c14e 55%, #c98a1a); border: 3px solid #5a3505; border-radius: 999px; padding: 12px 34px; min-height: 56px; box-shadow: 0 4px 0 rgba(20, 10, 0, .65), 0 0 22px rgba(0, 0, 0, .5); }
#startBtn { color: transparent !important; background: none !important; border-color: transparent !important; box-shadow: none !important; text-shadow: none !important; } /* seen on the canvas: a page element may not move */
.startFoot { position: absolute; left: 0; right: 0; bottom: 0; padding: 24px 12px calc(10px + env(safe-area-inset-bottom)); text-align: center; font-size: 12px; color: #f3f5ff; text-shadow: 0 1px 2px #000; background: linear-gradient(transparent, rgba(5, 8, 20, .82) 60%); }
@media (min-aspect-ratio: 1/1) { /* wide screen: the landscape picture has the logo and the dragon in it */
  #start #startLogo, #start #startDragon, #start #startCoins { display: none; }
}

/* autoplay choice (A7) */
/* how many auto spins: in the game's own language (owner 11-25), like the menu and the rules page */
#autoPick { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 25; width: min(92vw, 420px); padding: 16px 14px 14px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center;
  background: linear-gradient(#0f4a46, #0a2e33 30%, #071c24); border: 4px double #f1c453; border-radius: 22px; outline: 1px solid #5d3d0c; outline-offset: -8px; }
#autoPick .lab { font: 400 15px/1.4 "HoardTitle", -apple-system, "PingFang SC", sans-serif; letter-spacing: 1px; color: #d6f3ea; }
#autoPick .row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
#autoPick .row button { font-family: "HoardNum", -apple-system, sans-serif; font-size: 26px; min-height: 58px; border-radius: 16px; border: 2px solid #f1c453; background: linear-gradient(#17685f, #0c3a40); color: #ffd64d; }
#autoPick .pill { min-height: 42px; padding: 6px 26px; font: 400 16px "HoardTitle", -apple-system, "PingFang SC", sans-serif; letter-spacing: 2px; color: #fff3bf; background: #0c3a40; border: 2px solid rgba(241, 196, 83, .7); border-radius: 999px; }

/* the menu behind the control bar's ≡: three large buttons, one under another */
.menu { display: flex; flex-direction: column; gap: 12px; margin: 14px 0 6px; }
#modalBody .menu .pill { min-height: 54px; font-size: 19px; letter-spacing: 3px; }

/* external-wallet mode (docs/external-wallet-plan.md): the way back to the operator's lobby, and the notice when the
   page was opened without the operator's token */
#lobbyLink { position: fixed; z-index: 40; top: calc(6px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); padding: 6px 10px; border-radius: 999px; background: rgba(8, 12, 20, .78); border: 1px solid rgba(255, 255, 255, .22); color: #fff; font: 600 13px/1.2 system-ui, sans-serif; text-decoration: none; }
#needLobby { position: fixed; inset: 0; z-index: 70; display: grid; place-content: center; gap: 16px; padding: 24px; background: rgba(8, 12, 20, .92); color: #fff; font: 500 16px/1.5 system-ui, sans-serif; text-align: center; }
#needLobby p { margin: 0; }
#needLobby a { color: #ffd98a; font-weight: 700; }

/* looking at one past round (docs/round-replay-plan.md): the strip on top; everything that plays is put away */
#replayBar { position: fixed; z-index: 40; top: env(safe-area-inset-top); left: 0; right: 0; padding: 6px 10px 8px; background: rgba(8, 12, 20, .88); border-bottom: 1px solid rgba(255, 255, 255, .18); color: #fff; font: 500 12px/1.45 system-ui, sans-serif; text-align: center; }
#replayBar .head { font-weight: 700; color: #ffd98a; }
#replayBar .unpaid { font-weight: 700; color: #ff9d5c; }
#replayBar .what { overflow-wrap: anywhere; }
#replayBar .keys { display: flex; justify-content: center; gap: 8px; margin-top: 6px; }
body.replay #app { padding-top: 96px; }
body.replay #top, body.replay #betDown, body.replay #betUp, body.replay #auto, body.replay #turbo, body.replay #barMenu, body.replay #barHelp, body.replay #tally, body.replay #start { display: none !important; }
