/* PLAY.DEELEY.ORG — an original visual identity: minimal arcade machine +
   surreal game show. Deep black backgrounds, a few bright glowing accents,
   big geometric shapes, exaggerated scale. Nothing here is meant to
   resemble any existing game's branding. */

:root {
  --bg: #07070b;
  --bg2: #12121a;
  --bg3: #1c1c28;
  --fg: #f5f5f7;
  --dim: #9a9aab;
  --red: #ff3d5a;
  --blue: #3d7bff;
  --yellow: #ffd43b;
  --green: #2bd97a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 50% -10%, #1a1a2e 0%, var(--bg) 60%);
  color: var(--fg);
  font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
}
#app { position: fixed; inset: 0; overflow: hidden; }
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input { font-family: inherit; }

.a11y-invert { filter: invert(1) hue-rotate(180deg); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── Buttons ─────────────────────────────────────────────────── */

.btn {
  border: none;
  border-radius: 16px;
  font-weight: 700;
  letter-spacing: .03em;
  color: #08080c;
  background: var(--bg3);
  min-height: 48px;
  padding: 12px 20px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:active { transform: scale(.95); }
.btn.big { min-height: 60px; font-size: 1.1rem; padding: 16px 28px; border-radius: 20px; }
.btn.small { min-height: 40px; font-size: .82rem; padding: 8px 16px; border-radius: 12px; }
.btn.wide { width: 100%; }
.btn.red { background: var(--red); color: #fff; box-shadow: 0 0 0 rgba(255,61,90,0), 0 6px 24px -6px rgba(255,61,90,.7); }
.btn.blue { background: var(--blue); color: #fff; box-shadow: 0 6px 24px -6px rgba(61,123,255,.7); }
.btn.green { background: var(--green); color: #06210f; box-shadow: 0 6px 24px -6px rgba(43,217,122,.7); }
.btn.green.on { background: var(--bg3); color: var(--green); box-shadow: none; border: 2px solid var(--green); }
.btn.yellow { background: var(--yellow); color: #201800; box-shadow: 0 6px 24px -6px rgba(255,212,59,.7); }
.btn.ghost { background: transparent; color: var(--fg); border: 2px solid rgba(255,255,255,.18); box-shadow: none; }
.btn.icon { width: 46px; height: 46px; padding: 0; border-radius: 50%; background: rgba(255,255,255,.08); display: flex; align-items: center; justify-content: center; }
.btn.icon svg { fill: none; }
.btn.icon.back { position: absolute; top: calc(var(--safe-t) + 14px); left: 14px; z-index: 5; }
.err { color: var(--red); font-size: .85rem; min-height: 1.2em; margin: 4px 0; }

/* ── Screens ─────────────────────────────────────────────────── */

.screen {
  position: absolute; inset: 0;
  padding: calc(var(--safe-t) + 12px) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 16px);
  display: flex; flex-direction: column;
  max-width: 560px; margin: 0 auto;
}

.home {
  justify-content: space-between;
  background: radial-gradient(circle at 50% 20%, rgba(255,61,90,.14), transparent 60%);
}
.home-top { display: flex; justify-content: flex-end; gap: 8px; }
.home-mid { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; }
.logo { font-size: clamp(2.4rem, 11vw, 4rem); line-height: 1; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.logo-play { color: #fff; text-shadow: 0 0 30px rgba(255,61,90,.8), 0 0 70px rgba(255,61,90,.4); }
.logo-slash { color: var(--red); }
.logo-domain { display: block; font-size: .38em; color: var(--dim); font-family: 'Space Mono', monospace; letter-spacing: .12em; margin-top: 6px; }
.tag { color: var(--dim); font-size: .95rem; max-width: 320px; }
.home-actions { display: flex; flex-direction: column; gap: 12px; width: min(320px, 80vw); }
.home-stats { display: flex; gap: 10px; padding-bottom: 6px; }
.stat-box { flex: 1; background: rgba(255,255,255,.05); border-radius: 14px; padding: 12px 6px; text-align: center; }
.stat-n { display: block; font-family: 'Space Mono', monospace; font-size: 1.5rem; font-weight: 700; color: var(--yellow); }
.stat-l { display: block; font-size: .6rem; letter-spacing: .1em; color: var(--dim); margin-top: 2px; }

.simple { justify-content: center; gap: 10px; position: relative; }
.title { font-size: 1.6rem; margin: 40px 0 4px; }
.label { color: var(--dim); font-size: .85rem; margin: 10px 0 0; }
.optional { font-weight: 400; opacity: .7; }
.name-input, .code-input {
  background: var(--bg3); border: 2px solid rgba(255,255,255,.1); border-radius: 14px;
  color: var(--fg); font-size: 1.2rem; padding: 14px 16px; outline: none; width: 100%;
}
.code-input { text-transform: uppercase; letter-spacing: .25em; text-align: center; font-family: 'Space Mono', monospace; }
.name-input:focus, .code-input:focus { border-color: var(--red); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; padding: 0; }
.swatch[aria-checked="true"] { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.25); }

/* ── Room shell ──────────────────────────────────────────────── */

.room { padding-left: 0; padding-right: 0; max-width: 640px; }
#room-hud {
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 10px) 14px 10px;
  background: rgba(255,255,255,.03);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.hud-left { display: flex; flex-direction: column; font-family: 'Space Mono', monospace; font-size: .68rem; color: var(--dim); flex-shrink: 0; }
.hud-code { font-size: .9rem; color: var(--fg); font-weight: 700; letter-spacing: .1em; }
.hud-strip { flex: 1; display: flex; gap: 6px; overflow-x: auto; padding: 2px; }
.hud-right { display: flex; gap: 6px; flex-shrink: 0; }
.strip-item { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.05); border-radius: 999px; padding: 4px 10px 4px 4px; flex-shrink: 0; }
.strip-item.you { outline: 2px solid var(--yellow); }
.sinfo { display: flex; flex-direction: column; line-height: 1.1; }
.sname { font-size: .68rem; color: var(--fg); white-space: nowrap; }
.sname.away { opacity: .5; }
.stotal { font-family: 'Space Mono', monospace; font-size: .78rem; font-weight: 700; color: var(--yellow); }

.g-avatar {
  width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; color: #06060a; flex-shrink: 0;
}
.g-avatar.out { opacity: .3; filter: grayscale(1); }
.alive-row { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }

.panel { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; overflow-y: auto; }

/* ── Lobby ───────────────────────────────────────────────────── */

.room-code-label { color: var(--dim); font-size: .75rem; letter-spacing: .15em; margin: 0; }
.room-code-row { display: flex; align-items: center; gap: 10px; }
.room-code-big { font-family: 'Space Mono', monospace; font-size: 2.4rem; font-weight: 700; letter-spacing: .1em; color: var(--yellow); text-shadow: 0 0 24px rgba(255,212,59,.5); }
.lobby-count { color: var(--dim); font-size: .8rem; letter-spacing: .08em; margin: 0; }
.player-list { list-style: none; padding: 0; margin: 0; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 8px; }
.player-row { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.05); border-radius: 14px; padding: 8px 12px; }
.pname { flex: 1; display: flex; flex-direction: column; align-items: flex-start; font-size: .92rem; text-align: left; }
.host-badge { font-size: .6rem; color: var(--yellow); letter-spacing: .1em; }
.away-dot { font-size: .6rem; color: var(--dim); }
.ready-pill { font-size: .62rem; letter-spacing: .08em; padding: 4px 8px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--dim); flex-shrink: 0; }
.ready-pill.on { background: rgba(43,217,122,.18); color: var(--green); }
.btn-kick { background: transparent; border: none; padding: 6px; border-radius: 50%; }
.lobby-status { color: var(--dim); font-size: .88rem; margin: 4px 0; }

/* ── Intro ───────────────────────────────────────────────────── */

.intro-panel { background: radial-gradient(circle at 50% 40%, rgba(61,123,255,.16), transparent 65%); }
.intro-label { color: var(--dim); font-size: .78rem; letter-spacing: .2em; margin: 0; }
.intro-name { font-size: clamp(1.6rem, 8vw, 2.6rem); margin: 0; text-shadow: 0 0 30px rgba(61,123,255,.6); }
.intro-count { font-family: 'Space Mono', monospace; font-size: 4rem; font-weight: 700; color: var(--yellow); animation: pulse .5s ease infinite; }
.intro-sub { color: var(--dim); letter-spacing: .2em; font-size: .8rem; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* ── Playing ─────────────────────────────────────────────────── */

.playing-panel { padding: 10px; }
#game-mount { width: 100%; max-width: 480px; }
.game-banner { font-size: 1.1rem; font-weight: 700; text-align: center; margin: 6px 0 14px; color: var(--dim); }
.game-banner.mine { color: var(--yellow); text-shadow: 0 0 16px rgba(255,212,59,.6); }
.game-banner.danger-flash { color: var(--red); }

.g-shake { animation: g-shake .4s ease; }
@keyframes g-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-8px, 4px); }
  40% { transform: translate(7px, -5px); }
  60% { transform: translate(-6px, 3px); }
  80% { transform: translate(5px, -2px); }
}
.g-particle-layer { position: fixed; inset: 0; pointer-events: none; z-index: 999; }
.g-particle {
  position: absolute; width: 8px; height: 8px; border-radius: 2px;
  animation: g-particle-fly .65s ease-out forwards;
}
@keyframes g-particle-fly {
  0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.3) rotate(180deg); }
}

/* Big Blast */
.bb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.bb-btn { aspect-ratio: 1; border-radius: 24px; border: none; background: linear-gradient(160deg, #24243a, #14141f); box-shadow: inset 0 2px 0 rgba(255,255,255,.08), 0 6px 16px -6px #000; }
.bb-btn .bb-face { font-size: 1.6rem; }
.bb-btn.empty:not(:disabled) { cursor: pointer; }
.bb-btn.empty:not(:disabled):active { transform: scale(.94); }
.bb-btn.pending { background: linear-gradient(160deg, #3a3a5a, #1e1e2e); }
.bb-btn.tension { animation: bb-tension .3s ease infinite; }
@keyframes bb-tension { 0%, 100% { box-shadow: 0 0 0 rgba(255,212,59,.4); } 50% { box-shadow: 0 0 30px 6px rgba(255,212,59,.55); } }
.bb-btn.safe { background: linear-gradient(160deg, #1a3a28, #0d2015); box-shadow: 0 0 24px rgba(43,217,122,.4); }
.bb-btn.danger { background: linear-gradient(160deg, #4a1420, #260a10); box-shadow: 0 0 30px rgba(255,61,90,.6); }
.bb-hint { color: var(--dim); font-size: .78rem; text-align: center; margin: 12px 0 0; }

/* Hot Potato */
.hp-bomb-zone { display: flex; justify-content: center; padding: 30px 0; }
.hp-bomb {
  width: 120px; height: 120px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 3.2rem; background: #24243a;
  box-shadow: 0 0 calc(20px + 60px * var(--intensity, 0)) rgba(255,61,90, calc(.3 + .5 * var(--intensity, 0)));
  transition: box-shadow .1s linear;
}
.hp-bomb.critical { animation: hp-shudder .12s ease infinite; }
@keyframes hp-shudder { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
.hp-bomb.boom { animation: none; transform: scale(1.4); opacity: 0; transition: transform .3s ease, opacity .3s ease; }
.hp-targets { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.hp-target { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.06); border: 2px solid var(--c, #444); border-radius: 999px; padding: 8px 16px 8px 8px; color: var(--fg); }
.hp-target:active { transform: scale(.95); }

/* Color Panic */
.cp-target { font-size: 2rem; font-weight: 700; letter-spacing: .05em; padding: 20px; border-radius: 20px; background: rgba(255,255,255,.05); min-width: 200px; }
.cp-target.flash { animation: cp-flash .1s ease; }
@keyframes cp-flash { from { transform: scale(1.08); } to { transform: scale(1); } }
.cp-bar-track { width: 100%; max-width: 320px; height: 8px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; }
.cp-bar { height: 100%; background: var(--green); transition: width .05s linear; }
.cp-bar.critical { background: var(--red); }
.cp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; max-width: 340px; }
.cp-btn { min-height: 84px; border-radius: 20px; font-size: 1.1rem; font-weight: 700; letter-spacing: .05em; border: 4px solid transparent; }
.cp-btn.picked { border-color: #fff; }
.cp-btn:disabled { opacity: .55; }

/* Rope */
.rope-lane { position: relative; height: 180px; background: rgba(255,255,255,.04); border-radius: 20px; overflow: hidden; margin: 10px 0; }
.rope-bar { position: absolute; left: 0; width: 12%; height: 10px; background: var(--yellow); border-radius: 6px; box-shadow: 0 0 16px rgba(255,212,59,.6); }
.rope-lane.low .rope-bar { bottom: 22px; }
.rope-lane.high .rope-bar { top: 22px; }
.rope-lane.imminent { background: rgba(255,61,90,.12); }
.rope-figure { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 2.4rem; transition: transform .18s ease; }
.rope-figure.jumping { transform: translate(-50%, -50px); }
.rope-figure.brace { animation: rope-brace .15s ease infinite; }
@keyframes rope-brace { 0%, 100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.08); } }
.rope-jump-btn { min-height: 64px; border-radius: 20px; background: var(--yellow); color: #201800; font-weight: 700; font-size: 1.2rem; border: none; width: 100%; max-width: 260px; }
.rope-jump-btn:disabled { opacity: .4; }

/* Wobbly Tower */
.wt-stage { height: 260px; display: flex; align-items: flex-end; justify-content: center; }
.wt-tower { position: relative; width: 90px; height: 100%; transform: rotate(calc(var(--wobble, 0) * 6deg)); transition: transform .2s ease; }
.wt-tower.critical { animation: wt-wobble .3s ease infinite; }
@keyframes wt-wobble { 0%, 100% { transform: rotate(calc(var(--wobble,0) * -8deg)); } 50% { transform: rotate(calc(var(--wobble,0) * 8deg)); } }
.wt-tower.toppled { transform: rotate(70deg) translateX(60px); opacity: .3; transition: transform .5s ease, opacity .5s ease; }
.wt-block {
  position: absolute; left: 50%; width: 84px; height: 20px; margin-left: -42px;
  background: linear-gradient(160deg, #3d7bff, #24243a); border-radius: 6px;
  transform: translateX(var(--off, 0px));
}
.wt-block.dropping { animation: wt-drop .35s cubic-bezier(.3,1.4,.6,1); }
@keyframes wt-drop { from { transform: translate(var(--off,0px), -160px); } to { transform: translate(var(--off,0px), 0); } }
.wt-controls { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; max-width: 300px; }
.wt-controls input[type=range] { width: 100%; }
.wt-drop-btn { min-height: 56px; width: 100%; border-radius: 16px; background: var(--blue); color: #fff; font-weight: 700; border: none; }

/* ── Result ──────────────────────────────────────────────────── */

.result-panel { background: radial-gradient(circle at 50% 30%, rgba(255,212,59,.14), transparent 65%); }
.result-label { color: var(--dim); font-size: .8rem; letter-spacing: .2em; margin: 0; }
.result-game-name { color: var(--dim); font-size: .85rem; margin: 0; }
.result-trophy { font-size: 2.4rem; animation: result-pop .4s cubic-bezier(.3,1.6,.5,1); }
@keyframes result-pop { from { transform: scale(0) rotate(-20deg); } to { transform: scale(1) rotate(0); } }
.result-winner { font-size: clamp(1.4rem, 7vw, 2rem); margin: 0; }
.result-note { color: var(--dim); font-size: .85rem; margin: 0; }
.result-points { font-family: 'Space Mono', monospace; font-size: 1.8rem; font-weight: 700; color: var(--green); animation: result-pop .4s cubic-bezier(.3,1.6,.5,1) .1s backwards; }
.result-points.zero { color: var(--dim); }
.result-scores { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 340px; }
.result-score-row, .over-score-row { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.05); border-radius: 12px; padding: 8px 12px; font-size: .85rem; }
.result-score-row.winner, .over-score-row.winner { background: rgba(255,212,59,.12); outline: 1px solid rgba(255,212,59,.4); }
.result-score-row .n, .over-score-row .n { flex: 1; display: flex; align-items: center; gap: 8px; text-align: left; }
.result-score-row .gain { color: var(--green); font-family: 'Space Mono', monospace; width: 40px; text-align: right; }
.result-score-row .v, .over-score-row .v { font-family: 'Space Mono', monospace; font-weight: 700; }
.result-next { color: var(--dim); font-size: .72rem; letter-spacing: .15em; margin: 0; }

/* ── Match over ──────────────────────────────────────────────── */

.matchover-panel { background: radial-gradient(circle at 50% 25%, rgba(255,61,90,.16), transparent 65%); }
.over-trophy { font-size: 3.4rem; }
.over-trophy.you-won { animation: result-pop .5s cubic-bezier(.3,1.6,.5,1); }
.over-label { color: var(--dim); letter-spacing: .2em; font-size: .8rem; margin: 0; }
.over-winner { font-size: clamp(1.5rem, 8vw, 2.2rem); margin: 0; }
.over-points { color: var(--dim); margin: 0 0 6px; }
.over-scores { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 340px; margin-bottom: 10px; }

/* ── Overlays / banner ───────────────────────────────────────── */

.overlay {
  position: fixed; inset: 0; background: rgba(4,4,8,.86);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  z-index: 50; text-align: center; padding: 24px;
}
.overlay-actions { display: flex; gap: 10px; }
.banner {
  position: fixed; top: calc(var(--safe-t) + 10px); left: 50%; transform: translateX(-50%);
  background: var(--bg3); border: 1px solid rgba(255,255,255,.15); border-radius: 999px;
  padding: 10px 20px; font-size: .85rem; z-index: 60; box-shadow: 0 8px 24px -6px #000;
  max-width: 90vw; text-align: center;
}

/* ── High scores ─────────────────────────────────────────────── */

.lb-label { color: var(--dim); font-size: .72rem; letter-spacing: .15em; margin: 10px 0 4px; text-transform: uppercase; }
.lb-list { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 380px; margin: 0 auto; }
.lb-row {
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 10px;
  background: rgba(255,255,255,.05); border-radius: 12px; padding: 8px 14px; font-size: .9rem;
}
.lb-row.lb-top3 { background: rgba(255,212,59,.12); outline: 1px solid rgba(255,212,59,.35); }
.lb-rank { font-family: 'Space Mono', monospace; color: var(--dim); font-weight: 700; }
.lb-row.lb-top3 .lb-rank { color: var(--yellow); }
.lb-name { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-family: 'Space Mono', monospace; font-weight: 700; color: var(--fg); }
.lb-empty { color: var(--dim); font-size: .85rem; text-align: center; padding: 20px 0; }

.hs-form {
  width: 100%; max-width: 340px; background: rgba(255,212,59,.1); border: 2px solid rgba(255,212,59,.4);
  border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.hs-label { margin: 0; font-weight: 700; color: var(--yellow); text-align: center; font-size: .95rem; text-shadow: 0 0 16px rgba(255,212,59,.5); }
.hs-row { display: flex; gap: 8px; width: 100%; }
.hs-input {
  flex: 1; min-width: 0; background: var(--bg3); border: 2px solid rgba(255,255,255,.15); border-radius: 12px;
  color: var(--fg); font-size: 1rem; padding: 10px 12px; outline: none;
}
.hs-input:focus { border-color: var(--yellow); }
