/* 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); }

#top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
#games { display: flex; gap: 6px; }
#games button { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 14px; font-weight: 700; min-height: 44px; }
#games button.on { border-color: var(--gold); color: var(--gold); }
.topbtns { display: flex; gap: 6px; }
#title { text-align: center; font-weight: 800; letter-spacing: 2px; font-size: 20px; }
#title small { display: block; font-weight: 400; letter-spacing: 0; color: var(--dim); font-size: 11px; }

/* 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; }

#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 .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 { visibility: hidden; }

#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; }

#modal { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .8); overflow-y: auto; padding: 16px; -webkit-user-select: text; user-select: text; }
#modalBody { max-width: 460px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; line-height: 1.6; }
#modalBody h3 { margin: 14px 0 4px; font-size: 15px; color: var(--gold); }
#modalBody table { border-collapse: collapse; width: 100%; font-size: 13px; }
#modalBody td, #modalBody th { border-bottom: 1px solid var(--line); padding: 3px 4px; text-align: center; }
#modalBody textarea { width: 100%; min-height: 80px; background: #0d1428; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; -webkit-user-select: text; user-select: text; }
.stars button { font-size: 26px; background: none; border: 0; color: #556; }
.stars button.on { color: var(--gold); }
.close { float: right; }

#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 (A4): plain page text and one button over the canvas, which shows only the cloud picture meanwhile */
#start { position: fixed; inset: 0; z-index: 35; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); background: linear-gradient(rgba(5, 8, 20, .15), rgba(5, 8, 20, .55) 60%, rgba(5, 8, 20, .85)); }
#startTitle { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: -8vh; }
#startTitle canvas { max-width: 88vw; height: auto; }
#startLoad { font-size: 14px; color: var(--text); min-height: 20px; }
#startBtn { 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; }
.startFoot { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; }

/* autoplay choice (A7) */
#autoPick { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 25; width: min(92vw, 420px); background: var(--panel); border: 2px solid var(--gold); border-radius: 16px; padding: 12px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
#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: 22px; min-height: 52px; border-radius: 12px; border: 1px solid var(--gold); background: #241a07; color: var(--gold); }
