/* Pix Crash: night sky, violet and amber, one dark look on purpose (game
   screen inside the operator's iframe). */
:root {
  /* Esmeralda: the comet's greens for the controls, gold for the cash-out (chosen 2026-11-30). */
  --em1: #7cf0a8; --em2: #2fb866; --em3: #13703d; --gold: #ffd36a;
  --bg: #090a1f; --panel: #14153a; --panel2: #1d1f4d; --line: #2c2f6b;
  --fg: #f1f0ff; --muted: #a3a3d6;
  --amber: #ffb12e; --amber-d: #b77405; --violet: #8b5cff; --mint: #39e6a5; --hot: #ff4d5e;
  --display: "Arial Black", "Segoe UI Black", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: .45; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.hidden { display: none !important; }

#splash { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-content: center; gap: 18px; justify-items: center; }
#splash.done { display: none; }
/* The logo (logo 1, chosen 2026-11-30): the game's diamond, then PIX in
   green and CRASH in white, in Russo One (SIL OFL, fonts/RussoOne-OFL.txt;
   self-hosted, Latin subset). */
@font-face { font-family: "Russo One"; src: url("fonts/RussoOne-latin.woff2") format("woff2"); font-display: swap; }
.logo { display: flex; align-items: center; gap: .08em; line-height: 1; }
.logo img { width: 1.9em; height: 1.9em; margin: -.45em -.2em -.45em -.4em; }
.logo .w { font-family: "Russo One", var(--display); letter-spacing: .01em; color: #fff; white-space: nowrap; }
.logo .w b { font-weight: 400; background: linear-gradient(180deg, #9dffbf, #2fb866); -webkit-background-clip: text; background-clip: text; color: transparent; margin-right: .06em; }
.splash-logo, .brand { font-family: var(--display); letter-spacing: .02em; color: var(--amber); }
.splash-logo { font-size: 3rem; }
.splash-logo span, .brand span { color: var(--fg); }
.splash-bar { width: 180px; height: 6px; border-radius: 6px; background: var(--panel2); overflow: hidden; }
.splash-bar-fill { height: 100%; width: 0; background: var(--amber); animation: fill 1.2s ease-out forwards; }
@keyframes fill { to { width: 100%; } }

#app-frame { max-width: 520px; margin: 0 auto; padding: 10px max(10px, env(safe-area-inset-left, 0px)) 20px; display: flex; flex-direction: column; gap: 8px; position: relative; }
.top { display: flex; justify-content: space-between; align-items: center; }
.brand { font-size: 1.45rem; }
.top-right { display: flex; align-items: center; gap: 8px; }
/* Info button and balance in the Esmeralda look: deep green tiles with a green edge. */
.btn-icon { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border-radius: 12px; border: 1px solid var(--em3); background: linear-gradient(160deg, #123a2b, #0c2a20); color: var(--em1); }
.btn-icon:hover { border-color: var(--em2); }
.balance-box { display: flex; align-items: center; height: 38px; background: linear-gradient(160deg, #123a2b, #0c2a20); border: 1px solid var(--em3); border-radius: 12px; padding: 0 12px; }
.balance-box b { font-family: "Russo One", var(--display); font-weight: 400; font-size: 1.05rem; color: var(--em1); font-variant-numeric: tabular-nums; }
.grant-banner { background: var(--mint); color: #062a1d; border-radius: 10px; padding: 7px 12px; font-weight: 800; text-align: center; }

.history-wrap { display: flex; align-items: flex-start; gap: 6px; }
/* One line, faded at the end; opened (arrow on the right) it wraps to at
   most 3 lines (each chip line is 24px + 6px gap). */
.history { flex: 1; min-width: 0; display: flex; gap: 6px; overflow: hidden; height: 24px; mask-image: linear-gradient(90deg, #000 85%, transparent); }
.history.open { flex-wrap: wrap; height: auto; max-height: 84px; mask-image: none; }
.history span { height: 24px; display: inline-flex; align-items: center; }
.btn-history { flex: none; width: 28px; height: 24px; display: grid; place-items: center; padding: 0; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); }
.btn-history svg { transition: transform .15s; }
.btn-history[aria-expanded="true"] svg { transform: rotate(180deg); }
.history span { flex: none; padding: 3px 9px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: .78rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); }
/* History multipliers, from the Facetado proposal: plain under 2x, green
   outline from 2x, solid green from 10x. */
.history span { background: #151b38; border-color: #2a335f; color: #b9c2ef; }
.history .mid { background: #123b2a; border-color: #1c8c4e; color: #4fe08f; }
.history .hi { background: #4fe08f; border-color: #4fe08f; color: #062b16; }

.stage { position: relative; aspect-ratio: 16 / 11; border-radius: 16px; overflow: hidden; border: 1px solid var(--line);
  background: radial-gradient(ellipse at 50% 130%, #2a1f6e 0%, #12133a 55%, var(--bg) 100%); }
#sky { position: absolute; inset: 0; width: 100%; height: 100%; }
.center { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; pointer-events: none; }
/* In flight the number sits at the top center; the plot keeps the rocket
   below it (app.js: the curve's top is a third of the way down). */
.stage.flying .center, .stage.crashed .center { place-content: start center; padding-top: 12px; gap: 2px; }
.stage.flying .mult, .stage.crashed .mult { font-size: clamp(1.8rem, 8vw, 2.7rem); }
.mult { font-family: var(--display); font-size: clamp(2.8rem, 13vw, 4.6rem); font-variant-numeric: tabular-nums; text-shadow: 0 4px 24px #000a; }
.stage.crashed .mult { color: var(--hot); }
.stage.betting .mult { font-size: clamp(1.4rem, 6vw, 2rem); font-family: "Russo One", var(--display); background: linear-gradient(180deg, #9dffbf, #2fb866); -webkit-background-clip: text; background-clip: text; color: transparent; }
.phase-text { font-weight: 800; color: var(--muted); min-height: 1.2em; }
.stage.crashed .phase-text { color: var(--hot); }
.bubbles { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.bubble { position: absolute; left: 50%; padding: 6px 16px; border-radius: 999px; background: var(--mint); color: #062a1d;
  font-family: var(--display); font-size: 1.05rem; white-space: nowrap; box-shadow: 0 6px 20px #39e6a555;
  animation: bubble-rise 2s ease-out forwards; }
@keyframes bubble-rise {
  0% { opacity: 0; transform: translate(-50%, 14px) scale(.85); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  22% { transform: translate(-50%, -4px) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -26px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -38px) scale(1); }
}
.countdown { width: 160px; height: 6px; border-radius: 6px; background: #13703d55; overflow: hidden; }
#countdown-fill { height: 100%; background: linear-gradient(90deg, var(--em2), var(--em1)); width: 100%; box-shadow: 0 0 8px #7cf0a866; }

/* Each panel: the stake (stepper and quick values) on the left, the big
   button on the right. Panels stack, one per row. */
.panels { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.panel.in { border-color: var(--em2); }
.panel.won { border-color: var(--mint); }
.panel-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 10px; align-items: stretch; }
.amount { display: flex; flex-direction: column; gap: 6px; }
.stepper { display: flex; align-items: center; gap: 6px; background: var(--bg); border-radius: 999px; padding: 4px; }
.stepper .stake { flex: 1; text-align: center; font-family: var(--display); font-size: 1.05rem; font-variant-numeric: tabular-nums; }
/* The signs are drawn (SVG), not typed: a font's - and + sit on the text
   baseline, never exactly in the middle of the circle. */
.stepper button { width: 28px; height: 28px; flex: none; display: grid; place-items: center; padding: 0; border-radius: 50%; border: 0; background: var(--panel2); }
.stepper button svg { display: block; }
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.chips button { border: 0; border-radius: 6px; padding: 4px 0; background: #12263a; color: #8fb7a6; font-weight: 800; font-size: .8rem; }
.chips button.on { color: var(--em1); box-shadow: inset 0 0 0 2px var(--em2); }
.btn-main { border: 0; border-radius: 14px; padding: 10px 6px; min-height: 76px; font-family: var(--display); font-size: 1rem; line-height: 1.15;
  background: linear-gradient(160deg, var(--em1), var(--em2)); color: #062b16; box-shadow: 0 4px 0 var(--em3), inset 0 1px 0 #ffffff66; }
.btn-main:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 var(--em3); }
.btn-main.cashout { background: linear-gradient(160deg, #fff3b0, var(--gold)); color: #3a2600; box-shadow: 0 4px 0 #b88a1c; }
.btn-main.cashout:active:not(:disabled) { box-shadow: 0 2px 0 #b88a1c; }
.btn-main.waiting { background: #16304a; color: #8fb7a6; box-shadow: none; }
.btn-main small:empty { display: none; }
/* Before the bet: the stake under APOSTAR in the same display type and size, about as wide. */
.btn-main.bet small { font-family: var(--display); font-weight: 400; font-size: 1em; margin-top: 2px; }
.btn-main.cashout small { font-size: .85rem; }
.btn-main small { display: block; font-family: var(--body); font-weight: 800; font-size: .72rem; }

.round-bets { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; }
.round-bets-h { display: flex; justify-content: space-between; min-height: 30px; align-items: center; gap: 8px; margin-bottom: 6px; font-size: .82rem; font-weight: 800; color: var(--muted); }
.round-bets-h b { color: var(--mint); }
.btn-prev { flex: none; display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; background: var(--bg); color: var(--fg); font-size: .75rem; font-weight: 800; text-transform: none; letter-spacing: 0; }
.bets-cols, .bet-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) 62px minmax(0, 1fr); gap: 6px; align-items: center; }
.bets-cols { font-size: .7rem; color: var(--muted); font-weight: 700; padding: 0 8px 4px; }
.bets-cols span:nth-child(n+2) { text-align: center; }
.bets-cols span:last-child { text-align: right; }
.bets-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
/* The round's bet list is not shown (phones and computers alike); the code
   that fills it stays, so it can come back with one line. */
.round-bets { display: none; }

/* Computer screens: a wider game, a taller stage that fills the screen
   above the panels, and the two bet panels side by side. */
@media (min-width: 900px) {
  #app-frame { max-width: 1100px; gap: 12px; padding-top: 16px; }
  .stage { aspect-ratio: auto; height: clamp(340px, calc(100vh - 330px), 640px); }
  .panels { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .brand { font-size: 1.7rem; }
  .stage.flying .mult, .stage.crashed .mult { font-size: 4rem; }
  .stage.betting .mult { font-size: 2.6rem; }
}
.bet-row { padding: 4px 8px; border-radius: 999px; background: var(--bg); font-size: .8rem; font-variant-numeric: tabular-nums; }
.bet-row.won { background: color-mix(in srgb, var(--mint) 16%, var(--bg)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mint) 45%, transparent); }
.bet-row .who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bet-row .who > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bet-row .num { text-align: right; white-space: nowrap; }
.bet-row .num:nth-child(2) { text-align: center; }
.bet-row .coef { text-align: center; color: var(--muted); }
.bet-row .coef em { font-style: normal; font-weight: 800; font-size: .74rem; padding: 2px 7px; border-radius: 999px; }
.coef .lo { background: #2c3f8f; color: #cfe0ff; } .coef .mid { background: #5b2bbf; color: #efe6ff; } .coef .hi { background: #8a4f00; color: #ffe2a8; }
.av { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 900; font-size: .72rem; color: #120c2a; }
.status { min-height: 1em; font-size: .85rem; color: var(--muted); text-align: center; margin: 0; }

.modal { position: fixed; inset: 0; z-index: 40; background: #000b; display: grid; place-items: center; padding: 16px; }
.modal-card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; width: 100%; max-width: 380px; max-height: 100%; overflow-y: auto; }
.modal-card h2.sub { margin-top: 14px; font-size: 1rem; }
.modal-card h2 { margin: 0 0 8px; font-family: var(--display); font-size: 1.2rem; color: var(--amber); }
.modal-card ol { padding-left: 1.2em; margin: 0 0 8px; line-height: 1.45; }
.modal-card p { margin: 6px 0; line-height: 1.45; }
.modal-x { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: var(--panel2); font-size: 1.3rem; line-height: 1; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .72rem; word-break: break-all; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition: none !important; } }
