/* The Crypto Rabbit Hole TCG — neon/cyber UI. Landscape first; works on phones held sideways. */
:root {
  --bg: #05030c;
  --panel: rgba(12, 8, 26, 0.86);
  --panel-solid: #0d0920;
  --line: rgba(140, 120, 255, 0.28);
  --text: #eef0ff;
  --muted: #9a9cc4;
  --cyan: #38f3ff;
  --magenta: #ff4fd8;
  --gold: #ffc23d;
  --green: #22ff7a;
  --blue: #2f86ff;
  --purple: #b04dff;
  --red: #ff4060;
  --me: var(--cyan);
  --opp: var(--magenta);
  --card-w: clamp(64px, 7.4vw, 118px);
  --hud-h: 58px;
  --font: 'Outfit', system-ui, sans-serif;
  --display: 'Russo One', 'Arial Black', sans-serif;
  --mono: 'Share Tech Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; overscroll-behavior: none; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

/* ------------------------------------------------------------ buttons */
.btn {
  position: relative; cursor: pointer; border: 1px solid var(--line); background: linear-gradient(180deg, rgba(40, 30, 80, 0.85), rgba(16, 10, 34, 0.9));
  border-radius: 12px; padding: 10px 18px; font-weight: 700; letter-spacing: 0.02em; color: var(--text);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04) inset, 0 6px 18px rgba(0, 0, 0, 0.4); transition: transform 0.12s, box-shadow 0.2s, border-color 0.2s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--cyan); box-shadow: 0 0 18px rgba(56, 243, 255, 0.35), 0 6px 18px rgba(0, 0, 0, 0.4); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn.primary { border-color: rgba(56, 243, 255, 0.7); background: linear-gradient(180deg, #1ad6ff, #6a3cff); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.btn.primary:hover { box-shadow: 0 0 28px rgba(56, 243, 255, 0.6); }
.btn.danger { border-color: rgba(255, 64, 96, 0.6); background: linear-gradient(180deg, rgba(120, 20, 40, 0.9), rgba(50, 8, 20, 0.95)); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.big { padding: 14px 26px; font-size: 1.05rem; }
.btn.warn { border-color: rgba(255, 194, 61, 0.8); background: linear-gradient(180deg, #ffb52e, #e0561f); color: #1a0d00; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 18px; }
.icon-btn:hover { border-color: var(--cyan); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.03) inset; }

/* ------------------------------------------------------------ screens */
.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }
.title-inner { position: relative; height: 100%; display: flex; align-items: center; justify-content: center; gap: clamp(10px, 4vw, 60px); padding: 64px 24px 44px; }
.title-main { display: flex; flex-direction: column; align-items: center; gap: clamp(12px, 3vh, 30px); }
.logo { text-align: center; }
.logo-img { display: block; width: min(640px, 54vw); height: auto; filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 14px rgba(176, 77, 255, 0.75)) drop-shadow(0 10px 30px rgba(0, 0, 0, 0.6)); animation: logo-in 1.1s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes logo-in { from { opacity: 0; transform: translateY(-18px) scale(0.92); } }
.logo-tcg { display: block; margin-top: 6px; font-family: var(--mono); letter-spacing: 0.55em; color: var(--cyan); font-size: clamp(0.72rem, 1.3vw, 1rem); text-transform: uppercase; text-shadow: 0 0 14px rgba(56, 243, 255, 0.6); }
.menu { display: grid; gap: 10px; width: min(400px, 84vw); animation: menu-in 0.7s 0.25s both; }
@keyframes menu-in { from { opacity: 0; transform: translateY(16px); } }
.menu .btn.big { display: flex; align-items: center; gap: 12px; text-align: left; }
.menu .btn.big small { margin-left: auto; font-weight: 500; font-size: 0.78rem; color: var(--muted); }
.menu .btn.primary.big small { color: rgba(255, 255, 255, 0.8); }
.menu .mi { font-size: 1.25rem; width: 1.6em; text-align: center; }
.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn.small { padding: 6px 12px; font-size: 0.82rem; font-weight: 600; }
.menu .btn.ghost.small { color: var(--muted); justify-self: center; }
.online-count { font-family: var(--mono); }
.title-host { position: absolute; right: clamp(8px, 3vw, 60px); bottom: 0; width: clamp(200px, 27vw, 400px); animation: host-in 0.9s 0.4s cubic-bezier(.2, 1.2, .4, 1) both; pointer-events: none; }
.title-host::after { content: ''; position: absolute; left: -20%; right: -20%; bottom: -40px; height: 140px; z-index: -1;
  background: radial-gradient(ellipse at 50% 70%, rgba(255, 79, 216, 0.45), rgba(106, 60, 255, 0.25) 45%, transparent 72%); filter: blur(6px); }
@keyframes host-in { from { opacity: 0; transform: translateY(40px); } }
.host-art { display: block; width: 100%; height: auto; transform-origin: 50% 100%; animation: host-sway 6s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(176, 77, 255, 0.4));
  -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent 100%); mask-image: linear-gradient(to bottom, #000 72%, transparent 100%); }
@keyframes host-sway { 50% { transform: rotate(-1.2deg) scale(1.01); } }
.host-bubble { position: absolute; bottom: 100%; right: 22%; margin-bottom: 4px; width: max-content; max-width: 240px; padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: rgba(255, 255, 255, 0.95); color: #1b0d38; font-weight: 600; font-size: 0.92rem; box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45); transition: opacity 0.3s, transform 0.3s; }
.host-bubble.swap { opacity: 0; transform: translateY(6px); }
.title-foot { position: absolute; bottom: 12px; left: 0; right: 0; margin: 0; font-family: var(--mono); color: var(--muted); letter-spacing: 0.2em; font-size: 0.78rem; text-align: center; }
.profile-chip { position: absolute; top: 14px; right: 16px; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-align: left; }
.profile-chip:hover { border-color: var(--cyan); }
.chip-text b { display: block; font-size: 0.9rem; }
.chip-text small { color: var(--muted); font-size: 0.72rem; }
.avatar.sm { width: 34px; height: 34px; border-width: 2px; }
.avatar.xl { width: 84px; height: 84px; border-width: 3px; }
.avatar[style*="--frame"], .pfp-opt { border-color: var(--frame); box-shadow: 0 0 14px var(--frame); }
.avatar.card-pfp, .pfp-opt.card-pfp { background-size: 210%; background-position: 50% 30%; }
@media (max-width: 760px), (max-height: 520px) { .title-host { display: none; } }
@media (max-height: 520px) {
  .title-inner { padding: 50px 16px 28px; }
  .logo-img { width: min(380px, 50vw); }
  .menu { gap: 6px; }
  .menu .btn.big { padding: 8px 16px; font-size: 0.9rem; }
  .menu .btn { padding: 7px 12px; font-size: 0.85rem; }
  .title-foot { display: none; }
}

/* setup */
#setup { z-index: 21; display: none; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 100%, rgba(106, 60, 255, 0.4), rgba(5, 3, 12, 0.92)); }
#setup.active { display: flex; }
.setup-panel { position: relative; width: min(980px, 94vw); max-height: 94vh; overflow: auto; padding: 22px 26px; }
.setup-panel h2 { margin: 4px 0 14px; text-align: center; font-family: var(--display); font-weight: 400; letter-spacing: 0.05em; }
.setup-panel .back { position: absolute; left: 12px; top: 12px; }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.setup-col h3 { margin: 0 0 8px; font-size: 0.9rem; color: var(--muted); letter-spacing: 0.15em; text-transform: uppercase; }
.deck-pick { display: grid; gap: 8px; }
.deck-opt { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); cursor: pointer; text-align: left; }
.deck-opt img { width: 56px; border-radius: 6px; }
.deck-opt b { display: block; font-size: 1rem; }
.deck-opt small { color: var(--muted); font-size: 0.8rem; line-height: 1.25; display: block; }
.deck-opt.on { border-color: var(--cyan); box-shadow: 0 0 18px rgba(56, 243, 255, 0.3); background: rgba(56, 243, 255, 0.08); }
.setup-options { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.opt select, .opt input { accent-color: var(--cyan); }
select { background: #140e2c; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; }
.start { display: block; margin: 0 auto; }
.setup-vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: start; }
.vs-side h3 { margin: 0 0 8px; font-size: 0.85rem; color: var(--muted); letter-spacing: 0.15em; text-transform: uppercase; }
.vs-mid { align-self: center; font-family: var(--display); font-size: 2rem; color: var(--magenta); text-shadow: 0 0 18px rgba(255, 79, 216, 0.6); }
.opp-card { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; padding: 6px 10px; border-radius: 12px; background: rgba(255, 79, 216, 0.08); border: 1px solid rgba(255, 79, 216, 0.35); }
.opp-card[hidden] { display: none; }
.opp-card img { width: 64px; height: 64px; object-fit: cover; object-position: top; border-radius: 10px; }
.opp-card small { display: block; color: var(--muted); font-size: 0.78rem; }
.deck-opt { cursor: default; }
.locked-decks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.deck-opt.locked { opacity: 0.5; filter: grayscale(0.7); }
@media (max-width: 760px), (max-height: 520px) { .setup-vs { grid-template-columns: 1fr 1fr; } .vs-mid { display: none; } .locked-decks { display: none; } .setup-panel { padding: 14px 16px; } }

/* online lobby, leaderboards, profile */
#online, #boards { z-index: 21; display: none; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 100%, rgba(106, 60, 255, 0.4), rgba(5, 3, 12, 0.94)); }
#online.active, #boards.active { display: flex; }
.lobby-panel, .boards-panel { position: relative; width: min(620px, 94vw); max-height: 94vh; overflow: auto; padding: 22px 26px; touch-action: pan-y; }
.lobby-panel h2, .boards-panel h2 { margin: 4px 0 6px; text-align: center; font-family: var(--display); font-weight: 400; letter-spacing: 0.05em; }
.lobby-panel .back, .boards-panel .back { position: absolute; left: 12px; top: 12px; }
.net-status { text-align: center; margin: 0 0 14px; font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.net-status.online { color: var(--green); } .net-status.offline { color: var(--red); }
.lobby-body { display: grid; gap: 14px; }
.lobby-name { display: flex; align-items: center; gap: 10px; }
.lobby-name > span { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.text-in { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.35); color: var(--text); font: inherit; user-select: text; -webkit-user-select: text; }
.text-in:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 12px rgba(56, 243, 255, 0.3); }
.code-in { text-transform: uppercase; font-family: var(--mono); letter-spacing: 0.3em; text-align: center; max-width: 170px; }
.btn.quick { display: grid; gap: 2px; text-align: center; padding: 18px; font-size: 1.25rem; }
.btn.quick small { font-size: 0.8rem; font-weight: 500; opacity: 0.85; }
.lobby-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.join { display: flex; gap: 8px; }
.lobby-error { color: var(--red); text-align: center; margin: 0; }
.lobby-notes { margin: 0; padding-left: 18px; color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.lobby-wait, .lobby-soon { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 10px 0; }
.lobby-wait h3, .lobby-soon h3 { margin: 6px 0 0; }
.lobby-wait p, .lobby-soon p { margin: 0; color: var(--muted); max-width: 420px; }
.room-code { font-family: var(--mono); font-size: 2.6rem; letter-spacing: 0.35em; padding: 8px 18px 8px 28px; border-radius: 14px; border: 1px dashed var(--cyan); color: var(--cyan); cursor: copy; text-shadow: 0 0 14px rgba(56, 243, 255, 0.6); }
.board-tabs, .board-period { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 10px; }
.tab { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); cursor: pointer; font-size: 0.85rem; }
.tab.small { font-size: 0.78rem; padding: 4px 10px; }
.tab.on { border-color: var(--cyan); background: rgba(56, 243, 255, 0.14); color: #fff; }
.board-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.board-list li { display: grid; grid-template-columns: 46px 34px 1fr auto auto; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid transparent; }
.board-list li.me { border-color: var(--cyan); background: rgba(56, 243, 255, 0.08); }
.board-list li.sep { margin-top: 8px; grid-template-columns: 46px 1fr auto; }
.board-list li.empty { display: grid; justify-items: center; grid-template-columns: 1fr; color: var(--muted); padding: 22px; }
.board-list .rank { font-family: var(--mono); text-align: center; }
.board-list .val { font-family: var(--display); color: var(--gold); }
.board-list small { color: var(--muted); font-size: 0.75rem; }
.board-list li.rank-1 { background: linear-gradient(90deg, rgba(255, 194, 61, 0.16), rgba(255, 255, 255, 0.03)); }
.board-foot { text-align: center; color: var(--muted); font-size: 0.8rem; display: grid; gap: 8px; justify-items: center; }
#profile { z-index: 45; }
.profile-box { position: relative; width: min(560px, 94vw); max-height: 92vh; overflow: auto; padding: 22px 24px; display: grid; gap: 12px; touch-action: pan-y; }
.profile-box h3 { margin: 6px 0 0; font-size: 0.85rem; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; }
.close-x { position: absolute; top: 8px; right: 8px; padding: 6px 10px; }
.prof-head { display: flex; align-items: center; gap: 16px; }
.prof-head h2 { margin: 0 0 4px; font-family: var(--display); font-weight: 400; }
.access-badge { font-size: 0.75rem; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.access-badge.account { color: var(--cyan); border-color: rgba(56, 243, 255, 0.5); }
.access-badge.wallet { color: var(--gold); border-color: rgba(255, 194, 61, 0.6); }
.muted { color: var(--muted); margin: 0; }
.pfp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.pfp-opt { aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--frame, var(--line)); background-size: cover; background-position: center; cursor: pointer; opacity: 0.7; box-shadow: none; }
.pfp-opt.on { opacity: 1; box-shadow: 0 0 16px var(--frame); transform: scale(1.06); }
.frame-row { display: flex; gap: 8px; }
.frame-opt { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--frame); background: transparent; cursor: pointer; }
.frame-opt.on { box-shadow: 0 0 12px var(--frame); background: var(--frame); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat-grid div { display: grid; text-align: center; padding: 8px 4px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); }
.stat-grid b { font-family: var(--display); font-size: 1.2rem; color: var(--cyan); }
.stat-grid small { color: var(--muted); font-size: 0.72rem; }
.recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 0.88rem; }
.recent li { display: flex; gap: 6px; align-items: baseline; }
.recent li small { margin-left: auto; color: var(--muted); }
.recent li.won b { color: var(--green); } .recent li.lost b { color: var(--red); }
.signin { display: grid; gap: 8px; }
.signin p { margin: 0; }
.signin-more { display: flex; gap: 8px; flex-wrap: wrap; }
.muted.small { font-size: 0.78rem; }
.perks ul { list-style: none; margin: 6px 0 10px; padding: 0; display: grid; gap: 6px; }
.perks li { display: grid; gap: 2px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); opacity: 0.6; }
.perks li.on { opacity: 1; border-color: rgba(56, 243, 255, 0.45); }
.perks li span { color: var(--muted); font-size: 0.84rem; }
.prof-foot { display: flex; justify-content: space-between; }
.danger-text { color: var(--red); }

/* online table extras */
.turn-timer { position: absolute; left: 50%; top: calc(var(--hud-h) + 4px); transform: translateX(-50%); padding: 3px 12px; border-radius: 999px; font-family: var(--mono); font-size: 0.85rem; background: var(--panel); border: 1px solid var(--line); color: var(--muted); pointer-events: none; }
#game > .turn-timer { pointer-events: none; }
.turn-timer.mine { color: var(--cyan); border-color: rgba(56, 243, 255, 0.5); }
.turn-timer.low { color: var(--red); border-color: var(--red); }
.turn-timer[hidden], .emotes[hidden] { display: none; }
.emotes { position: absolute; right: 14px; bottom: calc(14px + 2 * 46px + 60px); display: flex; flex-direction: row-reverse; align-items: flex-end; gap: 8px; }
.emote-tray { display: none; flex-wrap: wrap; gap: 6px; max-width: 320px; padding: 8px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.emotes.open .emote-tray { display: flex; }
.emote-btn { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); cursor: pointer; font-size: 0.85rem; }
.emote-btn:hover { border-color: var(--cyan); }
.emote-pop { position: absolute; z-index: 30; padding: 10px 16px; border-radius: 18px; background: #fff; color: #1b0d38; font-weight: 700; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5); pointer-events: none; animation: emote 2.6s ease both; }
#game > .emote-pop { pointer-events: none; }
.emote-pop.opp { top: calc(var(--hud-h) + 16px); left: 70px; border-top-left-radius: 4px; }
.emote-pop.me { bottom: calc(14px + 3 * 46px + 30px); left: 70px; border-bottom-left-radius: 4px; }
@keyframes emote { 0% { opacity: 0; transform: scale(0.6); } 10% { opacity: 1; transform: scale(1.05); } 16% { transform: scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(-8px); } }
@media (max-height: 520px) { .emotes { bottom: calc(10px + 2 * 36px + 46px); right: 8px; } .lobby-panel, .boards-panel { padding: 12px 16px; } .room-code { font-size: 1.8rem; } .stat-grid { grid-template-columns: repeat(4, 1fr); } }


/* ------------------------------------------------------------ HUD */
#game { pointer-events: none; z-index: 5; }
#game > * { pointer-events: auto; }
.hud-top { position: absolute; top: 0; left: 0; right: 0; height: var(--hud-h); display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: linear-gradient(180deg, rgba(5, 3, 12, 0.92), rgba(5, 3, 12, 0)); pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.seat { display: flex; align-items: center; gap: 8px; min-width: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-size: 0.9rem; flex: none;
  background: radial-gradient(circle at 35% 30%, #3a2a70, #120a28); border: 2px solid var(--opp); box-shadow: 0 0 14px var(--opp); background-size: cover; background-position: center; }
.avatar.me { border-color: var(--me); box-shadow: 0 0 14px var(--me); }
.avatar.active { animation: pulse-ring 1.4s ease-in-out infinite; }
@keyframes pulse-ring { 50% { box-shadow: 0 0 26px currentColor, 0 0 0 4px rgba(255, 255, 255, 0.12); } }
.seat-name { font-weight: 800; font-size: 0.95rem; white-space: nowrap; }
.seat-stats { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); display: flex; gap: 10px; white-space: nowrap; }
.seat-stats .rekt { color: var(--red); font-weight: 700; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.4; } }
.lanes-done { color: var(--gold); }
.steps { flex: 1; display: flex; justify-content: center; gap: 4px; list-style: none; margin: 0; padding: 0; min-width: 0; }
.steps li { font-family: var(--mono); font-size: 0.72rem; padding: 5px 9px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.08); color: var(--muted); white-space: nowrap; background: rgba(10, 6, 24, 0.6); }
.steps li.done { opacity: 0.45; }
.steps li.now { color: #001018; background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 16px rgba(56, 243, 255, 0.6); font-weight: 700; }
.steps.opp li.now { background: var(--magenta); border-color: var(--magenta); box-shadow: 0 0 16px rgba(255, 79, 216, 0.6); color: #19001a; }
.hud-right { display: flex; gap: 6px; }
.seat-me { position: absolute; left: 12px; bottom: calc(var(--card-w) * 1.05 + 18px); }
.opp-hand { position: absolute; top: calc(var(--hud-h) - 4px); left: 14px; display: flex; pointer-events: none; }
.opp-hand .back { width: calc(var(--card-w) * 0.3); aspect-ratio: 1890/2640; margin: 0 -6px; border-radius: 5px; background: url(../assets/cards/sm/back.webp) center/cover; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6); transform: rotate(180deg); }
.opp-hand .count { margin-left: 14px; align-self: center; font-family: var(--mono); color: var(--muted); font-size: 0.8rem; }

/* centre guidance: one line on the board's centre rail, plus a Skip button when there's nothing to play */
.guide { position: absolute; left: 50%; top: var(--guide-y, 45%); transform: translate(-50%, -50%); z-index: 6; pointer-events: none;
  display: flex; align-items: center; gap: 10px; max-width: min(820px, 80vw); opacity: 0; transition: opacity 0.3s; }
.guide.show { opacity: 1; }
.g-line { font-weight: 600; font-size: clamp(0.8rem, 1.3vw, 1rem); letter-spacing: 0.01em; padding: 6px 18px; border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: linear-gradient(180deg, rgba(14, 10, 30, 0.88), rgba(6, 4, 16, 0.88)); border: 1px solid rgba(255, 255, 255, 0.1); color: #e7e9ff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }
.g-line.mine { border-color: rgba(56, 243, 255, 0.55); box-shadow: 0 0 22px rgba(56, 243, 255, 0.18), 0 8px 24px rgba(0, 0, 0, 0.45); }
.g-line.good { border-color: rgba(34, 255, 122, 0.5); }
.g-line.bad { border-color: rgba(255, 64, 96, 0.55); color: #ffdbe1; }
.g-line.muted { color: #c6c8e6; }
.g-line.flash { animation: gline 0.35s ease-out; }
#game > .guide { pointer-events: none; }
@keyframes gline { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.g-btns { display: flex; gap: 8px; pointer-events: auto; }
.g-btns:empty { display: none; }
.g-btns .btn { padding: 6px 16px; border-radius: 999px; font-size: 0.9rem; }
/* spotlight: the edges of the screen darken while an opponent's card is about to resolve */
.spotlight { position: absolute; inset: 0; z-index: 5; pointer-events: none; opacity: 0; transition: opacity 0.35s;
  background: radial-gradient(ellipse at 50% 35%, transparent 25%, rgba(0, 0, 0, 0.55) 70%, rgba(0, 0, 0, 0.8) 100%); }
#game > .spotlight { pointer-events: none; }
#game > .spotlight.open { opacity: 1; pointer-events: auto; cursor: pointer; }
/* Sandy: the CPU opponent's portrait and speech bubble, in the space left of the table */
.sandy { position: absolute; left: 14px; top: calc(var(--hud-h) + 26px); z-index: 6; display: none; pointer-events: none; }
.sandy.show { display: block; }
.sandy-card { position: relative; width: clamp(110px, 13vw, 190px); }
.sandy-art { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; border-radius: 18px;
  background: radial-gradient(circle at 50% 30%, rgba(255, 79, 216, 0.28), rgba(12, 8, 26, 0.9) 70%); border: 1px solid rgba(255, 79, 216, 0.45);
  box-shadow: 0 0 26px rgba(255, 79, 216, 0.25), 0 12px 30px rgba(0, 0, 0, 0.5); }
.sandy-art.pop { animation: sandypop 0.35s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes sandypop { from { transform: scale(0.94) translateY(4px); } to { transform: none; } }
.sandy-name { text-align: center; font-family: var(--display); font-size: clamp(0.8rem, 1.1vw, 1rem); color: #ffd2f5; margin-top: 4px; letter-spacing: 0.04em; }
.sandy-name small { display: block; font-family: var(--mono); font-size: 0.62rem; color: var(--muted); letter-spacing: 0.08em; }
.sandy-bubble { position: absolute; left: calc(100% + 10px); top: 18px; width: max-content; max-width: clamp(160px, 22vw, 300px); padding: 10px 14px; border-radius: 16px 16px 16px 4px;
  background: #fff6fd; color: #2a0f2a; font-weight: 700; font-size: clamp(0.78rem, 1.05vw, 0.95rem); line-height: 1.3; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  opacity: 0; transform: translateX(-6px) scale(0.96); transition: opacity 0.25s, transform 0.25s; }
.sandy-bubble.show { opacity: 1; transform: none; }
#game.with-sandy .opp-hand { left: calc(14px + clamp(110px, 13vw, 190px) + 12px); top: calc(var(--hud-h) + 4px); }
@media (max-height: 520px) {
  .sandy { top: calc(var(--hud-h) + 4px); left: 8px; }
  .sandy-card { width: 82px; }
  .sandy-name small { display: none; }
  .sandy-bubble { top: 6px; font-size: 0.7rem; max-width: 170px; padding: 6px 10px; }
}
/* the auto-skip toggle (unlocks after 10 games) */
.autoskip { position: absolute; right: 14px; bottom: calc(14px + 2 * 46px + 16px); padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); font-size: 0.78rem; font-weight: 700; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.autoskip.on { color: #001018; background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 16px rgba(56, 243, 255, 0.5); }
.autoskip.locked { cursor: help; opacity: 0.75; }
@media (max-height: 520px) { .autoskip { bottom: calc(10px + 2 * 36px + 12px); font-size: 0.68rem; padding: 4px 10px; } }
.prompt { position: absolute; top: calc(var(--hud-h) + 22px); left: 50%; transform: translateX(-50%); max-width: min(760px, 70vw); text-align: center; pointer-events: none;
  padding: 8px 18px; border-radius: 12px; background: rgba(5, 3, 12, 0.72); border: 1px solid var(--line); font-weight: 600; font-size: 0.95rem; opacity: 0; transition: opacity 0.2s; }
.prompt.show { opacity: 1; }
.prompt.mine { border-color: rgba(56, 243, 255, 0.6); box-shadow: 0 0 20px rgba(56, 243, 255, 0.25); }

/* hand */
.hand { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); height: calc(var(--card-w) * 1.4 + 14px); width: min(1100px, 92vw); pointer-events: none; }
.dcard { position: absolute; width: var(--card-w); aspect-ratio: 1890/2640; border-radius: calc(var(--card-w) * 0.06); cursor: pointer; pointer-events: auto;
  transform-origin: 50% 120%; transition: transform 0.22s cubic-bezier(.2, .8, .2, 1), filter 0.2s, box-shadow 0.2s; box-shadow: 0 8px 18px rgba(0, 0, 0, 0.55);
  background: #120c24; --mx: 0.5; --my: 0.5; }
.dcard img { width: 100%; height: 100%; border-radius: inherit; display: block; pointer-events: none; }
.dcard .holo { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; mix-blend-mode: color-dodge; opacity: 0;
  background: linear-gradient(115deg, transparent 20%, rgba(255, 0, 140, 0.55) 36%, rgba(255, 220, 0, 0.5) 44%, rgba(0, 255, 160, 0.5) 52%, rgba(0, 160, 255, 0.55) 60%, rgba(170, 0, 255, 0.5) 68%, transparent 82%);
  background-size: 250% 250%; background-position: calc(var(--mx) * 100%) calc(var(--my) * 100%); animation: holo 9s linear infinite; }
.dcard .sheen { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.55) 50%, transparent 60%); background-size: 300% 100%; animation: sheen 3.6s ease-in-out infinite; mix-blend-mode: overlay; }
.dcard .spark { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0;
  background-image: radial-gradient(circle, #fff 0 1px, transparent 1.5px), radial-gradient(circle, #fff 0 1px, transparent 1.5px);
  background-size: 23px 31px, 37px 29px; background-position: 0 0, 11px 7px; animation: twinkle 2.8s ease-in-out infinite; mix-blend-mode: screen; }
@keyframes holo { to { background-position: calc(var(--mx) * 100% + 250%) calc(var(--my) * 100%); } }
@keyframes sheen { 0% { background-position: 150% 0; } 60%, 100% { background-position: -50% 0; } }
@keyframes twinkle { 50% { opacity: 0.35; } }
.dcard.r-Uncommon { box-shadow: 0 0 14px 2px rgba(34, 255, 122, 0.55), 0 8px 18px rgba(0, 0, 0, 0.55); }
.dcard.r-Uncommon .sheen { opacity: 0.5; }
.dcard.r-Rare { box-shadow: 0 0 18px 3px rgba(47, 134, 255, 0.7), 0 8px 18px rgba(0, 0, 0, 0.55); }
.dcard.r-Rare .holo { opacity: 0.32; } .dcard.r-Rare .sheen { opacity: 0.55; }
.dcard.r-Epic { box-shadow: 0 0 22px 4px rgba(176, 77, 255, 0.8), 0 8px 18px rgba(0, 0, 0, 0.55); }
.dcard.r-Epic .holo { opacity: 0.5; } .dcard.r-Epic .sheen { opacity: 0.6; } .dcard.r-Epic .spark { opacity: 0.45; }
.dcard.r-Legendary { box-shadow: 0 0 26px 6px rgba(255, 194, 61, 0.9), 0 0 60px rgba(255, 160, 40, 0.35), 0 8px 18px rgba(0, 0, 0, 0.55); outline: 2px solid rgba(255, 220, 140, 0.8); outline-offset: -2px; }
.dcard.r-Legendary .holo { opacity: 0.6; filter: sepia(0.5) saturate(1.6); } .dcard.r-Legendary .sheen { opacity: 0.8; } .dcard.r-Legendary .spark { opacity: 0.8; }
.hand .dcard.playable::after { content: ''; position: absolute; inset: -4px; border-radius: inherit; border: 2px solid var(--cyan); box-shadow: 0 0 14px var(--cyan); animation: glow 1.2s ease-in-out infinite; pointer-events: none; }
@keyframes glow { 50% { opacity: 0.45; } }
.hand .dcard.unplayable { filter: brightness(0.62) saturate(0.7); }
.hand .dcard.selected { filter: brightness(1.12); }
.hand .dcard.selected::after { border-color: var(--gold); box-shadow: 0 0 20px var(--gold); animation: none; }
.hand .dcard .tag { position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); font-family: var(--display); font-size: 0.72rem; letter-spacing: 0.12em; color: var(--gold); white-space: nowrap; pointer-events: none;
  text-shadow: 0 0 10px rgba(255, 194, 61, 0.8), 0 1px 3px rgba(0, 0, 0, 0.9); animation: tag-pulse 1.4s ease-in-out infinite; }
@keyframes tag-pulse { 50% { opacity: 0.6; } }

.actions { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.actions .btn { min-width: 132px; }
.actions .btn.end { border-color: rgba(255, 194, 61, 0.7); }

.toasts { position: fixed; left: 50%; top: calc(var(--guide-y, 45%) + 70px); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 60; }
.toast { padding: 8px 16px; border-radius: 12px; background: rgba(8, 5, 20, 0.88); border: 1px solid var(--line); font-weight: 700; font-size: 0.95rem; animation: toast 2.8s forwards; text-align: center; max-width: 70vw; }
.toast.bad { border-color: rgba(255, 64, 96, 0.8); box-shadow: 0 0 20px rgba(255, 64, 96, 0.35); }
.toast.good { border-color: rgba(34, 255, 122, 0.7); box-shadow: 0 0 20px rgba(34, 255, 122, 0.3); }
@keyframes toast { 0% { opacity: 0; transform: translateY(10px) scale(0.95); } 8%, 82% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-14px); } }

.log { position: absolute; right: 0; top: var(--hud-h); bottom: 0; width: min(320px, 80vw); background: var(--panel); border-left: 1px solid var(--line); transform: translateX(105%); transition: transform 0.25s; padding: 10px 14px; overflow: auto; z-index: 9; }
.log.open { transform: none; }
.log h4 { margin: 4px 0 8px; font-family: var(--display); font-weight: 400; letter-spacing: 0.08em; }
.log ol { margin: 0; padding-left: 18px; font-size: 0.82rem; color: var(--muted); display: flex; flex-direction: column-reverse; gap: 3px; }
.log li.p0 { color: #bff9ff; } .log li.p1 { color: #ffd0f5; }

.banner { position: absolute; left: 0; right: 0; top: calc(var(--guide-y, 45%) - 62px); text-align: center; pointer-events: none; font-family: var(--display); font-size: clamp(1.05rem, 2.4vw, 1.9rem); opacity: 0; z-index: 7;
  text-shadow: 0 0 30px currentColor; letter-spacing: 0.06em; }
.banner.show { animation: banner 1.5s ease-out forwards; }
.banner.me { color: var(--cyan); } .banner.opp { color: var(--magenta); } .banner.gold { color: var(--gold); } .banner.red { color: var(--red); }
@keyframes banner { 0% { opacity: 0; transform: scale(1.25); letter-spacing: 0.2em; } 15% { opacity: 1; transform: scale(1); letter-spacing: 0.06em; } 75% { opacity: 1; } 100% { opacity: 0; transform: scale(0.96); } }

/* ------------------------------------------------------------ overlays */
.overlay { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 30; background: rgba(3, 2, 8, 0.6); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.overlay.open { display: flex; }
#modal, #reaction { z-index: 25; }
.modal-box { width: min(980px, 94vw); max-height: 88vh; display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7); }
.modal-box h3 { margin: 0; font-size: 1.05rem; }
.modal-box .sub { color: var(--muted); font-size: 0.85rem; margin-top: -6px; }
.pick-grid { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; overflow: auto; padding: 8px 4px 14px; }
.pick-grid .dcard { position: relative; --card-w: clamp(78px, 11vw, 140px); }
.pick-grid .dcard:hover { transform: translateY(-4px); }
.pick-grid .dcard.disabled { filter: grayscale(0.85) brightness(0.45); pointer-events: none; }
.pick-grid .dcard.chosen { transform: translateY(-8px); }
.pick-grid .dcard.chosen::after { content: '✓'; position: absolute; inset: -5px; border-radius: inherit; border: 3px solid var(--gold); box-shadow: 0 0 22px var(--gold); display: grid; place-items: start end; padding: 4px 8px; font-weight: 900; color: var(--gold); font-size: 20px; }
/* docked dialog: sits at the bottom so the table stays visible (picking cards or spots on the board) */
#modal.dock { align-items: flex-end; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; pointer-events: none; }
#modal.dock .modal-box { pointer-events: auto; margin-bottom: 10px; max-height: 42vh; width: min(900px, 80vw); }
#modal.dock .pick-grid .dcard { --card-w: clamp(54px, 7vw, 92px); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.choice-list { display: grid; gap: 8px; }

.reaction-box { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 22px; }
.reaction-box h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(1.1rem, 2.6vw, 1.7rem); letter-spacing: 0.04em; text-align: center; color: var(--gold); text-shadow: 0 0 20px rgba(255, 194, 61, 0.5); }
.reaction-row { display: flex; align-items: center; gap: clamp(12px, 3vw, 40px); }
.reaction-row .vs { font-family: var(--display); font-size: 1.6rem; color: var(--red); text-shadow: 0 0 18px var(--red); }
.reaction-row .dcard { position: relative; --card-w: clamp(110px, 16vw, 200px); }
.reaction-opts { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.reaction-opts .dcard { --card-w: clamp(90px, 12vw, 150px); position: relative; }
.reaction-opts .dcard:hover { transform: translateY(-8px) scale(1.04); }
.chain { display: flex; gap: 8px; }
.chain .dcard { position: relative; --card-w: 64px; }
.chain .dcard.cancelled { filter: grayscale(1) brightness(0.5); }

#inspect { z-index: 40; }
.inspect-box { display: flex; gap: 24px; align-items: center; max-width: 94vw; }
.inspect-box .dcard { position: relative; --card-w: min(380px, 34vw, calc(70vh * 0.716)); cursor: default; transform: perspective(900px) rotateY(calc((var(--mx) - 0.5) * 18deg)) rotateX(calc((0.5 - var(--my)) * 18deg)); transition: transform 0.08s; }
.inspect-info { max-width: 460px; max-height: 88vh; overflow: auto; touch-action: pan-y; }
.inspect-info h2 { margin: 0 0 4px; font-family: var(--display); font-weight: 400; }
.inspect-info .type { color: var(--muted); font-family: var(--mono); letter-spacing: 0.08em; margin-bottom: 10px; }
.inspect-info p { line-height: 1.45; }
.rarity-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 0.8rem; cursor: pointer; background: rgba(255, 255, 255, 0.04); }
.chip.on { border-color: var(--cyan); background: rgba(56, 243, 255, 0.12); }
.chip.Uncommon { color: var(--green); } .chip.Rare { color: #78b4ff; } .chip.Epic { color: #d199ff; } .chip.Legendary { color: var(--gold); }

.pass-box, .menu-box, .settings-box, .gameover-box { padding: 24px 28px; display: grid; gap: 12px; text-align: center; min-width: min(380px, 90vw); }
.pass-box h2, .menu-box h2, .settings-box h2 { margin: 0 0 6px; font-family: var(--display); font-weight: 400; letter-spacing: 0.05em; }
.settings-box { text-align: left; }
.gameover-box h1 { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(2.2rem, 7vw, 4.6rem); letter-spacing: 0.04em; }
.gameover-box.win h1 { color: var(--gold); text-shadow: 0 0 40px rgba(255, 194, 61, 0.7); }
.gameover-box.lose h1 { color: var(--red); text-shadow: 0 0 40px rgba(255, 64, 96, 0.6); }
.gameover-box .stats { font-family: var(--mono); color: var(--muted); }
.how-box { width: min(820px, 94vw); max-height: 88vh; overflow: auto; padding: 22px 26px; text-align: left; line-height: 1.5; }
.how-box h2 { font-family: var(--display); font-weight: 400; margin-top: 0; }
.how-box h3 { color: var(--cyan); margin-bottom: 4px; }
.how-box ol, .how-box ul { padding-left: 20px; }

/* ------------------------------------------------------------ library */
#library { z-index: 22; background: radial-gradient(ellipse at 50% 0%, rgba(106, 60, 255, 0.3), rgba(5, 3, 12, 0.97) 60%); overflow: auto; touch-action: pan-y; }
#library.active { display: block; }
.lib-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 16px; background: rgba(5, 3, 12, 0.9); border-bottom: 1px solid var(--line); }
.lib-head h2 { margin: 0; font-family: var(--display); font-weight: 400; }
.lib-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(96px, 12vw, 150px), 1fr)); gap: 16px; padding: 18px; }
.lib-grid .dcard { position: relative; width: 100%; --card-w: 100%; }
.lib-grid .dcard:hover { transform: translateY(-6px) scale(1.03); z-index: 2; }
.lib-grid figure { margin: 0; }
.lib-grid figcaption { font-size: 0.78rem; text-align: center; margin-top: 6px; color: var(--muted); }
.lib-grid figcaption b { color: var(--text); display: block; font-size: 0.85rem; }
.lib-section { grid-column: 1 / -1; font-family: var(--display); color: var(--cyan); letter-spacing: 0.08em; border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-top: 8px; }

/* ------------------------------------------------------------ misc */
#rotate { position: fixed; inset: 0; z-index: 100; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: var(--bg); text-align: center; }
.rotate-icon { font-size: 64px; color: var(--cyan); animation: spin 2s ease-in-out infinite; }
@keyframes spin { 50% { transform: rotate(90deg); } }
@media (orientation: portrait) and (max-width: 820px) { #rotate { display: flex; } }
#loading { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--bg); transition: opacity 0.4s; }
#loading.done { opacity: 0; pointer-events: none; }
#loading .bar { width: 220px; height: 4px; background: rgba(255, 255, 255, 0.08); border-radius: 4px; overflow: hidden; }
#loading .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--magenta)); transition: width 0.2s; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.1); border-top-color: var(--cyan); animation: rot 0.9s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* phones in landscape */
@media (max-height: 520px) {
  :root { --hud-h: 40px; --card-w: clamp(46px, 6vh + 2.4vw, 64px); }
  .hud-top { padding: 4px 8px; }
  .icon-btn { width: 32px; height: 32px; font-size: 15px; }
  .banner { font-size: 1.3rem; }
  .opp-hand { display: none; }
  .steps li { font-size: 0.6rem; padding: 3px 6px; }
  .avatar { width: 28px; height: 28px; font-size: 0.65rem; border-width: 1.5px; }
  .seat-name { font-size: 0.8rem; } .seat-stats { font-size: 0.68rem; gap: 6px; }
  .actions .btn { min-width: 100px; padding: 7px 12px; font-size: 0.85rem; }
  .prompt { font-size: 0.8rem; top: calc(var(--hud-h) + 12px); padding: 5px 12px; }
  .seat-me { bottom: calc(var(--card-w) * 1.05 + 10px); }
  .modal-box { padding: 12px 14px; max-height: 94vh; }
  .pick-grid .dcard { --card-w: clamp(60px, 18vh, 110px); }
  .reaction-row .dcard { --card-w: clamp(80px, 30vh, 150px); }
  .reaction-opts .dcard { --card-w: clamp(70px, 24vh, 120px); }
  .menu .btn.big { padding: 9px 18px; font-size: 0.92rem; }
}
@media (max-width: 900px) { .steps li:not(.now) { display: none; } }
@media (prefers-reduced-motion: reduce) { .dcard .holo, .dcard .sheen, .dcard .spark, .menu-portal { animation: none; } }

/* tutorial coach: Sandy's pose beside a speech panel */
.coach { position: fixed; left: 10px; top: calc(var(--hud-h) + 2px); z-index: 12; display: flex; flex-direction: column; align-items: flex-start; gap: 0; width: min(460px, 37vw); pointer-events: none; }
.coach[hidden] { display: none; }
.coach { --art: clamp(96px, 9vw, 128px); }
.coach-art { width: var(--art); height: auto; flex: none; margin: 0 0 calc(var(--art) * -0.3) 18px; position: relative; z-index: 0; filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 18px rgba(255, 79, 216, 0.35)); pointer-events: none; }
.coach-art.pop { animation: coach-bounce 0.45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes coach-bounce { 0% { transform: translateY(10px) scale(0.94); } 100% { transform: none; } }
.coach-body { position: relative; z-index: 1; align-self: stretch; display: grid; gap: 8px; padding: 12px 14px; border-radius: 16px; pointer-events: auto; max-height: calc(100vh - var(--hud-h) - 40px); overflow: auto;
  background: linear-gradient(160deg, rgba(40, 18, 70, 0.97), rgba(12, 8, 26, 0.97)); border: 1px solid rgba(255, 79, 216, 0.55); box-shadow: 0 0 26px rgba(255, 79, 216, 0.28), 0 16px 40px rgba(0, 0, 0, 0.55); }
.coach.hint .coach-body { border-color: rgba(56, 243, 255, 0.6); box-shadow: 0 0 22px rgba(56, 243, 255, 0.25), 0 16px 40px rgba(0, 0, 0, 0.55); }
.coach.in .coach-body { animation: coach-pop 0.3s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes coach-pop { from { opacity: 0; transform: translateY(-6px) scale(0.98); } }
.coach-top { display: flex; align-items: baseline; gap: 10px; }
.coach-name { color: var(--magenta); font-family: var(--display); font-weight: 400; letter-spacing: 0.05em; font-size: 0.9rem; }
.coach-lesson { font-family: var(--mono); color: var(--muted); font-size: 0.72rem; }
.coach-skip { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 0.75rem; text-decoration: underline; cursor: pointer; padding: 0; }
.coach-skip:hover { color: var(--text); }
.coach-text { margin: 0; line-height: 1.4; font-size: 0.9rem; }
.coach-text b { color: var(--gold); }
.coach-cards { display: flex; gap: 6px; flex-wrap: wrap; }
.coach-cards:empty { display: none; }
.coach-cards .dcard { position: relative; --card-w: clamp(44px, 4.4vw, 64px); cursor: default; transition: transform 0.15s; }
.coach-cards .dcard:hover { transform: scale(1.9); z-index: 3; }
.coach-btns { display: flex; justify-content: flex-end; gap: 8px; }
.coach-btns:empty { display: none; }
body:has(#reaction.open, #modal.open) .coach { top: auto; bottom: 10px; z-index: 60; width: min(420px, 38vw); }
body:has(#reaction.open, #modal.open) .coach { --art: 78px; }

/* what Sandy is pointing at */
.tut-focus { outline: 2px solid var(--gold) !important; outline-offset: 3px; box-shadow: 0 0 22px rgba(255, 194, 61, 0.7) !important; animation: tut-glow 1.1s ease-in-out infinite; position: relative; z-index: 11; }
@keyframes tut-glow { 50% { outline-color: rgba(255, 194, 61, 0.35); } }
.steps.tut-all li:not([data-step="Adoption"]) { display: block !important; }

/* lesson title cards */
.tut-cut { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(40, 18, 70, 0.92), rgba(5, 3, 12, 0.97)); opacity: 0; pointer-events: none; transition: opacity 0.35s; cursor: pointer; }
.tut-cut.show { opacity: 1; pointer-events: auto; }
.tut-cut-inner { text-align: center; transform: translateY(10px); transition: transform 0.5s cubic-bezier(.2, 1.2, .4, 1); }
.tut-cut.show .tut-cut-inner { transform: none; }
.tut-cut small { font-family: var(--mono); color: var(--cyan); letter-spacing: 0.3em; text-transform: uppercase; }
.tut-cut h2 { margin: 10px 0 6px; font-family: var(--display); font-weight: 400; font-size: clamp(1.8rem, 5vw, 3.4rem); color: #fff; text-shadow: 0 0 30px rgba(176, 77, 255, 0.7); }
.tut-cut p { margin: 0; color: var(--muted); font-size: 1.05rem; }

@media (max-height: 520px) {
  .coach { width: min(360px, 44vw); top: calc(var(--hud-h) + 4px); }
  .coach { --art: 62px; }
  .coach-art { margin-left: 12px; }
  .coach-body { padding: 6px 9px 7px; gap: 4px; max-height: calc(100vh - var(--hud-h) - 16px); }
  .coach-text { font-size: 0.72rem; line-height: 1.35; }
  .coach-top { gap: 6px; }
  .coach-name, .coach-lesson, .coach-skip { font-size: 0.66rem; }
  .coach-cards .dcard { --card-w: 32px; }
  .coach-btns .btn.small { padding: 4px 10px; font-size: 0.75rem; }
}

/* ------------------------------------------------------------ library: collection and locked prints */
.chip-gap { width: 10px; }
.chip.ver.on { border-color: var(--gold); background: rgba(255, 194, 61, 0.14); }
.lib-progress { grid-column: 1 / -1; color: var(--muted); font-size: 0.88rem; }
.lib-progress b { color: var(--gold); font-family: var(--display); font-weight: 400; font-size: 1.05rem; }
.dcard.locked img { filter: grayscale(1) brightness(0.5) contrast(1.05); }
.dcard.locked .holo, .dcard.locked .sheen, .dcard.locked .spark { opacity: 0 !important; }
.lib-grid .dcard.locked { box-shadow: 0 8px 18px rgba(0, 0, 0, 0.55); outline: none; }
.lib-grid .dcard.locked:hover { filter: brightness(1.25); }
.lock-badge { position: absolute; right: 6%; top: 4%; font-size: clamp(14px, 1.6vw, 20px); filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8)); pointer-events: none; }
.ver-badge { position: absolute; left: 6%; top: 4%; padding: 1px 6px; border-radius: 6px; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.05em; pointer-events: none; background: rgba(5, 3, 12, 0.85); border: 1px solid var(--line); }
.ver-badge.og { color: var(--magenta); border-color: rgba(255, 79, 216, 0.6); }
.ver-badge.signature { color: var(--gold); border-color: rgba(255, 194, 61, 0.6); }
.lib-grid figcaption .ver { display: block; font-size: 0.72rem; color: var(--cyan); }
.lib-grid figcaption .ver.og { color: var(--magenta); } .lib-grid figcaption .ver.signature { color: var(--gold); }
.lib-grid figcaption small { display: block; font-size: 0.7rem; color: var(--muted); }
.lib-grid figure.is-locked figcaption b { color: var(--muted); }
.lock-cover { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 4px; text-align: center; border-radius: inherit; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(5, 3, 12, 0.55), rgba(5, 3, 12, 0.15) 70%); }
.lock-cover span { font-size: clamp(30px, 4vw, 52px); filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.8)); }
.lock-cover b { font-size: 0.95rem; text-shadow: 0 2px 6px #000; }
.lock-cover small { color: var(--muted); text-shadow: 0 2px 6px #000; }
.versions { display: grid; gap: 8px; margin: 8px 0 10px; }
.version-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 10px; border: 1px solid transparent; }
.version-row.on { border-color: var(--line); background: rgba(255, 255, 255, 0.03); }
.version-row .ver { flex-basis: 100%; font-weight: 700; font-size: 0.85rem; color: var(--cyan); }
.version-row .ver.og { color: var(--magenta); } .version-row .ver.signature { color: var(--gold); }
.chip.locked { opacity: 0.6; }
.chip.locked.on { opacity: 1; }

.now-playing b { color: var(--gold); margin-right: 10px; font-weight: 700; }

/* ------------------------------------------------------------ the menu's world: the city, the portal, cards drifting out */
#title { z-index: 20; overflow: hidden; background: #05030c; }
.menu-sky { position: absolute; inset: -4%; background: url(../assets/ui/intro/city.webp) center 58% / cover no-repeat; filter: saturate(1.1) brightness(0.62); animation: sky-drift 40s ease-in-out infinite alternate; }
@keyframes sky-drift { to { transform: scale(1.06) translateY(-1%); } }
.menu-portal { position: absolute; left: 50%; top: 27%; width: min(80vh, 62vw); height: auto; transform: translate(-50%, -50%); opacity: 0.55; pointer-events: none; animation: portal-spin 90s linear infinite; filter: drop-shadow(0 0 40px rgba(255, 170, 60, 0.35)); }
@keyframes portal-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.menu-cards { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0.7; overflow: hidden; }
.menu-vignette { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 35%, transparent 30%, rgba(5, 3, 12, 0.55) 70%, rgba(5, 3, 12, 0.92) 100%),
    linear-gradient(180deg, rgba(5, 3, 12, 0.35), transparent 25%, transparent 70%, rgba(5, 3, 12, 0.85)); }
/* scanlines over the whole menu, very faint */
#title::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.18;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 3px); }

/* ------------------------------------------------------------ glass HUD buttons */
.menu { perspective: 1100px; }
.menu .btn {
  --cut: 12px;
  border: 0; border-radius: 0; color: #f4f1ff; letter-spacing: 0.04em;
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04) 46%, rgba(255, 255, 255, 0.02) 54%, rgba(140, 110, 255, 0.08)),
    rgba(10, 7, 26, 0.74);
  backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  box-shadow: inset 0 0 0 1px rgba(200, 210, 255, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 14px 30px rgba(0, 0, 0, 0.45);
  transform: translateZ(0); transition: transform 0.25s cubic-bezier(.2, 1.2, .4, 1), box-shadow 0.25s, background 0.25s;
  overflow: hidden;
}
/* HUD corner ticks */
.menu .btn::before { content: ''; position: absolute; inset: 4px; pointer-events: none;
  background:
    linear-gradient(var(--tick, #38f3ff), var(--tick, #38f3ff)) left top / 14px 1.5px no-repeat,
    linear-gradient(var(--tick, #38f3ff), var(--tick, #38f3ff)) left top / 1.5px 10px no-repeat,
    linear-gradient(var(--tick, #38f3ff), var(--tick, #38f3ff)) right bottom / 14px 1.5px no-repeat,
    linear-gradient(var(--tick, #38f3ff), var(--tick, #38f3ff)) right bottom / 1.5px 10px no-repeat;
  opacity: 0.55; transition: opacity 0.25s; }
/* a light sweep on hover */
.menu .btn::after { content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.28), transparent); transform: skewX(-18deg); transition: left 0.6s ease; }
.menu .btn:hover { transform: translateZ(40px) translateY(-2px); box-shadow: inset 0 0 0 1px rgba(56, 243, 255, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 0 26px rgba(56, 243, 255, 0.35), 0 18px 36px rgba(0, 0, 0, 0.5); }
.menu .btn:hover::before { opacity: 1; }
.menu .btn:hover::after { left: 130%; }
.menu .btn:active { transform: translateZ(10px) translateY(1px); }
.menu .btn.primary {
  --tick: #ffd27a;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.06) 48%, rgba(255, 255, 255, 0) 52%),
    linear-gradient(90deg, rgba(26, 214, 255, 0.55), rgba(106, 60, 255, 0.55) 60%, rgba(255, 79, 216, 0.45));
  box-shadow: inset 0 0 0 1px rgba(255, 220, 150, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 0 30px rgba(106, 60, 255, 0.45), 0 14px 30px rgba(0, 0, 0, 0.45);
  animation: primary-breathe 3.2s ease-in-out infinite;
}
@keyframes primary-breathe { 50% { box-shadow: inset 0 0 0 1px rgba(255, 220, 150, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 0 44px rgba(56, 243, 255, 0.5), 0 14px 30px rgba(0, 0, 0, 0.45); } }
.menu .btn.ghost { background: rgba(10, 7, 26, 0.6); }
.menu .mi { filter: drop-shadow(0 0 6px rgba(56, 243, 255, 0.6)); }
.menu .btn.big small { font-family: var(--mono); letter-spacing: 0.06em; }
/* the menu floats, tilted slightly towards you */
.menu { transform-style: preserve-3d; transform: rotateX(4deg); animation: menu-in 0.8s 0.25s both, menu-float 7s 1.1s ease-in-out infinite; }
@keyframes menu-float { 50% { transform: rotateX(4deg) translateY(-6px); } }
.profile-chip { backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); background: rgba(14, 10, 32, 0.5); box-shadow: inset 0 0 0 1px rgba(200, 210, 255, 0.18), 0 10px 26px rgba(0, 0, 0, 0.45); border: 0; }
.logo-tcg { margin-top: 10px; }

/* ------------------------------------------------------------ glass panels on the other menu screens */
#setup, #online, #boards { background: #05030c url(../assets/ui/intro/grid.webp) center bottom / cover no-repeat; }
#setup::before, #online::before, #boards::before { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 20%, rgba(106, 60, 255, 0.25), rgba(5, 3, 12, 0.82) 70%); pointer-events: none; }
.setup-panel, .lobby-panel, .boards-panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02)), rgba(12, 8, 28, 0.55);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(200, 210, 255, 0.2); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 30px 80px rgba(0, 0, 0, 0.6);
}

/* ------------------------------------------------------------ the intro: scroll to descend */
.intro { position: fixed; inset: 0; z-index: 85; overflow: hidden; background: #05030c; opacity: 0; transition: opacity 0.8s; touch-action: none; }
.intro.show { opacity: 1; }
.intro[hidden] { display: none; }
.intro .i-sky { position: absolute; inset: 0; background: url(../assets/ui/intro/city.webp) center 58% / cover no-repeat; transform-origin: 50% 44%; will-change: transform, opacity; }
.intro .i-grid { position: absolute; left: -30%; right: -30%; bottom: -10%; height: 70%; background: url(../assets/ui/intro/grid.webp) center top / cover no-repeat; mix-blend-mode: screen; opacity: 0.55; transform-origin: 50% 0; pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 30%); mask-image: linear-gradient(180deg, transparent, #000 30%); }
.intro .i-portal, .intro .i-tunnel { position: absolute; left: 50%; top: 44%; height: auto; transform: translate(-50%, -50%); will-change: transform, opacity; pointer-events: none; }
.intro .i-portal { width: min(62vh, 52vw); filter: drop-shadow(0 0 50px rgba(255, 170, 60, 0.45)); }
.intro .i-tunnel { width: max(110vw, 110vh); opacity: 0; mix-blend-mode: normal;
  -webkit-mask-image: radial-gradient(circle, #000 55%, transparent 72%); mask-image: radial-gradient(circle, #000 55%, transparent 72%); }
.intro .i-cards { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: hidden; }
/* a card flying out of the vortex */
.vc { position: absolute; border-radius: 6%; backface-visibility: visible; will-change: transform, opacity; pointer-events: none;
  box-shadow: 0 0 22px rgba(255, 190, 80, 0.45), 0 0 2px rgba(255, 230, 180, 0.9); }
.intro .i-logo { position: absolute; left: 50%; top: 17%; width: min(620px, 56vw); transform: translate(-50%, -50%); pointer-events: none; opacity: 0;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.95)) drop-shadow(0 0 18px rgba(176, 77, 255, 0.85)) drop-shadow(0 12px 30px rgba(0, 0, 0, 0.7)); }
.intro .i-scan { position: absolute; inset: 0; pointer-events: none; opacity: 0.35; background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 3px); mix-blend-mode: overlay; }
.intro .i-flash { position: absolute; inset: 0; background: radial-gradient(circle at 50% 44%, #fff, #ffe2a8 30%, #ff9f2e 60%, rgba(255, 140, 40, 0.6)); opacity: 0; pointer-events: none; }
.i-hud { position: absolute; inset: 14px; pointer-events: none; font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.22em; color: #ffc23d; text-transform: uppercase; text-shadow: 0 0 10px rgba(255, 194, 61, 0.6); }
.i-hud::before, .i-hud::after { content: ''; position: absolute; width: 40px; height: 40px; border: 2px solid rgba(255, 194, 61, 0.7); }
.i-hud::before { left: 0; top: 0; border-right: 0; border-bottom: 0; }
.i-hud::after { right: 0; bottom: 0; border-left: 0; border-top: 0; }
.i-hud .tl { position: absolute; left: 22px; top: 12px; }
.i-hud .tr { position: absolute; right: 22px; top: 12px; color: #38f3ff; text-shadow: 0 0 10px rgba(56, 243, 255, 0.6); }
.hud-btn { position: absolute; pointer-events: auto; cursor: pointer; font: inherit; letter-spacing: 0.22em; text-transform: uppercase; color: #fff; padding: 10px 18px;
  background: rgba(10, 6, 24, 0.55); border: 1px solid rgba(255, 194, 61, 0.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px); transition: background 0.2s, box-shadow 0.2s; }
.hud-btn:hover { background: rgba(255, 194, 61, 0.18); box-shadow: 0 0 20px rgba(255, 194, 61, 0.4); }
.i-hud .bl { left: 14px; bottom: 10px; }
.i-hud .br { right: 14px; bottom: 10px; }
.i-hint { position: absolute; left: 50%; bottom: 6%; transform: translateX(-50%); display: grid; justify-items: center; gap: 8px; font-family: var(--mono); letter-spacing: 0.4em; font-size: 0.82rem; color: #ffc23d; text-transform: uppercase; text-shadow: 0 0 10px rgba(255, 194, 61, 0.7); pointer-events: none; }
.i-hint i { width: 22px; height: 34px; border: 2px solid rgba(255, 194, 61, 0.8); border-radius: 12px; position: relative; }
.i-hint i::after { content: ''; position: absolute; left: 50%; top: 6px; width: 4px; height: 8px; margin-left: -2px; border-radius: 2px; background: #ffc23d; animation: wheel 1.4s ease-in-out infinite; }
@keyframes wheel { 0% { transform: translateY(0); opacity: 1; } 80% { transform: translateY(12px); opacity: 0; } 100% { opacity: 0; } }
@media (max-height: 520px), (max-width: 760px) {
  .i-hud { font-size: 0.62rem; inset: 8px; }
  .hud-btn { padding: 7px 12px; }
  .i-hint { font-size: 0.66rem; bottom: 16%; }
}
@media (prefers-reduced-motion: reduce) { .menu-portal, .menu-sky, .menu, .menu .btn.primary { animation: none; } }

/* the scroll hint reads clearly over the bright floor */
.i-hint span { padding: 6px 14px; background: rgba(5, 3, 12, 0.55); border: 1px solid rgba(255, 194, 61, 0.35); clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); }

/* =====================================================================================
   PHONES
   Sideways (short screens): every screen is laid out for ~360-430px of height.
   Upright: the menus, Library, lobby and profile work; only a match asks you to turn sideways.
   ===================================================================================== */
@media (orientation: portrait) and (max-width: 820px) { #rotate { display: none; } body.in-game #rotate { display: flex; } }

@media (max-height: 520px) {
  /* ---------------- title: logo on the left, the glass menu on the right */
  .title-inner { padding: 8px 14px; }
  .title-main { flex-direction: row; align-items: center; justify-content: center; gap: 4vw; width: 100%; }
  .logo-img { width: min(340px, 40vw); }
  .logo-tcg { font-size: 0.58rem; letter-spacing: 0.35em; margin-top: 6px; }
  .menu { width: min(380px, 48vw); gap: 5px; transform: none; animation: menu-in 0.8s 0.25s both; }
  .menu .btn { --cut: 8px; padding: 6px 10px; font-size: 0.8rem; }
  .menu .btn.big { padding: 7px 12px; font-size: 0.88rem; gap: 8px; }
  .menu .btn.big small { font-size: 0.6rem; }
  .menu .mi { font-size: 1rem; }
  .menu-row { gap: 5px; }
  .menu .btn.ghost.small { font-size: 0.66rem; padding: 4px 10px; }
  .menu-portal { left: 27%; top: 50%; width: min(78vh, 46vw); }
  .profile-chip { top: 6px; right: 8px; padding: 3px 10px 3px 3px; gap: 6px; }
  .profile-chip .avatar.sm { width: 26px; height: 26px; }
  .chip-text b { font-size: 0.74rem; } .chip-text small { display: none; }

  /* ---------------- menu screens */
  .setup-panel, .lobby-panel, .boards-panel { padding: 10px 14px; max-height: 96vh; }
  .setup-panel h2, .lobby-panel h2, .boards-panel h2 { font-size: 1.05rem; margin: 0 0 6px; }
  .setup-panel .back, .lobby-panel .back, .boards-panel .back { top: 6px; left: 6px; padding: 5px 10px; font-size: 0.78rem; }
  .vs-side h3 { font-size: 0.66rem; margin-bottom: 4px; }
  .deck-opt { padding: 5px 8px; grid-template-columns: 40px 1fr; gap: 8px; }
  .deck-opt img { width: 40px; }
  .deck-opt b { font-size: 0.82rem; } .deck-opt small { font-size: 0.68rem; }
  .opp-card { padding: 4px 8px; margin-bottom: 5px; }
  .opp-card img { width: 40px; height: 40px; }
  .setup-options { margin: 8px 0; }
  .opt { padding: 5px 10px; font-size: 0.82rem; }
  .btn.big.start { padding: 9px 20px; font-size: 0.92rem; }
  .btn.quick { padding: 10px; font-size: 1.05rem; }
  .lobby-body { gap: 9px; }
  .lobby-notes { font-size: 0.72rem; }
  .board-list li { padding: 5px 10px; }
  .profile-box { padding: 12px 14px; max-height: 96vh; }

  /* ---------------- Library: filters scroll sideways instead of wrapping into three rows */
  .lib-head { padding: 6px 10px; gap: 8px; flex-wrap: nowrap; }
  .lib-head h2 { font-size: 1rem; white-space: nowrap; }
  .lib-head .btn { white-space: nowrap; padding: 5px 10px; font-size: 0.78rem; flex: none; }
  .lib-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; }
  .lib-filters::-webkit-scrollbar { display: none; }
  .lib-filters .chip { white-space: nowrap; font-size: 0.72rem; padding: 3px 9px; }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 10px; padding: 10px; }
  .lib-grid figcaption { font-size: 0.66rem; }
  .lib-grid figcaption b { font-size: 0.72rem; }
  .inspect-box { gap: 12px; padding: 0 8px; }
  .inspect-box .dcard { --card-w: min(200px, 36vw, calc(86vh * 0.716)); }
  .inspect-info { max-height: 92vh; font-size: 0.82rem; }
  .inspect-info h2 { font-size: 1.1rem; }
  .version-row { padding: 3px 4px; gap: 4px; }
  .version-row .chip { font-size: 0.66rem; padding: 2px 7px; }

  /* ---------------- the match */
  :root { --hud-h: 38px; --card-w: clamp(46px, 7vh + 1.6vw, 60px); }
  .hand { left: 6px; transform: none; width: calc(100vw - 140px); height: calc(var(--card-w) * 1.4 + 8px); bottom: calc(var(--card-w) * -0.32); }
  .actions { right: 8px; bottom: 8px; gap: 6px; }
  .actions .btn { min-width: 92px; padding: 6px 10px; font-size: 0.8rem; }
  .autoskip { top: calc(var(--hud-h) + 4px); bottom: auto; right: 8px; font-size: 0.6rem; padding: 3px 8px; }
  .seat-me { left: 6px; bottom: calc(var(--card-w) * 1.4 + 8px); }
  .seat-me .seat-stats { display: none; }
  .sandy { left: 6px; }
  .sandy-card { width: 58px; }
  .sandy-name { font-size: 0.66rem; margin-top: 2px; }
  .sandy-bubble { left: calc(100% + 6px); top: 2px; font-size: 0.66rem; max-width: 150px; padding: 5px 9px; }
  .g-line { white-space: normal; max-width: 64vw; text-align: center; font-size: 0.76rem; padding: 4px 12px; line-height: 1.3; background: rgba(5, 3, 12, 0.85); }
  .g-btns .btn { padding: 4px 12px; font-size: 0.76rem; }
  .banner { font-size: 1.1rem; }
  .toast { font-size: 0.76rem; padding: 5px 12px; }
  .turn-timer { font-size: 0.7rem; padding: 2px 9px; }
  .menu-box, .settings-box, .gameover-box, .pass-box { padding: 12px 16px; gap: 7px; min-width: min(320px, 90vw); }
  .menu-box .btn, .settings-box .btn { padding: 7px 12px; font-size: 0.85rem; }
  .settings-box .opt { padding: 4px 10px; }
  .gameover-box h1 { font-size: 2rem; }
  .how-box { padding: 12px 16px; font-size: 0.85rem; }
  .log { font-size: 0.72rem; }
}

/* ---------------- phones upright: the menus stack and fit the width */
@media (orientation: portrait) and (max-width: 600px) {
  .title-inner { padding: 70px 14px 24px; }
  .logo-img { width: 86vw; }
  .menu { width: 90vw; }
  .menu-portal { top: 22%; width: 120vw; }
  .setup-vs, .lobby-row, .locked-decks { grid-template-columns: 1fr; }
  .vs-mid { display: none; }
  .setup-panel, .lobby-panel, .boards-panel, .profile-box { width: 94vw; padding: 14px; }
  .lib-head { flex-wrap: wrap; }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .inspect-box { flex-direction: column; max-height: 94vh; overflow: auto; }
  .inspect-box .dcard { --card-w: min(240px, 60vw); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ------------------------------------------------------------ sound board */
#soundboard { z-index: 46; }
.soundboard-box { width: min(640px, 94vw); max-height: 90vh; overflow: auto; padding: 18px 22px; display: grid; gap: 8px; touch-action: pan-y; }
.soundboard-box h2 { margin: 0; font-family: var(--display); font-weight: 400; }
.soundboard-box h3 { margin: 8px 0 0; font-size: 0.78rem; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; }
.sb-row { display: flex; flex-wrap: wrap; gap: 6px; }
.sb-btn.hit { animation: sb-hit 0.5s ease-out; }
@keyframes sb-hit { from { box-shadow: 0 0 0 2px var(--cyan), 0 0 22px rgba(56, 243, 255, 0.6); } }
.soundboard-box.loading .sb-row { opacity: 0.5; }

.toast.tip { border-color: rgba(255, 194, 61, 0.6); color: #fff3d6; box-shadow: 0 0 18px rgba(255, 194, 61, 0.25); }

/* phones sideways: the reaction screen in two columns, so No reaction is always on screen
   (left: what's coming at you; right: your Reactions and the No reaction button) */
@media (max-height: 520px) {
  .reaction-box { display: grid; grid-template-columns: auto auto; grid-template-areas: "title title" "row sub" "row opts" "row btn";
    align-items: center; justify-items: center; column-gap: clamp(16px, 4vw, 40px); row-gap: 6px; padding: 8px 14px; max-height: 100vh; }
  .reaction-box > h3 { grid-area: title; font-size: 1rem; }
  .reaction-box > .reaction-row { grid-area: row; gap: 10px; }
  .reaction-box > .sub { grid-area: sub; font-size: 0.75rem; align-self: end; }
  .reaction-box > .reaction-opts { grid-area: opts; gap: 8px; }
  .reaction-box > .btn { grid-area: btn; align-self: start; padding: 7px 18px; font-size: 0.85rem; }
  .reaction-row .dcard { --card-w: min(30vh, 22vw); }
  .reaction-opts .dcard { --card-w: min(23vh, 15vw); }
  .reaction-row .chain .dcard { --card-w: min(13vh, 9vw); }
  .reaction-row .vs { font-size: 1.1rem; }
}

/* phones: the docked card picker (e.g. choosing a Cipher for Token Burn) is tall enough to show
   whole cards */
@media (max-height: 520px) {
  #modal.dock .modal-box { max-height: 76vh; width: min(760px, 88vw); padding: 8px 12px; gap: 6px; margin-bottom: 6px; }
  #modal.dock .modal-box h3 { font-size: 0.85rem; }
  #modal.dock .modal-box .sub { font-size: 0.7rem; margin-top: -2px; }
  #modal.dock .pick-grid { padding: 6px 4px 8px; gap: 8px; }
  #modal.dock .pick-grid .dcard { --card-w: min(25vh, 13vw); }
}
