@font-face {
  font-family: Orbitron;
  src: url("font/orbitron_bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --abyss: #070412;
  --night: #120b26;
  --surface: #1b1233;
  --raised: #261a47;
  --sunken: #0e0821;
  --text: #f7f5ff;
  --muted: #b9aedc;
  --dim: #8577ae;
  --violet: #7c3aed;
  --violet-light: #a776ff;
  --magenta: #de37a8;
  --gold: #ffc844;
  --amber: #ff9628;
  --cyan: #38c4ff;
  --mint: #40e6a8;
  --pink: #ff60b0;
  --warn: #ffb45a;
  --error: #ff5d86;
  --dock: 68px;
  --pad-top: calc(12px + env(safe-area-inset-top));
  --pad-bottom: calc(var(--dock) + 12px + env(safe-area-inset-bottom));
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--abyss); color: var(--text); }
body {
  font-family: Orbitron, "Trebuchet MS", sans-serif;
  background:
    linear-gradient(180deg, rgba(7,4,18,.72), rgba(7,4,18,.4) 40%, rgba(7,4,18,.88)),
    url("assets/bg_arena.png") center/cover no-repeat,
    var(--abyss);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
body.angry {
  background:
    linear-gradient(180deg, rgba(7,4,18,.48), rgba(7,4,18,.16) 45%, rgba(7,4,18,.78)),
    url("assets/bg_angry_spins.png") center/cover no-repeat,
    var(--abyss);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("assets/fx_particles.png") center/cover;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s;
}
body.angry::before { opacity: .3; }

button, input { font: inherit; color: inherit; }
button {
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .08s ease, filter .15s, opacity .15s, background .2s, border-color .2s, color .2s;
}
button:not(:disabled):active { transform: scale(.96); filter: brightness(1.15); }
button:disabled { cursor: default; opacity: .45; filter: saturate(.5); }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
img { max-width: 100%; display: block; -webkit-user-drag: none; pointer-events: none; }

#shell {
  position: relative;
  min-height: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: var(--pad-top) 14px var(--pad-bottom);
}
body.no-dock { --pad-bottom: calc(16px + env(safe-area-inset-bottom)); }
section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: calc(100vh - var(--pad-top) - var(--pad-bottom));
  min-height: calc(100dvh - var(--pad-top) - var(--pad-bottom));
}
section[data-screen="game"], section[data-screen="disclosure"] { justify-content: center; }

.logo { width: auto; margin: 18px auto; color: var(--gold); font-size: 42px; letter-spacing: .04em; text-align: center; text-shadow: 0 8px 18px rgba(0,0,0,.45); }
.hero { position: relative; min-height: 150px; display: grid; place-items: center; }
.hero .portal { position: absolute; width: 86%; opacity: .55; }
.hero .logo { position: relative; width: auto; font-size: 40px; }

.card {
  background: linear-gradient(180deg, rgba(38,26,71,.92), rgba(27,18,51,.92));
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card.gold { box-shadow: inset 0 0 0 1px rgba(255,200,68,.35); }
.card h1, .card h3 { margin: 0; font-size: 15px; line-height: 1.35; }
.card p, .lead { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.kicker { color: var(--dim); font-size: 11px; letter-spacing: .14em; }
.points { color: var(--gold); font-size: 34px; line-height: 1; }
.points span { color: var(--muted); font-size: 14px; margin-left: 6px; }

.cta, .danger, .links button, .row button, .back, .choice, .ghost {
  border: 0;
  border-radius: 14px;
  background: linear-gradient(90deg, var(--violet), var(--magenta));
  padding: 14px 16px;
  letter-spacing: .04em;
}
.cta.gold { background: linear-gradient(90deg, var(--amber), var(--gold)); color: var(--abyss); box-shadow: 0 0 18px rgba(255,150,40,.35); }
.danger { background: linear-gradient(90deg, #8a2048, var(--error)); }
.links, .row { display: flex; gap: 8px; }
.links button, .row button, .back, .choice, .ghost {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
}
.links button, .row button, .back { flex: 1; }
.ghost.cyan { border-color: rgba(56,196,255,.5); }
.pill {
  align-self: flex-start;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  background: rgba(64,230,168,.18);
  color: var(--mint);
}
.pill.warn { background: rgba(255,180,90,.18); color: var(--warn); }
.pill.pink { background: rgba(255,96,176,.18); color: var(--pink); }

/* Game HUD */
.glass {
  background: linear-gradient(180deg, rgba(38,26,71,.78), rgba(14,8,33,.78));
  border: 1px solid var(--line, rgba(255,255,255,.12));
  border-radius: 16px;
}
.hud { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chip {
  min-width: 0;
  background: rgba(14,8,33,.72);
  border: 1px solid rgba(255,255,255,.08);
  border-top: 2px solid var(--accent, rgba(255,255,255,.12));
  border-radius: 14px;
  padding: 8px 10px;
  --accent: var(--dim);
}
.chip span { color: var(--dim); font-size: 10px; letter-spacing: .08em; }
.chip b { display: block; font-size: 16px; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.chip.gold { --accent: var(--gold); }
#chip-bet { --accent: var(--cyan); }
#chip-bet.angry { --accent: var(--pink); }
#chip-win { --accent: var(--muted); }
#chip-win.on { --accent: var(--mint); }

.banner { --line: rgba(255,96,176,.55); display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 12px; }
.banner .pill { align-self: center; }

.meter { --line: rgba(124,58,237,.45); padding: 12px 14px; }
.meter.full { --line: rgba(255,200,68,.7); }
.meter-head { display: flex; justify-content: space-between; align-items: center; color: var(--dim); font-size: 10px; letter-spacing: .12em; }
.meter-head b { color: var(--muted); font-size: 12px; letter-spacing: .04em; }
.meter.full .meter-head b { color: var(--gold); }
.meter-track {
  position: relative;
  height: 14px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--sunken);
  border: 1px solid rgba(255,255,255,.1);
  overflow: hidden;
}
.meter-track i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--pink));
  transition: width .52s ease;
}
.meter.full .meter-track i { background: linear-gradient(90deg, var(--amber), var(--gold)); }
.meter-track::before {
  content: "";
  position: absolute;
  top: 0; left: 6px; right: 6px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
}
.meter-track::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(20% - 1px), rgba(7,4,18,.45) calc(20% - 1px) 20%);
}
body.reduced .meter-track i { transition: none; }

/* Cabinet */
.cabinet {
  position: relative;
  padding: 8px;
  border: 3px solid transparent;
  border-radius: 26px;
  background:
    linear-gradient(180deg, #3a2610, var(--night), #1a1028) padding-box,
    linear-gradient(135deg, var(--gold), var(--violet-light), var(--cyan), var(--gold)) border-box;
  box-shadow: 0 0 24px rgba(124,58,237,.35);
}
.cabinet.angry {
  background:
    linear-gradient(180deg, #3a1024, var(--night), #1a1028) padding-box,
    linear-gradient(135deg, var(--pink), var(--gold), var(--magenta)) border-box;
  box-shadow: 0 0 28px rgba(255,96,176,.45);
}
.well {
  position: relative;
  padding: 6px;
  border-radius: 18px;
  background: linear-gradient(180deg, #12081f, var(--abyss), #1a0c28);
  border: 1px solid rgba(255,255,255,.1);
}
.leds {
  position: absolute;
  top: 0; left: 18px; right: 18px;
  height: 8px;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  z-index: 1;
}
.leds i, .corner {
  border-radius: 50%;
  background: var(--cyan);
  animation: led .9s ease-in-out infinite alternate;
}
.leds i { width: 7px; height: 7px; }
.leds i:nth-child(even) { animation-direction: alternate-reverse; }
.cabinet.angry .leds i, .cabinet.angry .corner { background: var(--gold); }
.corner { position: absolute; width: 10px; height: 10px; }
.corner.tl { top: 2px; left: 2px; }
.corner.tr { top: 2px; right: 2px; }
.corner.bl { bottom: 2px; left: 2px; }
.corner.br { bottom: 2px; right: 2px; }
@keyframes led { from { opacity: .3; } to { opacity: 1; } }
body.reduced .leds i, body.reduced .corner { animation: none; }

.reels-wrap {
  position: relative;
  width: min(100%, calc(min(300px, 33vh) * 5 / 3));
  width: min(100%, calc(min(300px, 33dvh) * 5 / 3));
  margin: 0 auto;
}
#reels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(3, auto);
  grid-auto-flow: column;
  gap: 4px;
}
.cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(0,0,0,.18));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: box-shadow .2s, background .2s;
}
.cell img { width: 86%; height: 86%; object-fit: contain; }
.cell.hit {
  background: linear-gradient(180deg, rgba(255,200,68,.28), rgba(255,150,40,.1));
  box-shadow: inset 0 0 0 2px var(--gold), 0 0 12px rgba(255,200,68,.45);
}
.cell.hit img { animation: win-pulse .62s ease-in-out infinite alternate; }
.cell.spin img { animation: reel-blur .1s linear infinite; }
body.reduced .cell.hit img { animation: none; transform: scale(1.08); }
@keyframes win-pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
@keyframes reel-blur {
  from { transform: translateY(-12%); filter: blur(1.5px) brightness(1.2); }
  to { transform: translateY(12%); filter: blur(1.5px) brightness(1.2); }
}

#payline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  animation: payline-pulse .7s ease-in-out infinite alternate;
}
#payline polyline { fill: none; stroke-linecap: round; stroke-linejoin: round; }
#payline .halo { stroke: var(--magenta); stroke-opacity: .3; stroke-width: 10; }
#payline .core { stroke: var(--gold); stroke-width: 3; }
#payline .glow { fill: var(--gold); fill-opacity: .35; }
#payline .node { fill: var(--text); }
@keyframes payline-pulse { from { opacity: .55; } to { opacity: 1; } }

.summary { min-height: 1.2em; margin: 0; color: var(--mint); font-size: 12px; text-align: center; }

/* Controls */
.stepper { --line: rgba(255,200,68,.35); display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; padding: 10px 12px; }
.stepper.locked { --line: rgba(255,96,176,.55); }
.step {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  background: var(--raised);
  border: 1px solid rgba(255,200,68,.7);
  color: var(--gold);
  font-size: 24px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.step:disabled { opacity: 1; filter: none; background: rgba(27,18,51,.5); border-color: rgba(255,255,255,.08); color: var(--dim); }
.bet-value { text-align: center; }
.bet-value span { color: var(--dim); font-size: 10px; letter-spacing: .14em; }
.bet-value b { display: block; color: var(--gold); font-size: 28px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stepper.locked .bet-value span { color: var(--pink); }

.controls { display: grid; grid-template-columns: 1fr 1.15fr; gap: 12px; align-items: center; }
#auto { height: 72px; border-radius: 18px; border-color: rgba(167,118,255,.55); }
#auto.on { border-color: var(--pink); color: var(--pink); background: rgba(255,96,176,.12); }
#spin {
  position: relative;
  height: 96px;
  padding: 0;
  border: 0;
  background: transparent;
  filter: drop-shadow(0 0 12px rgba(255,200,68,.55)) drop-shadow(0 0 4px rgba(255,150,40,.6));
}
#spin img { width: 100%; height: 100%; object-fit: cover; object-position: center 47%; }
#spin:not(:disabled):active { filter: drop-shadow(0 0 16px rgba(255,200,68,.7)) brightness(1.15); }
#spin:disabled { filter: none; }
#spin .dots { position: absolute; inset: 0; display: none; place-items: center; font-size: 26px; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
#spin.busy .dots { display: grid; }
#spin.busy img { opacity: .5; }

/* Secondary screens */
.top { display: flex; align-items: center; gap: 8px; }
.top h2 { margin: 0; font-size: 18px; }
.back { flex: 0 0 44px; padding: 10px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.rowline { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.rowline span { color: var(--muted); }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.toggle input { width: 22px; height: 22px; accent-color: var(--violet); }

.symbol-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.symbol-row img { width: 40px; height: 40px; }
.symbol-row div { margin-left: auto; text-align: right; font-size: 11px; color: var(--muted); }
.symbol-row strong { color: var(--gold); display: block; font-size: 13px; }

/* Bottom navigation */
#dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  max-width: 520px;
  margin: 0 auto;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--night), var(--abyss));
}
#dock::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--violet), transparent);
}
#dock button {
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 10px;
}
#dock svg {
  box-sizing: content-box;
  width: 22px;
  height: 22px;
  padding: 4px 16px;
  border-radius: 999px;
  fill: currentColor;
  transition: background .2s, fill .2s;
}
#dock button.on { color: var(--gold); }
#dock button.on svg { background: var(--gold); fill: var(--abyss); }
body.no-dock #dock { display: none; }

/* Modals */
#modal {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7,4,15,.8);
}
#modal[data-kind="fury"] { background: rgba(7,4,18,.93); }
#modal .fx {
  position: absolute;
  inset: 0;
  background: url("assets/fx_particles.png") center/cover;
  opacity: 0;
  pointer-events: none;
}
#modal.fx-on .fx { animation: shimmer .9s ease-in-out infinite alternate; }
#modal[data-kind="fury"].fx-on .fx { animation: none; opacity: .4; }
body.reduced #modal.fx-on .fx { animation: none; opacity: .45; }
@keyframes shimmer { from { opacity: .29; } to { opacity: .45; } }

.frame {
  --accent: var(--gold);
  position: relative;
  width: min(100%, 420px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  text-align: center;
  border: 2px solid transparent;
  border-radius: 26px;
  background:
    linear-gradient(180deg, var(--raised), var(--night), var(--abyss)) padding-box,
    linear-gradient(135deg, var(--accent), rgba(255,255,255,.18), var(--accent)) border-box;
  box-shadow: 0 0 32px -6px var(--accent);
  animation: pop .32s ease-out;
}
.frame::before {
  content: "";
  position: absolute;
  top: 0; left: 12%; right: 12%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
body.reduced .frame { animation: none; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.frame h3 { margin: 0; color: var(--gold); font-size: 20px; }
.frame p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.frame .cta, .frame .list, .frame .choice { align-self: stretch; }

.win-title { margin: 0; color: var(--accent); font-size: 26px; line-height: 1.2; text-shadow: 0 0 18px var(--accent); }
.win-amount { font-size: 46px; line-height: 1; font-variant-numeric: tabular-nums; }
.frame .tap { animation: shimmer-text .9s ease-in-out infinite alternate; }
body.reduced .frame .tap { animation: none; }
@keyframes shimmer-text { from { opacity: .65; } to { opacity: 1; } }

.chest { width: 104px; height: 104px; object-fit: contain; }
.pulse { animation: breathe 1.1s ease-in-out infinite alternate; }
body.reduced .pulse { animation: none; }
@keyframes breathe { from { transform: scale(.94); } to { transform: scale(1.04); } }
.boxes { align-self: stretch; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: 18px;
  border: 1px solid var(--box-line);
  background: linear-gradient(180deg, var(--raised), var(--sunken));
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}
.box img { width: 100%; height: 84px; object-fit: contain; }
.box:disabled { opacity: 1; filter: none; }
.box.picked { border: 2px solid var(--gold); color: var(--gold); box-shadow: 0 0 16px rgba(255,200,68,.35); }
.box.dim img { opacity: .45; }
.reward { color: var(--gold) !important; font-size: 18px !important; }

/* Short phones: keep the Spin button above the fold */
@media (max-height: 720px) {
  section[data-screen="game"] { gap: 8px; }
  .chip { padding: 6px 8px; }
  .chip b { font-size: 14px; }
  .banner { padding: 6px 10px; }
  .meter { padding: 8px 12px; }
  .meter-track { height: 10px; margin-top: 4px; }
  .cabinet { padding: 6px; }
  .well { padding: 4px; }
  .reels-wrap { width: min(100%, calc(27vh * 5 / 3)); width: min(100%, calc(27dvh * 5 / 3)); }
  .stepper { grid-template-columns: 40px 1fr 40px; padding: 6px 10px; }
  .step { width: 40px; height: 40px; font-size: 20px; }
  .bet-value b { font-size: 22px; }
  #auto { height: 56px; }
  #spin { height: 72px; }
  section[data-screen="game"] > .ghost { padding: 10px 16px; font-size: 13px; }
}
