/* Tandem — co-op puzzle platformer. */
:root {
  --coral: #ff7a6b;
  --teal: #4fd1c5;
  --sun: #ffd166;
  --lav: #a78bfa;
  --ink: #1b1430;
  --ink2: #261c42;
  --text: #f4efff;
  --dim: rgba(244, 239, 255, .62);
  --edge: rgba(255, 255, 255, .14);
  --gold: #ffd166;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--ink);
  color: var(--text); font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent; touch-action: none;
}
#gameCanvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

button { font-family: inherit; }
.muted { color: var(--dim); font-size: 13px; }
.error { color: #ff9a8f; min-height: 1em; font-size: 13px; margin: 6px 0; }
.gold { color: var(--gold); }

/* ── overlay card ─────────────────────────────────────────────────── */
#overlay {
  position: fixed; inset: 0; display: flex; align-items: flex-start; justify-content: center;
  z-index: 10; overflow-y: auto; padding: 22px 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(79, 209, 197, .16), transparent 60%),
              rgba(16, 11, 30, .72);
  touch-action: pan-y;
}
#overlay.in-play { background: rgba(16, 11, 30, .45); }
.card {
  position: relative; width: min(560px, calc(100vw - 32px)); margin: auto 16px;
  background: linear-gradient(180deg, #2b2048, #1f1736); border: 1px solid var(--edge);
  border-radius: 18px; padding: 22px 22px 18px; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.card.wide { width: min(760px, calc(100vw - 32px)); }
.card-help {
  position: absolute; top: 12px; left: 12px; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--edge); background: rgba(255, 255, 255, .06); color: var(--text);
  font-weight: 800; cursor: pointer;
}
.td-title {
  margin: 4px 0 8px; font-size: 44px; letter-spacing: .14em; font-weight: 900;
  background: linear-gradient(90deg, var(--coral), var(--sun), var(--teal));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  display: inline-flex; align-items: center; gap: 8px;
}
.td-title.small { font-size: 26px; }
.td-blob {
  display: inline-block; width: .55em; height: .5em; border-radius: 50% 50% 40% 40%;
  background: var(--coral); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18);
  -webkit-text-fill-color: initial;
}
.td-blob.b { background: var(--teal); transform: translateY(-.32em); margin-left: -.45em; }
.tagline { color: var(--dim); font-size: 14px; margin: 4px 0 14px; line-height: 1.45; }

input[type="text"] {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--edge);
  background: rgba(0, 0, 0, .25); color: var(--text); font-size: 15px; outline: none;
}
input[type="text"]:focus { border-color: var(--teal); }
.primary, .secondary {
  display: block; width: 100%; margin: 8px 0 0; padding: 12px 14px; border-radius: 12px;
  font-size: 16px; font-weight: 800; cursor: pointer; border: 0; color: #1b1430;
}
.primary { background: linear-gradient(90deg, var(--coral), var(--sun)); }
.primary small { display: block; font-weight: 600; font-size: 11px; opacity: .75; }
.secondary { background: rgba(255, 255, 255, .08); color: var(--text); border: 1px solid var(--edge); }
.primary:disabled, .secondary:disabled { opacity: .45; cursor: default; }
.link-btn {
  background: none; border: 0; color: var(--teal); cursor: pointer; font-size: 13px;
  margin: 10px 6px 0; padding: 4px;
}
.back-link { display: block; margin-top: 12px; color: var(--dim); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--text); }
.home-buttons { margin-top: 8px; }
.row-2 { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row-2 > * { margin: 0 !important; }
.row-2 .secondary { flex: 1; }
.row-2 input { flex: 0 0 110px; text-transform: uppercase; text-align: center; letter-spacing: .2em; }
.row-2 .check { flex: 0 0 auto; }
.check { font-size: 13px; color: var(--dim); white-space: nowrap; display: flex; gap: 4px; align-items: center; }

.rooms-box { margin-top: 14px; text-align: left; border: 1px solid var(--edge); border-radius: 12px; padding: 8px 10px; }
.rooms-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--dim); }
.rooms-head .link-btn { margin: 0; }
.rooms-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-height: 170px; overflow-y: auto; }
.room-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 9px;
  background: rgba(255, 255, 255, .05); cursor: pointer; border: 1px solid transparent; font-size: 13px;
}
.room-row:hover { border-color: var(--teal); }
.room-row .code { font-weight: 900; letter-spacing: .12em; color: var(--sun); min-width: 54px; }
.room-row .who { flex: 1; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-row .cnt { font-weight: 700; }

/* ── lobby ───────────────────────────────────────────────────────── */
.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.room-badge {
  font-size: 12px; color: var(--dim); border: 1px dashed var(--edge); border-radius: 10px;
  padding: 6px 10px; cursor: pointer; text-align: right;
}
.room-badge b { color: var(--sun); letter-spacing: .18em; font-size: 16px; }
.player-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0 2px; }
.p-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--edge); font-size: 13px;
}
.p-chip .dot { width: 12px; height: 12px; border-radius: 50%; }
.p-chip .tag { color: var(--dim); font-size: 11px; }
.seat-note { margin: 4px 0 8px; }
.worlds { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 6px 0; }
.world-tab {
  padding: 6px 10px; border-radius: 9px; border: 1px solid var(--edge); font-size: 12px;
  background: rgba(255, 255, 255, .04); color: var(--text); cursor: pointer;
}
.world-tab.on { background: rgba(79, 209, 197, .22); border-color: var(--teal); }
.world-tab.locked { opacity: .45; }
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.lv-tile {
  position: relative; padding: 9px 6px 8px; border-radius: 11px; border: 1px solid var(--edge);
  background: rgba(255, 255, 255, .05); color: var(--text); cursor: pointer; text-align: center;
  font-size: 12px; min-height: 62px;
}
.lv-tile b { display: block; font-size: 15px; }
.lv-tile .nm { display: block; color: var(--dim); font-size: 11px; margin-top: 2px; }
.lv-tile.on { border-color: var(--sun); box-shadow: 0 0 0 2px rgba(255, 209, 102, .35) inset; }
.lv-tile.cleared::after { content: "✓"; position: absolute; top: 4px; right: 7px; color: var(--teal); font-weight: 900; }
.lv-tile.locked { opacity: .38; cursor: not-allowed; }
.lv-tile.locked::after { content: "🔒"; position: absolute; top: 3px; right: 5px; font-size: 11px; }
.lv-tile.nohost { cursor: default; }
.level-info { font-size: 13px; color: var(--dim); min-height: 2.6em; margin: 4px 0; }
.level-info b { color: var(--text); }

.leaderboard { margin-top: 12px; text-align: left; }
.leaderboard, .lb-panel, .lb-card {
  --lb-accent: #ffd166;
  --lb-text: #f4efff;
  --lb-dim: rgba(244, 239, 255, .55);
  --lb-edge: rgba(255, 255, 255, .14);
  --lb-panel: rgba(31, 23, 54, .85);
}
.lb-card { max-width: min(640px, 94vw) !important; width: min(640px, 94vw) !important; }

.load-bar { height: 10px; border-radius: 6px; background: rgba(0, 0, 0, .3); overflow: hidden; margin: 12px 0 6px; }
#loadBar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--coral), var(--sun), var(--teal)); }
.count-level { color: var(--dim); font-size: 15px; }
.countdown { font-size: 88px; font-weight: 900; color: var(--sun); text-shadow: 0 6px 30px rgba(255, 209, 102, .4); }
.result-time { font-size: 40px; font-weight: 900; color: var(--sun); margin: 2px 0; }
#resultTable, #resultAwards { margin-top: 10px; }
#resultTable { overflow-x: auto; -webkit-overflow-scrolling: touch; }
body.solo-room #lobbyChat { display: none; }

/* ── HUD ─────────────────────────────────────────────────────────── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud-top {
  position: absolute; left: calc(10px + env(safe-area-inset-left)); top: calc(8px + env(safe-area-inset-top));
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; max-width: calc(100vw - 190px);
}
.hud-level, .hud-timer, .hud-inside {
  background: rgba(16, 11, 30, .72); border: 1px solid var(--edge); border-radius: 10px;
  padding: 5px 10px; font-size: 13px;
}
.hud-level b { color: var(--sun); }
.hud-timer { font-variant-numeric: tabular-nums; font-weight: 800; }
.hud-inside:empty { display: none; }
.hud-right {
  position: absolute; right: calc(8px + env(safe-area-inset-right)); top: calc(8px + env(safe-area-inset-top));
  display: flex; gap: 6px; pointer-events: auto; align-items: flex-start;
}
.hud-btn, .hud-gear summary {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--edge);
  background: rgba(16, 11, 30, .85); color: var(--text); font-size: 16px; font-weight: 800;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.hud-gear { position: relative; }
.hud-gear summary { list-style: none; }
.hud-gear summary::-webkit-details-marker { display: none; }
/* site_audio.css pins #hudAudio fixed bottom-centre; inside the gear it drops
   below the toggle instead, so restate ALL four placement properties. */
#hudAudio {
  position: absolute; top: 42px; right: 0; left: auto; bottom: auto; transform: none;
  background: rgba(16, 11, 30, .95); border-radius: 12px; padding: 6px 8px;
  width: max-content; max-width: 86vw;
}
/* web/style.css pins .volume-slider position:fixed top:12px — undo it here
   or every slider lands in the corner of the screen (CLAUDE.md item 5). */
.volume-slider { position: static !important; top: auto !important; }
body:not(.is-host) .host-only { display: none !important; }

.hero-strip {
  position: absolute; left: 50%; transform: translateX(-50%); top: calc(52px + env(safe-area-inset-top));
  display: flex; gap: 6px; pointer-events: auto;
}
.hero-strip:empty { display: none; }
.hero-pill {
  display: flex; align-items: center; gap: 6px; padding: 4px 9px 4px 5px; border-radius: 999px;
  background: rgba(16, 11, 30, .8); border: 1px solid var(--edge); font-size: 12px; cursor: pointer;
  color: var(--text);
}
.hero-pill .dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .3); }
.hero-pill.on { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 209, 102, .3); }
.hero-pill.in { opacity: .55; }
.hero-pill .nm { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hud-hint {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom));
  max-width: min(640px, 92vw); text-align: center; font-size: 14px; line-height: 1.4;
  background: rgba(255, 250, 235, .95); color: #3a2a12; padding: 8px 14px; border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35); transition: opacity .25s;
}
.hud-hint:empty { opacity: 0; }
.hud-toast { position: absolute; left: 50%; top: 96px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast {
  background: rgba(16, 11, 30, .86); border: 1px solid var(--edge); border-radius: 10px;
  padding: 6px 12px; font-size: 13px; animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.hud-center { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); text-align: center; }
.center-note {
  font-size: 30px; font-weight: 900; color: var(--sun); text-shadow: 0 4px 24px rgba(0, 0, 0, .55);
  background: rgba(16, 11, 30, .55); padding: 10px 22px; border-radius: 16px;
}
.spectator-flag {
  position: fixed; top: calc(52px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 9; padding: 4px 12px; background: rgba(16, 11, 30, .86); border: 1px solid var(--edge);
  border-radius: 999px; font-size: 12px; letter-spacing: .08em;
}
.rotate-hint { display: none; }

/* touch controls: shown on coarse pointers, or once a finger touches the page */
#touchLayer { display: none; }
body.touch #touchLayer { display: block; }
.pad-left, .pad-right {
  position: absolute; bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 10px;
  align-items: flex-end; pointer-events: auto;
}
.pad-left { left: calc(12px + env(safe-area-inset-left)); }
.pad-right { right: calc(12px + env(safe-area-inset-right)); }
.tbtn {
  width: 76px; height: 76px; border-radius: 22px; border: 2px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .13); color: var(--text); font-size: 28px; font-weight: 900;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.tbtn small { font-size: 9px; letter-spacing: .1em; opacity: .8; }
.tbtn.jump { width: 88px; height: 88px; background: rgba(255, 122, 107, .32); }
.tbtn.act { background: rgba(79, 209, 197, .28); }
.tbtn.small { width: 62px; height: 62px; font-size: 22px; border-radius: 18px; }
.tbtn.swap { background: rgba(255, 209, 102, .26); }
.tbtn.held { filter: brightness(1.7); transform: scale(.94); }
body:not(.multi-hero) .tbtn.swap { display: none; }
body.touch .hud-hint { bottom: calc(112px + env(safe-area-inset-bottom)); }

@media (max-width: 640px) {
  .card { padding: 18px 14px 14px; }
  #lobbyAudio { margin-top: 30px; }
  .td-title { font-size: 34px; }
  .level-grid { grid-template-columns: repeat(2, 1fr); }
  .hud-top { max-width: calc(100vw - 176px); gap: 6px; }
  .hud-level span { display: none; }
  .hero-strip { top: calc(48px + env(safe-area-inset-top)); }
  .hero-pill .nm { max-width: 70px; }
  .tbtn { width: 66px; height: 66px; }
  .tbtn.jump { width: 78px; height: 78px; }
  .tbtn.small { width: 56px; height: 56px; }
  .hud-hint { font-size: 13px; }
}
@media (orientation: portrait) and (max-width: 640px) {
  body.touch.playing .rotate-hint {
    display: block; position: absolute; top: calc(92px + env(safe-area-inset-top)); left: 50%;
    transform: translateX(-50%); font-size: 11px; color: var(--dim); white-space: nowrap;
    background: rgba(16, 11, 30, .7); padding: 3px 9px; border-radius: 999px;
    animation: fade-out 1s 6s forwards;
  }
}
@keyframes fade-out { to { opacity: 0; visibility: hidden; } }

/* ── how to play ─────────────────────────────────────────────────── */
.help-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 6, 20, .72);
  display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto;
}
.help-card {
  position: relative; width: min(620px, 100%); background: #251b40; border: 1px solid var(--edge);
  border-radius: 18px; padding: 20px; text-align: left; max-height: calc(100vh - 32px); overflow-y: auto;
}
.help-card h2 { margin: 0 0 6px; }
.help-td { color: var(--sun); }
.help-x { position: absolute; top: 10px; right: 10px; background: none; border: 0; color: var(--text); font-size: 18px; cursor: pointer; }
.help-lead { color: var(--dim); margin: 0 0 10px; line-height: 1.45; }
.help-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.help-tab { flex: 1; padding: 8px; border-radius: 10px; border: 1px solid var(--edge); background: rgba(255, 255, 255, .04); color: var(--text); cursor: pointer; }
.help-tab.on { background: rgba(79, 209, 197, .22); border-color: var(--teal); }
.help-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.help-item { background: rgba(255, 255, 255, .05); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.help-ico { font-size: 22px; }
.help-item small { color: var(--dim); line-height: 1.35; }
.kb { color: var(--sun); font-weight: 700; }
.tc { display: none; color: var(--teal); font-weight: 700; }
body.touch .kb { display: none; }
body.touch .tc { display: inline; }
.help-note { color: var(--dim); font-size: 13px; }
.help-rules { margin: 0; padding-left: 18px; line-height: 1.5; font-size: 14px; }
.help-rules li { margin-bottom: 6px; }
.help-again { color: var(--dim); font-size: 12px; margin: 12px 0 0; }
@media (max-width: 520px) { .help-grid { grid-template-columns: 1fr; } }
