/* SlotBattles (Powered by GLuck) — mobile-first. Olympus theme.
   Original art is emoji + CSS only; no third-party assets or brand names. */
:root {
  --bg-0: #060c24;
  --bg-1: #0b1437;
  --bg-2: #15235c;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-strong: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.13);
  --text: #eef3ff;
  --muted: #9fb0d6;
  --gold-1: #ffe9a3;
  --gold-2: #f3b73c;
  --gold-3: #c8861a;
  --purple: #6a8bff;
  --pink: #46d8ff;
  --green: #38e8a0;
  --danger: #ff5c5c;
  --bolt: #59e0ff;
  --radius: 16px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 50% -8%, rgba(243, 183, 60, 0.22), transparent 60%),
    radial-gradient(900px 600px at 50% -10%, var(--bg-2), transparent 62%),
    radial-gradient(700px 500px at 90% 8%, rgba(89, 224, 255, 0.12), transparent 55%),
    linear-gradient(160deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100%;
  position: relative;
}

/* ---- Screens ---- */
.screen { display: none; min-height: 100vh; min-height: 100dvh; flex-direction: column; }
.screen.active { display: flex; }

/* ---- Buttons ---- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: 14px;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease, opacity .15s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-lg { padding: 17px; font-size: 17px; }
.btn-primary {
  border: none;
  color: #2a1500;
  background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
  box-shadow: 0 8px 20px rgba(246, 183, 60, 0.35);
}
.btn-primary:active { filter: brightness(0.97); }
.btn-ghost { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.btn.is-ready { background: linear-gradient(180deg, #50f0a8, #21c47e); color: #04341f; border: none; }

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
  display: grid; place-items: center;
}

/* ---- Home ---- */
.home { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 22px calc(28px + var(--safe-bottom)); text-align: center; gap: 10px; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.brand-mark { width: 96px; height: 96px; filter: drop-shadow(0 8px 22px rgba(243, 183, 60, 0.4)); }
.brand-word {
  font-size: 40px; font-weight: 900; letter-spacing: 0.5px; line-height: 1;
  background: linear-gradient(180deg, #fff, var(--gold-1));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-word span { background: linear-gradient(180deg, var(--bolt), var(--purple)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-by { font-size: 11px; letter-spacing: 2px; color: var(--muted); font-weight: 700; }
.brand-by b { color: var(--gold-1); }
.tagline { color: var(--muted); margin: 8px 0 18px; font-weight: 600; }
.brand-foot { text-align: center; color: var(--muted); font-size: 11px; letter-spacing: .5px; margin: 12px 0 0; opacity: .8; }
.brand-foot b { color: var(--gold-1); }
.card {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  text-align: left;
  display: flex; flex-direction: column; gap: 12px;
}
.card label { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
input {
  width: 100%;
  font-size: 17px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  outline: none;
}
input:focus { border-color: var(--gold-2); box-shadow: 0 0 0 3px rgba(246, 183, 60, 0.2); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 4px 0; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.join-row { display: flex; gap: 10px; }
.code-field { text-transform: uppercase; letter-spacing: 6px; font-weight: 800; text-align: center; flex: 1; }
.join-row .btn { width: auto; flex: 0 0 96px; }
.footnote { color: var(--muted); font-size: 12px; margin-top: 16px; opacity: .8; }

/* ---- Top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(14px + var(--safe-top)) 16px 14px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(180deg, rgba(18, 7, 38, 0.92), rgba(18, 7, 38, 0.55));
  backdrop-filter: blur(8px);
}
.room { display: flex; flex-direction: column; align-items: center; }
.room-label { font-size: 10px; letter-spacing: 2px; color: var(--muted); }
.room-code {
  font-size: 26px; font-weight: 900; letter-spacing: 6px;
  background: none; border: none; color: var(--gold-1); cursor: pointer; padding: 0;
}
.room-code.copied::after { content: " ✓"; color: var(--green); }
.pill { background: var(--panel-strong); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 800; font-size: 14px; }

/* ---- Lobby ---- */
.lobby { flex: 1; padding: 18px 16px; overflow-y: auto; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 0 0 12px; }
.player-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.player-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px;
  animation: pop .25s ease;
}
.avatar {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 40px;
  display: grid; place-items: center; font-weight: 900; font-size: 16px;
  background: linear-gradient(180deg, var(--purple), #5b34c0); color: #fff;
}
.avatar.bot { background: linear-gradient(180deg, #4a5568, #2d3340); }
.player-row .pname { font-weight: 700; flex: 1; display: flex; align-items: center; gap: 8px; }
.tag { font-size: 10px; font-weight: 800; padding: 3px 7px; border-radius: 999px; letter-spacing: .5px; }
.tag.you { background: rgba(246, 183, 60, 0.2); color: var(--gold-1); }
.tag.host { background: rgba(138, 92, 255, 0.25); color: #cdb6ff; }
.tag.bot { background: rgba(255,255,255,0.1); color: var(--muted); }
.ready-dot { font-size: 13px; font-weight: 800; }
.ready-dot.yes { color: var(--green); }
.ready-dot.no { color: var(--muted); }

.lobby-foot { padding: 14px 16px calc(16px + var(--safe-bottom)); border-top: 1px solid var(--line); background: rgba(18, 7, 38, 0.6); backdrop-filter: blur(8px); }
.status { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 12px; min-height: 16px; }

/* ---- Game ---- */
.game-topbar { gap: 8px; }
.game-topbar .stat { flex: 1; display: flex; flex-direction: column; align-items: center; }
.stat-label { font-size: 9px; letter-spacing: 1.4px; color: var(--muted); }
.stat-value { font-size: 20px; font-weight: 900; }
.stat-value.bump { animation: bump .4s ease; }
.mute { flex: 0 0 40px; }

.game { flex: 1; display: flex; flex-direction: column; padding: 14px 14px calc(14px + var(--safe-bottom)); gap: 14px; }
.slot-wrap { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.slot-frame {
  position: relative; width: 100%;
  border-radius: 20px;
  padding: 12px;
  border: 2px solid transparent;
  background-clip: padding-box;
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(255,255,255,0.06);
}
.slot-frame.olympus {
  background:
    radial-gradient(130% 90% at 50% 0%, rgba(89,224,255,0.14), transparent 60%),
    linear-gradient(180deg, #18306e, #0a1330);
}
.slot-frame::before {
  content: ""; position: absolute; inset: -2px; border-radius: 22px; z-index: -1;
  background: linear-gradient(180deg, var(--gold-1), var(--gold-3));
}
.slot-title { text-align: center; margin: 0 0 10px; }
.slot-title span {
  display: inline-block; font-size: 12px; font-weight: 900; letter-spacing: 2px;
  color: #2a1a00; background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
  padding: 5px 16px; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.6);
}
.slot {
  display: flex; gap: 8px;
  background: radial-gradient(100% 130% at 50% -15%, #14224c, #060b1e);
  border-radius: 14px; padding: 8px;
  box-shadow: inset 0 8px 24px rgba(0,0,0,0.65);
}
.reel {
  flex: 1; position: relative; overflow: hidden; border-radius: 10px;
  background: linear-gradient(180deg, #0f1838, #0a1026);
  aspect-ratio: 1 / 3;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}
.reel-strip { position: absolute; left: 0; right: 0; top: 0; display: flex; flex-direction: column; will-change: transform; }
.tile {
  position: relative;
  display: grid; place-items: center;
  font-size: clamp(26px, 9vw, 40px);
  line-height: 1;
}
.tile-inner {
  width: 86%; height: 86%; border-radius: 10px;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 28%, #26396b, #121b3c);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), inset 0 -3px 7px rgba(0,0,0,0.45);
}
.tile.wild .tile-inner {
  background: radial-gradient(circle at 50% 28%, #fff0bf, #e09a12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 0 16px rgba(255,226,122,0.7);
}
.wild-tag {
  position: absolute; bottom: 9%; left: 50%; transform: translateX(-50%);
  font-size: 8px; font-weight: 900; letter-spacing: 1px;
  color: #3a1d00; background: rgba(255,255,255,0.72);
  padding: 1px 6px; border-radius: 6px;
}
.tile.win .tile-inner {
  animation: winpulse .6s ease infinite alternate;
  box-shadow: 0 0 0 2px var(--gold-1), 0 0 18px rgba(255,226,122,0.85);
}
.win-banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.6);
  font-size: 42px; font-weight: 900; color: var(--gold-1);
  text-shadow: 0 4px 18px rgba(0,0,0,0.6); opacity: 0; pointer-events: none;
  background: rgba(8, 12, 32, 0.6); padding: 8px 20px; border-radius: 16px;
}
.win-banner.show { animation: winpop 1.1s ease forwards; }
.win-banner.big { color: #fff; background: linear-gradient(180deg, var(--bolt), #1f6bff); }

.spin-btn {
  appearance: none; border: none; cursor: pointer;
  width: 100%; max-width: 320px;
  padding: 18px; border-radius: 18px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: linear-gradient(180deg, #5fdcff, #1f6bff);
  color: #fff; box-shadow: 0 12px 26px rgba(31, 107, 255, 0.5);
  transition: transform .08s ease, filter .15s ease;
}
.spin-btn .spin-label { font-size: 24px; font-weight: 900; letter-spacing: 3px; text-shadow: 0 2px 8px rgba(0,0,0,0.25); }
.spin-btn .bet { font-size: 12px; opacity: .9; }
.spin-btn:active { transform: translateY(2px) scale(0.99); }
.spin-btn[disabled] { filter: grayscale(0.5) brightness(0.8); opacity: .7; cursor: not-allowed; }

/* ---- Leaderboard ---- */
.board { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.leaderboard { list-style: none; margin: 0; padding: 0; position: relative; }
.lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 12px;
  background: rgba(255,255,255,0.03);
  margin-bottom: 8px;
  transition: transform .45s cubic-bezier(.2,.8,.2,1), background .3s ease;
}
.lb-row:last-child { margin-bottom: 0; }
.lb-row.you { background: rgba(243, 183, 60, 0.12); box-shadow: inset 0 0 0 1px rgba(243,183,60,0.4); }
.lb-row.flash { background: rgba(56, 232, 160, 0.20); }
.lb-row.done { opacity: .62; }
.lb-rank {
  flex: 0 0 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center; font-weight: 900; font-size: 13px;
  background: var(--panel-strong); color: var(--muted);
}
.lb-row.r1 .lb-rank { background: linear-gradient(180deg, var(--gold-1), var(--gold-2)); color: #3a1d00; }
.lb-row.r2 .lb-rank { background: linear-gradient(180deg, #e9eef5, #aab4c4); color: #20242c; }
.lb-row.r3 .lb-rank { background: linear-gradient(180deg, #f0b07a, #c9803f); color: #3a1d00; }
.lb-main { flex: 1; min-width: 0; }
.lb-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.lb-name { font-weight: 700; display: flex; align-items: center; gap: 6px; min-width: 0; }
.lb-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.lb-val { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.lb-balance { font-weight: 900; font-size: 15px; }
.lb-sub { font-size: 10px; color: var(--muted); }
.lb-track { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.09); overflow: hidden; }
.lb-bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #3b62ff, #59e0ff); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.lb-row.r1 .lb-bar { background: linear-gradient(90deg, var(--gold-2), var(--gold-1)); }
.lb-row.r2 .lb-bar { background: linear-gradient(90deg, #aab4c4, #e9eef5); }
.lb-row.r3 .lb-bar { background: linear-gradient(90deg, #c9803f, #f0b07a); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: 0 0 7px; }
.dot.off { background: var(--muted); opacity: .5; }

/* ---- Results ---- */
.results { flex: 1; padding: calc(20px + var(--safe-top)) 18px 10px; overflow-y: auto; }
.results-title { text-align: center; font-size: 26px; font-weight: 900; margin: 6px 0 18px; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin-bottom: 22px; }
.pod { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pod .pavatar { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; font-weight: 900; background: linear-gradient(180deg, var(--purple), #5b34c0); color: #fff; }
.pod .pname { font-weight: 800; font-size: 13px; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .pscore { font-size: 13px; color: var(--gold-1); font-weight: 800; }
.pod .bar { width: 100%; border-radius: 12px 12px 0 0; display: grid; place-items: start center; padding-top: 8px; font-size: 22px; font-weight: 900; }
.pod.p1 .bar { height: 96px; background: linear-gradient(180deg, var(--gold-1), var(--gold-3)); color: #3a1d00; }
.pod.p2 .bar { height: 72px; background: linear-gradient(180deg, #e9eef5, #aab4c4); color: #20242c; }
.pod.p3 .bar { height: 56px; background: linear-gradient(180deg, #f0b07a, #c9803f); color: #3a1d00; }
.pod.p1 .pavatar { box-shadow: 0 0 0 3px var(--gold-1), 0 0 24px rgba(255,226,122,0.6); }
.results-actions { display: flex; gap: 10px; }
.results-actions .btn { flex: 1; }

/* ---- Overlays ---- */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(8, 4, 20, 0.7); backdrop-filter: blur(4px); }
.overlay.hidden { display: none; }
.countdown span { font-size: 160px; font-weight: 900; color: var(--gold-1); text-shadow: 0 10px 40px rgba(0,0,0,0.6); animation: countpop .9s ease; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
  background: #2a1357; color: var(--text); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 12px; z-index: 60; max-width: 90%;
  box-shadow: var(--shadow); font-weight: 600; font-size: 14px; text-align: center;
}
.toast.hidden { display: none; }
.toast.error { background: #4a1530; border-color: var(--danger); }

/* ---- Animations ---- */
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.25); color: var(--green); } 100% { transform: scale(1); } }
@keyframes winpulse { from { box-shadow: 0 0 0 2px var(--gold-1), 0 0 8px rgba(255,226,122,0.5); } to { box-shadow: 0 0 0 2px var(--gold-1), 0 0 22px rgba(255,226,122,0.95); } }
@keyframes winpop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  70% { opacity: 1; transform: translate(-50%, -60%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -90%) scale(0.95); }
}
@keyframes countpop { 0% { opacity: 0; transform: scale(0.4); } 30% { opacity: 1; transform: scale(1.1); } 100% { opacity: 0.8; transform: scale(1); } }

@media (min-height: 760px) {
  .stat-value { font-size: 22px; }
  .spin-btn { padding: 22px; }
}
