:root {
  --ground-0: #110505; --ground-1: #1A0807; --ground-2: #22100C; --ground-3: #2A120A; --ember: #4A140A;
  --line: #5A2A1A; --line-warm: #8A4A1A;
  --gold: #F5B83D; --flame: #FF7A3D; --flame-soft: #FF9A5C; --hot: #C8360C;
  --text: #FFF4E6; --muted: #D9BFA6; --ink: #1A0A00;
  --display: 'Bungee', system-ui, sans-serif;
  --ui: 'Barlow Condensed', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 60% at 50% 0%, var(--ember) 0%, var(--ground-1) 55%, var(--ground-0) 100%) fixed, var(--ground-0);
  color: var(--text); font-family: var(--ui); font-size: 17px;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wordmark { display: flex; flex-direction: column; align-items: center; line-height: 1; font-family: var(--display); }
.wordmark span:first-child { color: var(--gold); font-size: 19px; }
.wordmark span:last-child { color: var(--flame); font-size: 13px; letter-spacing: 3px; }
.wordmark--big span:first-child { font-size: 34px; }
.wordmark--big span:last-child { font-size: 22px; letter-spacing: 6px; }

.btn { min-height: 48px; border-radius: 14px; border: none; font-weight: 700; font-size: 19px; cursor: pointer; padding: 0 18px; }
.btn--primary { background: var(--gold); color: var(--ink); }
.btn--primary:disabled { opacity: .6; cursor: default; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--ground-2); display: grid; place-items: center; cursor: pointer; }

/* Sign-in */
.signin { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 24px 16px; }
.signin__form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 8px; }
.signin__form label { font-weight: 600; color: var(--muted); }
.signin__form input { height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--ground-2); padding: 0 14px; font-size: 20px; }
.signin__form input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.signin__error { min-height: 22px; margin: 4px 0; color: #FF8A66; }

/* Lobby: phone first */
.lobby { height: 100%; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.topbar { flex-shrink: 0; height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px; }
.topbar__right { display: flex; align-items: center; gap: 10px; }
.topbar .balance--header, .topbar .btn--resume { display: none; }
.chip-account { height: 32px; padding: 0 10px; border-radius: 16px; background: var(--ground-2); border: 1px solid var(--line); display: flex; align-items: center; font-weight: 600; color: var(--muted); }

/* The cafe's community bonus, shown to an at-home player as an invitation: it is only won in the cafe. */
.gbf-teaser { flex-shrink: 0; margin: 8px 12px 0; padding: 8px 12px; border-radius: 12px; background: #2A1206; border: 1px solid #8A4B12; color: #FFD27A; font-size: 0.9rem; text-align: center; }
.gbf-teaser[hidden] { display: none; }
.jackpots { flex-shrink: 0; margin: 4px 12px 0; padding: 10px; border-radius: 16px; background: #1E0B08; border: 1px solid #6B3A12; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.jp { min-height: 52px; border-radius: 10px; background: var(--ground-3); border: 1px solid var(--line-warm); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.jp__name { font-size: 13px; font-weight: 700; letter-spacing: 2px; color: var(--flame-soft); }
.jp__value { font-family: var(--display); font-size: 17px; }
.jp--mega { grid-column: 1 / -1; min-height: 58px; flex-direction: row; justify-content: space-between; padding: 0 14px; border: 2px solid var(--gold); }
.jp--mega .jp__name { font-family: var(--display); font-size: 20px; letter-spacing: 0; color: var(--gold); }
.jp--mega .jp__value { font-size: 30px; }

.filters { flex-shrink: 0; display: flex; gap: 8px; padding: 12px 12px 8px; overflow-x: auto; }
.filter { flex-shrink: 0; min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line); background: var(--ground-2); color: #E8D3BF; font-weight: 600; cursor: pointer; }
.filter[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--ink); font-weight: 700; }

.grid { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 12px 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; align-content: start; }
.grid-empty { margin: 24px 16px; color: var(--muted); text-align: center; }
.tile { position: relative; padding: 0; border: none; background: none; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.tile:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 12px; }
.tile img { display: block; width: 100%; aspect-ratio: 290 / 373; border-radius: 10px; box-shadow: 0 6px 18px rgba(0, 0, 0, .55); }
.tile__name { font-size: 17px; font-weight: 700; padding: 0 2px; }
.badge { position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 6px; font-size: 13px; font-weight: 700; letter-spacing: 1px; }
.badge--hot { background: var(--hot); color: #FFFFFF; }
.badge--new { background: var(--gold); color: var(--ink); }

.bottombar { flex-shrink: 0; padding: 10px 12px calc(14px + env(safe-area-inset-bottom)); background: var(--ground-1); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.bottombar__balances { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.balance { padding: 6px 12px; border-radius: 12px; background: var(--ground-2); border: 1px solid var(--line); display: flex; flex-direction: column; }
.balance__label { font-size: 13px; font-weight: 700; letter-spacing: 1.5px; color: var(--muted); }
.balance__value { font-family: var(--display); font-size: 22px; }
.balance__value--gold { color: var(--gold); }

/* Menu */
.menu { position: fixed; inset: 0; display: flex; z-index: 20; }
.menu__panel { width: min(300px, 80vw); height: 100%; background: #1E0B08; border-right: 1px solid #6B3A12; padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; }
.menu__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.menu__muted { color: var(--muted); font-weight: 600; }
.menu__account { font-family: var(--display); font-size: 20px; }
.menu__item { min-height: 48px; border-radius: 10px; border: none; background: var(--ground-3); font-size: 18px; font-weight: 600; text-align: left; padding: 0 14px; display: flex; align-items: center; color: var(--text); text-decoration: none; cursor: pointer; }
.menu__hint { margin: 0 4px; color: var(--muted); }
.menu__spacer { flex: 1; }
.menu__item--logout { justify-content: center; background: transparent; border: 1px solid var(--hot); color: #FF8A66; font-weight: 700; }
.menu__scrim { flex: 1; border: none; background: rgba(0, 0, 0, .6); cursor: pointer; }

/* Game overlay */
.game { position: fixed; inset: 0; background: #000000; z-index: 30; }
.game__frame { width: 100%; height: 100%; border: 0; display: block; }
.game__close { position: absolute; top: calc(8px + env(safe-area-inset-top)); left: 8px; width: 44px; height: 44px; border-radius: 22px; border: none; background: rgba(0, 0, 0, .45); color: #FFFFFF; display: grid; place-items: center; cursor: pointer; }

/* Phone control bar: the frame on top, the bar's own controls below it. */
.game--bar { display: flex; flex-direction: column; }
.game--bar .game__frame { order: 1; flex: 1 1 auto; min-height: 0; height: auto; }
.game--bar #game-close { display: none; }
.bar { order: 2; position: relative; flex: 0 0 auto; height: calc(clamp(140px, 16vh, 168px) + env(safe-area-inset-bottom)); height: calc(clamp(140px, 16dvh, 168px) + env(safe-area-inset-bottom)); padding: 4px calc(8px + env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left)); background: var(--ground-1); border-top: 1px solid var(--line); display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.bar, .bar * { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.bar__message { margin: 0; max-width: calc(100% - 120px); height: 16px; line-height: 16px; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__follow { position: absolute; top: 0; right: calc(0px + env(safe-area-inset-right)); z-index: 0; height: 50px; min-width: 48px; padding: 3px 20px 25px; border: none; background: none; color: var(--flame-soft); font-family: var(--ui); font-weight: 700; font-size: 14px; line-height: 22px; letter-spacing: 1px; cursor: pointer; }
.bar__follow::before { content: ''; position: absolute; z-index: -1; top: 3px; bottom: 25px; left: 12px; right: 12px; border-radius: 12px; border: 1px solid var(--flame); background: var(--ground-3); }
.bar__meters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.bar__meter { min-width: 0; display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.bar__label { font-family: var(--ui); font-weight: 700; font-size: 11px; letter-spacing: 1px; color: var(--flame-soft); white-space: nowrap; }
/* Never cut a value: no ellipsis, no clipping. A long one steps down by data-len, set from its length by the view. */
.bar__value { max-width: 100%; font-family: var(--display); font-size: 17px; color: var(--gold); white-space: nowrap; min-height: 18px; }
.bar__value[data-len="long"] { font-size: 15px; }
.bar__value[data-len="longer"] { font-size: 12px; }
.bar__controls { display: flex; align-items: flex-end; gap: 8px; }
.bar__btn { min-width: 48px; height: 48px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line-warm); background: var(--ground-3); color: var(--text); font-family: var(--ui); font-weight: 700; font-size: 18px; display: grid; place-items: center; cursor: pointer; }
.bar__btn--level { min-width: 72px; padding: 0 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; line-height: 1.05; }
.bar__btn--level .bar__label { font-size: 11px; }
.bar__btn--level .bar__value { font-size: 17px; min-height: 0; }
.bar__btn--level .bar__value[data-len="long"] { font-size: 15px; }
.bar__btn--level .bar__value[data-len="longer"] { font-size: 12px; }
.bar__btn--buy { background: var(--hot); border-color: var(--flame); }
.bar__btn:disabled, .bar__play--off, .bar__row:disabled { opacity: .4; cursor: default; }
.bar__play { margin-left: auto; width: 84px; height: 72px; border-radius: 36px; border: 2px solid var(--gold); background: var(--gold); color: var(--ink); font-family: var(--display); font-size: 20px; cursor: pointer; }
.bar__play[data-face="stop"] { background: var(--hot); border-color: var(--flame); color: var(--text); }
.bar__play[data-face="skip"] { background: var(--flame); border-color: var(--flame-soft); }
.bar__play[data-face="auto"] { background: var(--ground-3); border-color: var(--gold); color: var(--gold); }
.bar__sheet { position: absolute; left: calc(8px + env(safe-area-inset-left)); bottom: 100%; margin-bottom: 6px; min-width: 200px; border-radius: 14px; border: 1px solid var(--line-warm); background: var(--ground-2); overflow: hidden; z-index: 2; }
.bar__row { display: block; width: 100%; min-height: 52px; padding: 0 18px; border: none; background: none; text-align: left; font-family: var(--ui); font-weight: 600; font-size: 20px; cursor: pointer; }
.bar__row + .bar__row { border-top: 1px solid var(--line); }
.game__rotate { position: absolute; inset: 0; z-index: 5; background: var(--ground-0); display: grid; place-items: center; padding: 24px; text-align: center; font-family: var(--display); font-size: 22px; color: var(--gold); }
.game__rotate p { margin: 0; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: 90vw; padding: 10px 16px; border-radius: 12px; background: #3A1A10; border: 1px solid var(--flame); z-index: 40; }

/* Desktop */
@media (min-width: 900px) {
  .lobby { padding: 0 32px 28px; gap: 18px; }
  .topbar { height: 76px; padding: 0; }
  .wordmark { flex-direction: row; align-items: baseline; gap: 10px; }
  .wordmark span:first-child { font-size: 30px; }
  .wordmark span:last-child { font-size: 20px; }
  .topbar .balance--header, .topbar .btn--resume:not([hidden]) { display: flex; }
  .topbar .btn--resume { align-items: center; }
  .bottombar { display: none; }
  .jackpots { margin: 0; padding: 0; background: none; border: none; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 14px; }
  .jp--mega { grid-column: auto; }
  .jp { min-height: 84px; }
  .jp__value { font-size: 26px; }
  .jp--mega .jp__value { font-size: 42px; }
  .filters { padding: 0; }
  .grid { padding: 0; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 18px 20px; }
  .tile__name { font-size: 19px; }
}
