:root {
  --ink: #f4ead8;
  --ink-dim: rgba(244, 234, 216, 0.62);
  --ink-faint: rgba(244, 234, 216, 0.38);
  --char: #151210;
  --char-2: #1d1916;
  --char-3: #2a241f;
  --line: rgba(244, 222, 180, 0.12);
  --brass: #d3ad68;
  --brass-hi: #f0d79c;
  --brass-lo: #8a6a35;
  --teal: #2a9d8f;
  --teal-hi: #57c7b6;
  --red: #e0574a;
  --radius: 14px;
  --ui: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 2px 0 rgba(255, 240, 210, 0.04) inset;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d0b0a; color: var(--ink); font-family: var(--ui); }
body { overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }

#safe-probe { position: fixed; visibility: hidden; pointer-events: none; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

/* ---------- Room background ---------- */
#room {
  position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 50% 50%, rgba(120, 82, 46, 0.32), transparent 70%),
    radial-gradient(ellipse 120% 90% at 50% 50%, #1e1712 0%, #110d0b 55%, #070605 100%);
}
#room::after {
  content: ''; position: absolute; inset: 0; opacity: 0.35; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}
.lamp { position: absolute; width: 30vmax; height: 30vmax; border-radius: 50%; background: radial-gradient(circle, rgba(255, 210, 150, 0.10), transparent 65%); transform: translate(-50%, -50%); top: 50%; }
.lamp.l1 { left: 25%; } .lamp.l2 { left: 50%; } .lamp.l3 { left: 75%; }
body.portrait .lamp { left: 50%; } body.portrait .lamp.l1 { top: 25%; } body.portrait .lamp.l3 { top: 75%; }

canvas#gl, canvas#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
canvas#fx { pointer-events: none; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; transition: opacity 0.4s; }
body.is-menu #hud, body.is-demo #hud { opacity: 0; }
body.is-menu #hud *, body.is-demo #hud * { pointer-events: none !important; }

.topbar {
  position: absolute; left: 0; right: 0; top: 0;
  padding: calc(env(safe-area-inset-top) + 10px) calc(var(--sr, env(safe-area-inset-right)) + 14px) 0 calc(var(--sl, env(safe-area-inset-left)) + 14px);
  display: grid; grid-template-columns: 1fr auto 1fr auto; align-items: center; gap: 12px;
}
.player {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 7px 14px 7px 7px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(36, 31, 27, 0.92), rgba(22, 19, 17, 0.92));
  border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  justify-self: start; max-width: 100%;
  transition: border-color 0.35s, box-shadow 0.35s, transform 0.35s;
}
.player.right { justify-self: end; padding: 7px 7px 7px 14px; }
.player.active { border-color: rgba(240, 215, 156, 0.55); box-shadow: 0 0 0 1px rgba(240, 215, 156, 0.18), 0 8px 28px rgba(211, 173, 104, 0.18); }
.avatar {
  position: relative; flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 18px;
  background: radial-gradient(circle at 35% 30%, #3d6f69, #173733 70%); color: #eaf6f2;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 2px 6px rgba(0, 0, 0, 0.4);
}
.avatar.cpu { background: radial-gradient(circle at 35% 30%, #4a4038, #221d19 70%); }
.cpu-icon { width: 20px; height: 20px; fill: none; stroke: var(--brass-hi); stroke-width: 1.6; stroke-linecap: round; }
.turn-ring { position: absolute; inset: -2px; width: 44px; height: 44px; transform: rotate(-90deg); opacity: 0; transition: opacity 0.3s; }
.turn-ring circle { fill: none; stroke: var(--brass-hi); stroke-width: 2; stroke-dasharray: 126; stroke-dashoffset: 0; stroke-linecap: round; }
.player.active .turn-ring { opacity: 1; animation: ringPulse 2.2s ease-in-out infinite; }
@keyframes ringPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.pinfo { min-width: 0; }
.player.right .pinfo { text-align: right; }
.pname { font-weight: 700; font-size: 14px; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pname small { font-weight: 600; color: var(--ink-faint); font-size: 11px; margin-left: 4px; }
.prack { display: flex; gap: 3px; margin-top: 4px; height: 16px; align-items: center; }
.player.right .prack { justify-content: flex-end; }
.prack .mb { width: 16px; height: 16px; border-radius: 50%; background-size: cover; flex: none; transition: transform 0.35s cubic-bezier(.3,1.6,.5,1), opacity 0.4s, filter 0.4s; }
.prack .mb.empty { background: rgba(255, 255, 255, 0.07); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5); }
.prack .mb.gone { opacity: 0.18; filter: grayscale(1); transform: scale(0.72); }
.prack .mb.pop { animation: pop 0.55s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.5); filter: brightness(1.6); } 100% { transform: scale(0.72); } }
.prack .mb.eight { box-shadow: 0 0 0 1px rgba(240, 215, 156, 0.5); }

.status { text-align: center; min-width: 0; padding: 0 6px; }
.status-main { font-family: var(--display); font-weight: 600; font-size: 19px; letter-spacing: 0.01em; white-space: nowrap; }
.status-sub { font-size: 11.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--brass-hi); margin-top: 2px; white-space: nowrap; opacity: 0.9; }
.status-sub.warn { color: #ffb2a6; }

.icon-btn {
  pointer-events: auto; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); background: rgba(28, 24, 21, 0.9); color: var(--ink);
  transition: transform 0.15s, background 0.2s;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; stroke: currentColor; stroke-width: 0; }
.icon-btn.back svg { fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Banner ---------- */
.banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.9); text-align: center;
  padding: 16px 34px 15px; border-radius: 18px; opacity: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(24, 20, 17, 0.88), rgba(14, 12, 10, 0.88));
  border: 1px solid rgba(240, 215, 156, 0.22);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.22s, transform 0.35s cubic-bezier(.2,1.4,.4,1);
  max-width: min(86vw, 520px);
}
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.banner-title { font-family: var(--display); font-weight: 700; font-size: clamp(24px, 4.2vmin, 38px); letter-spacing: 0.01em; line-height: 1.1; }
.banner-sub { margin-top: 6px; font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brass-hi); }
.banner.foul { border-color: rgba(224, 87, 74, 0.5); }
.banner.foul .banner-title { color: #ffc2b8; }
.banner.good .banner-title { background: linear-gradient(180deg, var(--brass-hi), var(--brass)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Controls ---------- */
.ctrl { position: absolute; pointer-events: auto; touch-action: none; transition: opacity 0.3s, filter 0.3s; }
.ctrl.disabled { opacity: 0.32; filter: saturate(0.3); pointer-events: none; }
.ctrl-label { position: absolute; font-size: 10px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); white-space: nowrap; pointer-events: none; }

#power { width: 64px; height: 300px; }
#power .power-track {
  position: absolute; left: 50%; top: 12px; bottom: 12px; width: 16px; transform: translateX(-50%); border-radius: 10px;
  background: linear-gradient(90deg, #0a0908, #1b1714 50%, #0a0908);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(240, 215, 156, 0.12);
  overflow: hidden;
}
#power .power-fill {
  position: absolute; left: 0; right: 0; top: 0; height: 0%;
  background: linear-gradient(180deg, #2a9d8f 0%, #8fc27a 40%, #f0b44c 72%, #e0574a 100%);
  background-size: 100% var(--track-len, 276px);
  box-shadow: 0 0 14px rgba(240, 180, 76, 0.45);
}
#power .power-ticks { position: absolute; inset: 0; background: repeating-linear-gradient(180deg, transparent 0 calc(10% - 1px), rgba(255, 255, 255, 0.10) calc(10% - 1px) 10%); }
#power .power-handle {
  position: absolute; left: 50%; top: 12px; width: 50px; height: 30px; transform: translate(-50%, -50%);
  border-radius: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px;
  background: linear-gradient(180deg, #f3dca5, #c49b56 55%, #8e6a33);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 -2px 0 rgba(0, 0, 0, 0.25);
  transition: box-shadow 0.2s, transform 0.12s;
}
#power .power-handle span { width: 22px; height: 2px; border-radius: 2px; background: rgba(70, 48, 20, 0.55); }
#power.dragging .power-handle { transform: translate(-50%, -50%) scale(1.06); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.6), 0 0 0 4px rgba(240, 215, 156, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.55); }
#power .power-value {
  position: absolute; left: calc(100% + 4px); top: 12px; transform: translateY(-50%); font-family: var(--display); font-weight: 700; font-size: 18px;
  opacity: 0; transition: opacity 0.2s; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8); pointer-events: none;
}
#power.dragging .power-value { opacity: 1; }
body.hand-left #power .power-value { left: auto; right: calc(100% + 4px); }
#power .ctrl-label { left: 50%; bottom: -16px; transform: translateX(-50%); }

/* horizontal power (portrait) */
body.portrait #power { width: 300px; height: 64px; }
body.portrait #power .power-track { left: 12px; right: 12px; top: 50%; bottom: auto; width: auto; height: 16px; transform: translateY(-50%); }
body.portrait #power .power-fill { top: 0; bottom: 0; height: auto; width: 0%; right: 0; left: auto; background: linear-gradient(270deg, #2a9d8f 0%, #8fc27a 40%, #f0b44c 72%, #e0574a 100%); background-size: var(--track-len, 276px) 100%; background-position: right; }
body.portrait #power .power-ticks { background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(255, 255, 255, 0.10) calc(10% - 1px) 10%); }
body.portrait #power .power-handle { top: 50%; left: auto; width: 30px; height: 50px; flex-direction: row; }
body.portrait #power .power-handle span { width: 2px; height: 22px; }
body.portrait #power .power-value { left: auto; top: -18px; transform: translateX(-50%); }
body.portrait #power .ctrl-label { left: 50%; bottom: -12px; }
body.portrait.hand-left #power .power-fill { right: auto; left: 0; background: linear-gradient(90deg, #2a9d8f 0%, #8fc27a 40%, #f0b44c 72%, #e0574a 100%); background-size: var(--track-len, 276px) 100%; }

#fine { width: 46px; height: 210px; }
#fine .fine-wheel {
  position: absolute; inset: 0; border-radius: 12px; overflow: hidden;
  background: #0d0b0a;
  box-shadow: inset 0 0 0 1px rgba(240, 215, 156, 0.14), 0 6px 16px rgba(0, 0, 0, 0.45);
}
#fine .fine-ridges {
  position: absolute; inset: -40px 0;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.55), rgba(255,255,255,0.04) 30%, rgba(255,255,255,0.10) 50%, rgba(255,255,255,0.04) 70%, rgba(0,0,0,0.55)),
    repeating-linear-gradient(180deg, #3a322b 0 3px, #1a1613 3px 4px, #2b251f 4px 8px);
}
#fine .fine-wheel::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0.85), transparent 28%, transparent 72%, rgba(0,0,0,0.85)); pointer-events: none; }
#fine .ctrl-label { left: 50%; bottom: -16px; transform: translateX(-50%); }
body.portrait #fine { width: 210px; height: 46px; }
body.portrait #fine .fine-ridges { inset: 0 -40px; background:
    linear-gradient(180deg, rgba(0,0,0,0.55), rgba(255,255,255,0.04) 30%, rgba(255,255,255,0.10) 50%, rgba(255,255,255,0.04) 70%, rgba(0,0,0,0.55)),
    repeating-linear-gradient(90deg, #3a322b 0 3px, #1a1613 3px 4px, #2b251f 4px 8px); }
body.portrait #fine .fine-wheel::after { background: linear-gradient(90deg, rgba(0,0,0,0.85), transparent 28%, transparent 72%, rgba(0,0,0,0.85)); }
body.portrait #fine .ctrl-label { bottom: -14px; }

.spin-btn { width: 58px; height: 58px; border: none; background: none; padding: 0; }
.spin-ball {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #ffffff, #efe9dc 38%, #b9b1a2 80%, #8d8577);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(240, 215, 156, 0.25);
}
.spin-dot { position: absolute; width: 12px; height: 12px; border-radius: 50%; left: 50%; top: 50%; transform: translate(-50%, -50%); background: radial-gradient(circle at 35% 35%, #ff7a6c, #c3241c); box-shadow: 0 0 0 2px rgba(255,255,255,0.7), 0 1px 3px rgba(0,0,0,0.5); }
.spin-btn .ctrl-label { left: 50%; bottom: -16px; transform: translateX(-50%); }
.spin-btn.has-spin .spin-ball { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5), 0 0 0 2px var(--red); }

.spin-panel {
  position: absolute; pointer-events: none; opacity: 0; transform: scale(0.85); transition: opacity 0.2s, transform 0.25s cubic-bezier(.2,1.4,.4,1);
  padding: 18px; border-radius: 22px; background: rgba(18, 15, 13, 0.94); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.spin-panel.open { opacity: 1; transform: scale(1); pointer-events: auto; }
.spin-big {
  position: relative; width: 180px; height: 180px; border-radius: 50%; touch-action: none;
  background: radial-gradient(circle at 36% 30%, #ffffff, #efe9dc 40%, #b9b1a2 82%, #847c6f);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
.spin-cross { position: absolute; inset: 0; background: linear-gradient(90deg, transparent calc(50% - 0.5px), rgba(0,0,0,0.18) calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)), linear-gradient(180deg, transparent calc(50% - 0.5px), rgba(0,0,0,0.18) calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)); border-radius: 50%; }
.spin-limit { position: absolute; inset: 17%; border-radius: 50%; border: 1px dashed rgba(0, 0, 0, 0.22); }
.spin-big .spin-dot { width: 26px; height: 26px; }
.spin-help { font-size: 11px; color: var(--ink-faint); letter-spacing: 0.04em; }

.hint {
  position: absolute; pointer-events: none; opacity: 0; transform: translateY(6px);
  padding: 10px 14px; border-radius: 12px; max-width: 260px; font-size: 13px; font-weight: 600; line-height: 1.35;
  background: rgba(244, 234, 216, 0.95); color: #1a1512; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  transition: opacity 0.3s, transform 0.3s;
}
.hint.show { opacity: 1; transform: translateY(0); animation: hintBob 2.4s ease-in-out infinite 0.4s; }
/* Mouse players: the wheel replaces the on-screen fine-aim control; a chip shows a pinned aim. */
body.mouse-input #fine { display: none; }
.aim-lock {
  position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 6;
  display: flex; align-items: center; gap: 8px; padding: 7px 14px 7px 11px; border-radius: 999px;
  background: rgba(16, 13, 11, 0.78); border: 1px solid rgba(228, 196, 140, 0.35); color: var(--ink, #f4ead8);
  font: 600 12px/1 var(--ui); letter-spacing: 0.02em; cursor: pointer; backdrop-filter: blur(6px);
  opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.aim-lock svg { width: 15px; height: 15px; fill: none; stroke: #e4c48c; stroke-width: 2; stroke-linecap: round; }
.aim-lock b { color: #e4c48c; font-weight: 700; }
.aim-lock span { color: rgba(244, 234, 216, 0.62); font-weight: 500; }
.aim-lock.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.aim-lock:hover { border-color: rgba(228, 196, 140, 0.7); }
@keyframes hintBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* ---------- Screens ---------- */
.screen {
  position: fixed; inset: 0; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(16px, var(--sr, env(safe-area-inset-right))) max(16px, env(safe-area-inset-bottom)) max(16px, var(--sl, env(safe-area-inset-left)));
  background: radial-gradient(ellipse at center, rgba(10, 8, 7, 0.45), rgba(6, 5, 4, 0.82));
  opacity: 0; pointer-events: none; transition: opacity 0.35s;
  overflow-y: auto;
}
.screen.open { opacity: 1; pointer-events: auto; }
.screen:not(.open), .screen:not(.open) * { pointer-events: none !important; }
.screen .panel, .screen .menu-card { transform: translateY(14px) scale(0.98); transition: transform 0.45s cubic-bezier(.2,1.2,.4,1); }
.screen.open .panel, .screen.open .menu-card { transform: none; }
#menu { background: radial-gradient(ellipse at center, rgba(10, 8, 7, 0.25), rgba(6, 5, 4, 0.78)); }

.menu-card, .panel {
  width: min(420px, 100%); padding: 30px 28px 24px; border-radius: 24px;
  background: linear-gradient(180deg, rgba(30, 26, 22, 0.94), rgba(17, 14, 12, 0.96));
  border: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.panel.narrow { width: min(360px, 100%); }
.panel.wide { width: min(640px, 100%); max-height: calc(100dvh - 32px); overflow: hidden; }
.panel h2 { font-family: var(--display); font-weight: 600; font-size: 26px; margin: 0; text-align: center; }
.panel-head { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; margin-bottom: 4px; }

.logo { text-align: center; margin-bottom: 6px; }
.logo h1 {
  font-family: var(--display); font-weight: 600; font-size: clamp(40px, 9vw, 54px); line-height: 1; margin: 12px 0 8px; letter-spacing: -0.01em;
  background: linear-gradient(180deg, #fff3d6 0%, var(--brass-hi) 40%, var(--brass) 75%, #a8803f 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.5));
}
.logo h1 em { font-style: italic; font-weight: 500; }
.logo-sub { font-size: 11.5px; font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-dim); }
.logo-ball {
  width: 54px; height: 54px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 34% 28%, #5a5a5a, #121212 45%, #000 100%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6), inset 0 -4px 10px rgba(255, 255, 255, 0.05);
  position: relative;
}
.logo-ball::after { content: ''; position: absolute; width: 30%; height: 16%; left: 26%; top: 14%; border-radius: 50%; background: rgba(255, 255, 255, 0.35); filter: blur(2px); }
.logo-ball span { width: 46%; height: 46%; border-radius: 50%; background: #f7f3e9; color: #111; display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.logo-ball.spin { animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.field-label { font-size: 11px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 8px; text-align: center; }
.seg { display: flex; padding: 4px; gap: 4px; border-radius: 14px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); }
.seg button { flex: 1; border: none; background: none; padding: 10px 8px; border-radius: 10px; font-weight: 700; font-size: 14px; color: var(--ink-dim); transition: background 0.2s, color 0.2s, box-shadow 0.2s; }
.seg button.on { background: linear-gradient(180deg, #3b332b, #2a241f); color: var(--ink); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 0 1px rgba(240, 215, 156, 0.3); }
.seg.small button { padding: 7px 8px; font-size: 12px; }

.btn {
  pointer-events: auto; border: 1px solid var(--line); border-radius: 14px; padding: 13px 16px; font-weight: 700; font-size: 15px;
  background: linear-gradient(180deg, #2c2621, #1e1a17); color: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.12s, filter 0.2s, box-shadow 0.2s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.97); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary {
  border: none; color: #2a1c0a; letter-spacing: 0.01em;
  background: linear-gradient(180deg, #f6e1ad 0%, #d9b46e 48%, #b88b45 100%);
  box-shadow: 0 10px 26px rgba(211, 173, 104, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}
.btn.big { padding: 17px 18px; font-size: 17px; font-weight: 800; }
.btn.ghost { background: transparent; }
.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lang-row { display: flex; justify-content: center; gap: 6px; margin-top: 2px; }
.lang-row button { border: 1px solid transparent; background: none; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: 0.08em; color: var(--ink-faint); }
.lang-row button.on { color: var(--ink); border-color: rgba(240, 215, 156, 0.35); }

.rows { display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 2px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); font-weight: 600; font-size: 14px; }
.row > span { flex: none; }
.row .seg { flex: 0 1 auto; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 52%; height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--brass) var(--v, 50%), rgba(255, 255, 255, 0.12) var(--v, 50%)); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(180deg, #f6e1ad, #b88b45); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); border: none; }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(180deg, #f6e1ad, #b88b45); border: none; }
.toggle { width: 50px; height: 28px; border-radius: 999px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.4); position: relative; padding: 0; transition: background 0.2s; }
.toggle i { position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #8b8278; transition: transform 0.25s cubic-bezier(.3,1.4,.5,1), background 0.2s; }
.toggle.on { background: rgba(42, 157, 143, 0.45); }
.toggle.on i { transform: translateX(22px); background: #f4ead8; }

.rules-body { flex: 1; min-height: 0; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; padding-right: 4px; font-size: 14px; line-height: 1.55; color: var(--ink-dim); }
.rules-body h3 { font-family: var(--display); font-weight: 600; color: var(--ink); font-size: 18px; margin: 10px 0 6px; }
.rules-body li { margin: 6px 0; padding-left: 2px; }
.rules-body li::marker { color: var(--brass); font-weight: 800; }

.result { text-align: center; }
.result-badge { margin-top: -4px; }
.result-title { font-size: 34px !important; }
.result.win .result-title { background: linear-gradient(180deg, #fff3d6, var(--brass-hi) 45%, var(--brass)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result-reason { color: var(--brass-hi); font-size: 12px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; margin-top: -6px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0; }
.stat { padding: 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.05); }
.stat b { display: block; font-family: var(--display); font-size: 24px; font-weight: 700; color: var(--ink); }
.stat span { font-size: 10.5px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }

#loading { position: fixed; inset: 0; display: grid; place-content: center; gap: 16px; background: #0d0b0a; transition: opacity 0.5s; z-index: 10; text-align: center; }
#loading.done { opacity: 0; pointer-events: none; }
.loading-text { font-size: 12px; font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-faint); }
#fatal { z-index: 20; }
#fatal p { color: var(--ink-dim); line-height: 1.5; text-align: center; }

/* ---------- compact & portrait adjustments ---------- */
body.compact .player { padding: 5px 10px 5px 5px; gap: 8px; }
body.compact .player.right { padding: 5px 5px 5px 10px; }
body.compact .avatar { width: 32px; height: 32px; font-size: 15px; }
body.compact .turn-ring { width: 36px; height: 36px; }
body.compact .pname { font-size: 12.5px; }
body.compact .prack { gap: 2px; height: 13px; margin-top: 3px; }
body.compact .prack .mb { width: 13px; height: 13px; }
body.compact .status-main { font-size: 16px; }
body.compact .status-sub { font-size: 10px; letter-spacing: 0.1em; }
body.compact .icon-btn { width: 36px; height: 36px; }

body.portrait .topbar { grid-template-columns: 1fr 1fr auto; grid-template-rows: auto auto; row-gap: 8px; }
body.portrait .topbar .status { grid-column: 1 / -1; grid-row: 2; }
body.portrait .topbar #p0 { grid-column: 1; grid-row: 1; }
body.portrait .topbar #p1 { grid-column: 2; grid-row: 1; }
body.portrait .topbar #pauseBtn { grid-column: 3; grid-row: 1; }
body.short-land .topbar { padding-top: calc(env(safe-area-inset-top) + 5px); }
body.short-land .status-main { font-size: 15px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition-duration: 0.01ms !important; }
}
.screen, .screen * { touch-action: pan-y; }

/* ---------- Tap to start ---------- */
#splash { background: radial-gradient(ellipse at center, rgba(10, 8, 7, 0.35), rgba(6, 5, 4, 0.88)); cursor: pointer; z-index: 5; }
.splash-card { display: flex; flex-direction: column; align-items: center; gap: clamp(28px, 7vh, 64px); text-align: center; }
.splash-card .logo h1 { font-size: clamp(44px, 12.5vw, 88px); }
.logo h1 { padding: 0 0.08em; }
.splash-card .logo-ball { width: 72px; height: 72px; }
.splash-card .logo-ball span { font-size: 20px; }
.tap-start {
  border: none; background: none; display: flex; align-items: center; gap: 12px;
  font-family: var(--ui); font-weight: 800; font-size: clamp(15px, 2.4vmin, 19px); letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink);
  animation: tapPulse 1.8s ease-in-out infinite;
}
.tap-start svg { width: 30px; height: 30px; fill: none; stroke: var(--brass-hi); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; animation: tapFinger 1.3s ease-in-out infinite; filter: drop-shadow(0 0 8px rgba(240, 215, 156, 0.5)); }
@keyframes tapPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes tapFinger { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
#splash.leaving .splash-card { transform: scale(1.04); opacity: 0; transition: transform 0.5s, opacity 0.4s; }

/* ---------- Menu grid ---------- */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.menu-grid .btn { padding: 11px 10px; font-size: 14px; }

/* ---------- Practice ---------- */
.practice-bar { position: absolute; display: none; gap: 8px; pointer-events: auto; z-index: 2; }
body.is-practice .practice-bar { display: flex; }
body.is-practice #p1 { visibility: hidden; }
.pbtn { display: flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); background: rgba(22, 19, 17, 0.92); color: var(--ink); font-weight: 700; font-size: 13px; box-shadow: 0 6px 18px rgba(0,0,0,0.4); transition: transform 0.12s, border-color 0.2s, background 0.2s; }
.pbtn:active { transform: scale(0.95); }
.pbtn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pbtn.on { border-color: rgba(240, 215, 156, 0.7); background: linear-gradient(180deg, #4a3d2a, #2c241b); color: var(--brass-hi); }
body.compact .pbtn span { display: none; }
body.compact .pbtn { padding: 9px 11px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 70px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 30; pointer-events: none; width: min(92vw, 360px); }
.toast { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px; border-radius: 16px; background: linear-gradient(180deg, rgba(40, 33, 25, 0.97), rgba(22, 18, 15, 0.97)); border: 1px solid rgba(240, 215, 156, 0.45); box-shadow: 0 16px 40px rgba(0,0,0,0.5), 0 0 30px rgba(211, 173, 104, 0.15); animation: toastIn 0.5s cubic-bezier(.2,1.4,.4,1) both; }
.toast.out { animation: toastOut 0.4s ease both; }
.toast .ti { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; color: #2a1c0a; background: linear-gradient(180deg, #f6e1ad, #c49b56); box-shadow: inset 0 1px 0 rgba(255,255,255,0.6); }
.toast small { display: block; font-size: 10px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass-hi); }
.toast b { font-family: var(--display); font-size: 17px; font-weight: 600; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) scale(0.96); } }

/* ---------- Result: score + ranking form ---------- */
.result-score { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin-top: 2px; }
.result-score span { font-size: 11px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); }
.result-score b { font-family: var(--display); font-size: 32px; font-weight: 700; color: var(--brass-hi); }
.rank-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.rank-form[hidden] { display: none; }
.rank-form input { min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,0.35); color: var(--ink); font: 600 15px var(--ui); outline: none; user-select: text; -webkit-user-select: text; touch-action: manipulation; }
.rank-form input:focus { border-color: rgba(240, 215, 156, 0.5); }
.rank-form .btn { padding: 12px 14px; font-size: 13px; }
.rank-status { grid-column: 1 / -1; font-size: 12.5px; font-weight: 700; color: var(--brass-hi); min-height: 16px; text-align: center; }
.rank-status.error { color: #ffb2a6; }
.rank-form.done input, .rank-form.done .btn { display: none; }

/* ---------- Tabs, profile, ranking ---------- */
.seg.tabs { margin-bottom: 4px; }
.profile-body, .rank-list { overflow-y: auto; min-height: 0; flex: 1; touch-action: pan-y; overscroll-behavior: contain; padding-right: 2px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.ach-list { display: flex; flex-direction: column; gap: 8px; }
.ach { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: rgba(0,0,0,0.28); border: 1px solid rgba(255,255,255,0.05); }
.ach .ti { flex: none; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; background: rgba(255,255,255,0.06); color: var(--ink-faint); }
.ach.got .ti { color: #2a1c0a; background: linear-gradient(180deg, #f6e1ad, #c49b56); }
.ach b { display: block; font-size: 14px; }
.ach span { font-size: 12.5px; color: var(--ink-dim); }
.ach:not(.got) b { color: var(--ink-dim); }
.style-title { font-family: var(--display); font-size: 17px; font-weight: 600; margin: 4px 0 8px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-bottom: 14px; }
.swatch { border: 1px solid var(--line); border-radius: 14px; padding: 8px; background: rgba(0,0,0,0.25); display: flex; flex-direction: column; gap: 6px; align-items: center; text-align: center; font-size: 12px; font-weight: 700; color: var(--ink); position: relative; transition: transform 0.12s, border-color 0.2s; }
.swatch:active { transform: scale(0.96); }
.swatch .chip { width: 100%; height: 44px; border-radius: 10px; box-shadow: inset 0 2px 8px rgba(0,0,0,0.5); }
.swatch .cue-chip { width: 100%; height: 44px; border-radius: 10px; display: grid; place-items: center; background: rgba(0,0,0,0.3); }
.swatch .cue-chip i { display: block; width: 86%; height: 7px; border-radius: 4px; }
.swatch.on { border-color: rgba(240, 215, 156, 0.75); box-shadow: 0 0 0 1px rgba(240, 215, 156, 0.3); }
.swatch.locked { opacity: 0.55; }
.swatch small { font-size: 10px; font-weight: 700; color: var(--ink-faint); }
.rank-row { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; font-weight: 700; }
.rank-row:nth-child(odd) { background: rgba(0,0,0,0.22); }
.rank-row .rk { font-family: var(--display); font-size: 18px; color: var(--ink-dim); text-align: center; }
.rank-row.top1 .rk { color: #f2cf6b; } .rank-row.top2 .rk { color: #d8d8d8; } .rank-row.top3 .rk { color: #d39a5e; }
.rank-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .sc { font-family: var(--display); font-size: 17px; color: var(--brass-hi); }
.rank-row.me { outline: 1px solid rgba(240, 215, 156, 0.6); background: rgba(211, 173, 104, 0.12); }
.rank-msg { text-align: center; color: var(--ink-dim); padding: 30px 10px; font-weight: 600; }

/* ---------- Online ---------- */
.text-input { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,0.35); color: var(--ink); font: 700 16px var(--ui); outline: none; user-select: text; -webkit-user-select: text; touch-action: manipulation; }
.text-input:focus { border-color: rgba(240, 215, 156, 0.55); }
.code-input { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; font-family: var(--display); font-size: 20px; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--ink-faint); font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.room-code { text-align: center; font-family: var(--display); font-weight: 700; font-size: clamp(40px, 12vw, 54px); letter-spacing: 0.18em; padding-left: 0.18em; background: linear-gradient(180deg, #fff3d6, var(--brass-hi) 45%, var(--brass)); -webkit-background-clip: text; background-clip: text; color: transparent; user-select: text; -webkit-user-select: text; }
.lobby-share { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lobby-share .btn { font-size: 13px; padding: 11px 8px; }
.seats { display: flex; flex-direction: column; gap: 8px; }
.seat { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,0.28); border: 1px solid rgba(255,255,255,0.05); font-weight: 700; }
.seat .dot { width: 10px; height: 10px; border-radius: 50%; background: #5d554c; flex: none; }
.seat.ready .dot { background: #57c78a; box-shadow: 0 0 10px rgba(87, 199, 138, 0.6); }
.seat.off .dot { background: #c9644f; }
.seat .st { margin-left: auto; font-size: 12px; color: var(--ink-faint); font-weight: 700; }
.seat.empty { color: var(--ink-faint); font-style: italic; }
#lobbyReady.on { background: linear-gradient(180deg, #8fe0b0, #3fa36b); color: #0d2a18; }

.av-letter { display: none; }
body.is-online .av-letter { display: block; }
body.is-online .cpu-icon { display: none; }
body.is-online .avatar.cpu { background: radial-gradient(circle at 35% 30%, #6a4c86, #2b1e3a 70%); color: #f3eaff; }

/* ---------- Online, one situation at a time (data-state on the card) ---------- */
.online-card [data-show], .lobby [data-show] { display: none !important; }
#onCard[data-state="start"] [data-show~="start"], #onCard[data-state="code"] [data-show~="code"],
#onCard[data-state="busy"] [data-show~="busy"], #onCard[data-state="expired"] [data-show~="expired"],
#onCard[data-state="full"] [data-show~="full"], #onCard[data-state="offline"] [data-show~="offline"],
#onCard[data-state="guest"] [data-show~="guest"], #onCard[data-state="name"] [data-show~="name"], #onCard[data-state="resume"] [data-show~="resume"],
#lobbyCard[data-state="waiting"] [data-show~="waiting"], #lobbyCard[data-state="countdown"] [data-show~="countdown"] { display: flex !important; }
.on-block { flex-direction: column; gap: 12px; }
.on-sub { margin: 0; text-align: center; color: var(--ink-dim); font-size: 14px; line-height: 1.45; text-wrap: balance; }
.on-icon { display: grid; place-items: center; }
.on-icon svg { width: 40px; height: 40px; fill: none; stroke: var(--brass-hi); stroke-width: 1.6; stroke-linecap: round; }
.on-error { padding: 10px 12px; border-radius: 12px; background: rgba(201, 100, 79, 0.14); border: 1px solid rgba(201, 100, 79, 0.4); color: #ffcabf; font-size: 13px; font-weight: 600; line-height: 1.4; text-align: center; }
.on-busy { align-items: center; padding: 18px 0 10px; }
.on-busy p { margin: 0; color: var(--ink-dim); font-weight: 600; text-align: center; }
.as-line { text-align: center; font-size: 13.5px; color: var(--ink-dim); }
.as-line b { color: var(--ink); }
.as-line.small { font-size: 12.5px; }
.link-btn { border: none; background: none; padding: 6px 4px; color: var(--brass-hi); font: 700 inherit var(--ui); font-size: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(240, 215, 156, 0.35); cursor: pointer; min-height: 32px; }
.link-btn.center { align-self: center; font-size: 14px; min-height: 44px; }
.name-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.name-row[hidden] { display: none; }
.name-row .btn { padding: 12px 16px; }
.choice {
  display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 14px; text-align: left;
  padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); color: var(--ink);
  background: linear-gradient(180deg, #2c2621, #1e1a17); min-height: 76px; cursor: pointer;
  transition: transform 0.12s, filter 0.2s, border-color 0.2s;
}
.choice:hover { filter: brightness(1.1); border-color: rgba(240, 215, 156, 0.35); }
.choice:active { transform: scale(0.98); }
.choice:disabled { opacity: 0.5; pointer-events: none; }
.choice-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: rgba(240, 215, 156, 0.1); }
.choice-icon svg { width: 26px; height: 26px; fill: none; stroke: var(--brass-hi); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.choice-text { display: flex; flex-direction: column; gap: 3px; }
.choice-text b { font-size: 16.5px; font-weight: 800; }
.choice-text small { font-size: 12.5px; color: var(--ink-dim); font-weight: 600; }
.choice.primary { border: none; color: #2a1c0a; background: linear-gradient(180deg, #f6e1ad 0%, #d9b46e 48%, #b88b45 100%); box-shadow: 0 10px 26px rgba(211, 173, 104, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -2px 0 rgba(0, 0, 0, 0.18); }
.choice.primary .choice-icon { background: rgba(42, 28, 10, 0.12); }
.choice.primary .choice-icon svg { stroke: #2a1c0a; }
.choice.primary .choice-text small { color: rgba(42, 28, 10, 0.72); }
.code-input { font-size: 24px; padding: 12px 10px; }
.code-input::placeholder { color: rgba(244, 234, 216, 0.18); }
.btn.danger { background: linear-gradient(180deg, #7a2d22, #5a1f17); border-color: rgba(255, 140, 120, 0.35); color: #ffe3dc; }
/* lobby */
.lobby-code-wrap { display: flex; flex-direction: column; align-items: center; gap: 0; }
.lobby-code-wrap .field-label { margin-bottom: 2px; }
button.room-code { border: none; background-color: transparent; cursor: copy; line-height: 1.1; padding: 2px 0 2px 0.18em; }
.lobby-invite, .lobby-go { flex-direction: column; gap: 6px; align-items: stretch; }
.lobby-go { align-items: center; }
.lobby-arrived { margin: 0; font-family: var(--display); font-size: 20px; color: var(--ink); text-align: center; }
.lobby-count { font-family: var(--display); font-weight: 700; font-size: 64px; line-height: 1; color: var(--brass-hi); animation: countPop 1s ease-out infinite; }
@keyframes countPop { 0% { transform: scale(1.25); opacity: 0.4; } 25% { transform: scale(1); opacity: 1; } 100% { opacity: 0.85; } }
.lobby-tip { margin: 0; font-size: 12.5px; color: var(--ink-faint); text-align: center; line-height: 1.4; text-wrap: balance; }
.lobby-tip:empty { display: none; }
.seat.empty .dot { animation: waitPulse 1.4s ease-in-out infinite; }
@keyframes waitPulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; background: var(--brass-hi); } }
/* the panel rides up with the iPhone keyboard (visualViewport -> --kb) */
#online { padding-bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--kb, 0px)); transition: padding-bottom 0.2s; }
#lobby { padding-bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--kb, 0px)); transition: padding-bottom 0.2s; }
@media (max-height: 520px) {
  .online-card, .lobby { padding: 18px 20px 16px; gap: 10px; }
  .choice { min-height: 60px; padding: 10px 14px; }
  .lobby .room-code { font-size: 38px; }
  .lobby-count { font-size: 44px; }
}
.online-card, .lobby { max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.toast.plain { padding: 12px 16px; justify-content: center; text-align: center; }
.toast.plain b { font-family: var(--ui); font-size: 14px; font-weight: 700; }
.result-note { margin: -4px 0 0; text-align: center; font-size: 13.5px; font-weight: 700; color: #ffcabf; }
.result-note:empty { display: none; }
.ti svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Photosensitivity notice before "tap to start" (plain text, not a card) */
.photo-warn { margin-top: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 320px; text-align: center; }
.photo-warn p { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--ink-dim); text-wrap: balance; }
.photo-btn { border: 1px solid var(--line); background: rgba(0,0,0,0.3); color: var(--ink); border-radius: 999px; padding: 10px 16px; min-height: 44px; font: 700 13px var(--ui); cursor: pointer; }
.photo-btn.on { border-color: rgba(240, 215, 156, 0.6); color: var(--brass-hi); }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation: none !important; transition-duration: 0.01ms !important; }
.on-block p[data-show], .lobby p[data-show] { justify-content: center; text-align: center; }

/* ---------- Settings tabs ---------- */
.set-tabs { margin-bottom: 2px; }
#setRows .row { display: none; }
#setRows[data-tab="sound"] .row[data-tab="sound"], #setRows[data-tab="game"] .row[data-tab="game"], #setRows[data-tab="display"] .row[data-tab="display"] { display: flex; }
#setRows .row:last-child { border-bottom: none; }
@media (max-width: 420px) {
  .row { flex-wrap: wrap; row-gap: 8px; }
  .row > .seg { flex: 1 1 100%; }
  .row > input[type=range] { flex: 1 1 120px; min-width: 0; }
}

/* ---------- Short screens (phones lying down, portal iframes): no scrolling, use columns ---------- */
@media (max-height: 560px) and (min-aspect-ratio: 5/4) {
  .menu-card { width: min(780px, 100%); display: grid; grid-template-columns: 1fr 1.15fr; column-gap: 26px; row-gap: 8px; padding: 18px 22px; align-items: center; }
  .menu-card > .logo { grid-column: 1; grid-row: 1 / span 5; margin: 0; }
  .menu-card > .lang-row { grid-column: 1; grid-row: 6; }
  .menu-card > :not(.logo):not(.lang-row) { grid-column: 2; }
  .menu-card .logo h1 { font-size: clamp(34px, 6vw, 50px); }
  .menu-card .btn { padding: 9px 12px; }
  .menu-card .btn.big { padding: 12px 14px; font-size: 15px; }
  .menu-grid .btn { padding: 8px 10px; }
  #pause .panel { width: min(560px, 100%); display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 18px 22px; }
  #pause .panel > h2, #pause .panel > #pauseNote { grid-column: 1 / -1; }
  #pause .panel > #resumeBtn { grid-column: 1 / -1; }
  .result { width: min(720px, 100%) !important; display: grid; grid-template-columns: 1fr 1fr; column-gap: 22px; row-gap: 8px; padding: 18px 22px; align-content: center; }
  .result > .result-badge, .result > .result-title, .result > .result-reason, .result > .result-note, .result > .result-score { grid-column: 1; }
  .result > .stats, .result > .rank-form, .result > #rematchBtn, .result > #menuBtn { grid-column: 2; }
  .result > .result-badge { grid-row: 1; } .result > .result-title { grid-row: 2; } .result > .result-reason { grid-row: 3; }
  .result > .result-note { grid-row: 4; } .result > .result-score { grid-row: 5; }
  .result > .stats { grid-row: 1 / span 3; margin: 0; } .result > .rank-form { grid-row: 4; } .result > #rematchBtn { grid-row: 5; } .result > #menuBtn { grid-row: 6; }
  .result .stat { padding: 7px; } .result .stat b { font-size: 20px; }
  .result .btn.big { padding: 12px 14px; }
  .splash-card { gap: 14px; }
  .splash-card .logo-ball { width: 46px; height: 46px; }
  .splash-card .logo h1 { font-size: clamp(36px, 7vw, 56px); margin: 6px 0 4px; }
  .photo-warn { margin-top: 0; gap: 6px; }
  .photo-warn p { font-size: 11.5px; }
  .photo-btn { min-height: 38px; padding: 7px 14px; }
  .panel:not(.narrow):not(.wide) { max-height: calc(100dvh - 24px); padding: 16px 22px; gap: 8px; }
  .row { padding: 6px 2px; }
}
/* Small portrait phones (iPhone SE 1st gen, 360x640 Androids) */
@media (max-height: 700px) and (max-aspect-ratio: 4/5) {
  .menu-card { padding: 18px 18px 14px; gap: 9px; }
  .menu-card .logo { margin-bottom: 0; }
  .menu-card .logo-ball { width: 40px; height: 40px; }
  .menu-card .logo h1 { font-size: 38px; margin: 6px 0 4px; }
  .menu-card .btn { padding: 10px 12px; }
  .menu-card .btn.big { padding: 13px 14px; font-size: 16px; }
  .menu-grid .btn { padding: 8px 8px; }
  .result { padding: 18px 18px 14px; gap: 9px; }
  .result .logo-ball { width: 40px; height: 40px; }
  .result-title { font-size: 28px !important; }
  .result .stat { padding: 7px; } .result .stat b { font-size: 20px; }
  .result .btn.big { padding: 13px 14px; }
  .splash-card .photo-warn p { text-shadow: 0 1px 6px rgba(0,0,0,0.9); }
}
.photo-warn p { text-shadow: 0 1px 8px rgba(0,0,0,0.85); }

/* =====================================================================================
   THEME: Clube claro. Ivory panels, near-black ink, felt green and brass accents.
   The table is the only dark area on screen. (Overrides the original dark styling above.)
   ===================================================================================== */
:root {
  --paper: #f4eee3; --paper-hi: #fbf8f2; --paper-lo: #e8dfcf;
  --ink: #221c17; --ink-dim: rgba(34, 28, 23, 0.7); --ink-faint: rgba(34, 28, 23, 0.5);
  --line: rgba(70, 52, 34, 0.16);
  --felt: #1e6b5f; --felt-hi: #2a8a7b; --felt-lo: #154d45;
  --brass: #b8893f; --brass-hi: #8a6424; --brass-lo: #6e4f1c; --brass-glow: #e2c27f;
  --red: #b5402f;
  --shadow: 0 24px 60px rgba(70, 50, 25, 0.22), 0 2px 6px rgba(70, 50, 25, 0.08);
}
html, body { background: var(--paper); color: var(--ink); }
#room {
  background:
    radial-gradient(ellipse 70% 55% at 50% 50%, rgba(255, 250, 240, 0.9), transparent 72%),
    radial-gradient(ellipse 120% 95% at 50% 50%, #f3ece0 0%, #e7dcc8 58%, #d4c3a6 100%);
}
#room::after { opacity: 0.18; mix-blend-mode: multiply; }
.lamp { background: radial-gradient(circle, rgba(255, 244, 222, 0.55), transparent 65%); }

/* HUD */
.player { background: rgba(251, 248, 242, 0.94); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(70, 50, 25, 0.14); }
.player.active { border-color: rgba(30, 107, 95, 0.55); box-shadow: 0 0 0 2px rgba(30, 107, 95, 0.16), 0 8px 24px rgba(30, 107, 95, 0.16); }
.avatar { background: radial-gradient(circle at 35% 30%, #3a8b7e, #154d45 72%); color: #f6efe2; }
.avatar.cpu { background: radial-gradient(circle at 35% 30%, #4b4540, #23201d 72%); }
.cpu-icon { stroke: var(--brass-glow); }
.turn-ring circle { stroke: var(--felt-hi); }
.pname small { color: var(--ink-faint); }
.prack .mb.empty { background: rgba(70, 52, 34, 0.1); box-shadow: inset 0 1px 2px rgba(70, 52, 34, 0.25); }
.prack .mb.eight { box-shadow: 0 0 0 1px var(--brass); }
.status-main { color: var(--ink); }
.status-sub { color: var(--brass-hi); opacity: 1; }
.status-sub.warn { color: var(--red); }
.icon-btn { background: rgba(251, 248, 242, 0.94); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 4px 12px rgba(70, 50, 25, 0.12); }
.banner { background: rgba(251, 248, 242, 0.95); border: 1px solid var(--line); box-shadow: 0 24px 60px rgba(20, 15, 10, 0.35); }
.banner-title { color: var(--ink); }
.banner-sub { color: var(--brass-hi); }
.banner.foul { border-color: rgba(181, 64, 47, 0.45); }
.banner.foul .banner-title { color: var(--red); }
.banner.good .banner-title { background: none; color: var(--felt); -webkit-text-fill-color: currentColor; }
.hint { background: rgba(251, 248, 242, 0.97); color: var(--ink); box-shadow: 0 10px 28px rgba(20, 15, 10, 0.3); border: 1px solid var(--line); }
.aim-lock { background: rgba(251, 248, 242, 0.95); border-color: var(--line); color: var(--ink); box-shadow: 0 6px 18px rgba(70, 50, 25, 0.16); }
.aim-lock svg { stroke: var(--brass-hi); }
.aim-lock b { color: var(--felt); }
.aim-lock span { color: var(--ink-dim); }
.aim-lock:hover { border-color: rgba(30, 107, 95, 0.5); }
.ctrl-label { color: var(--ink-faint); }

/* power bar */
#power .power-track { background: linear-gradient(90deg, #ddd2bf, #f2ebdf 50%, #ddd2bf); box-shadow: inset 0 2px 5px rgba(70, 50, 25, 0.28), 0 0 0 1px rgba(70, 52, 34, 0.16); }
body.portrait #power .power-track { background: linear-gradient(180deg, #ddd2bf, #f2ebdf 50%, #ddd2bf); }
#power .power-fill { background: linear-gradient(180deg, #2a8a7b 0%, #7fb26b 40%, #e0a63e 72%, #c4473a 100%); background-size: 100% var(--track-len, 276px); box-shadow: none; }
body.portrait #power .power-fill { background: linear-gradient(270deg, #2a8a7b 0%, #7fb26b 40%, #e0a63e 72%, #c4473a 100%); background-size: var(--track-len, 276px) 100%; background-position: right; }
body.portrait.hand-left #power .power-fill { background: linear-gradient(90deg, #2a8a7b 0%, #7fb26b 40%, #e0a63e 72%, #c4473a 100%); background-size: var(--track-len, 276px) 100%; }
#power .power-ticks { background: repeating-linear-gradient(180deg, transparent 0 calc(10% - 1px), rgba(70, 52, 34, 0.14) calc(10% - 1px) 10%); }
body.portrait #power .power-ticks { background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(70, 52, 34, 0.14) calc(10% - 1px) 10%); }
#power .power-handle { box-shadow: 0 5px 12px rgba(70, 50, 25, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -2px 0 rgba(0, 0, 0, 0.2); }
#power .power-value { color: var(--ink); text-shadow: 0 1px 6px rgba(251, 248, 242, 0.95); }

/* fine wheel: light, translucent so the cue stays visible through it */
#fine .fine-wheel { background: rgba(244, 238, 227, 0.55); box-shadow: inset 0 0 0 1px rgba(70, 52, 34, 0.2), 0 4px 12px rgba(70, 50, 25, 0.14); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#fine .fine-ridges { background: linear-gradient(90deg, rgba(70,52,34,0.18), transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%, rgba(70,52,34,0.18)), repeating-linear-gradient(180deg, rgba(70,52,34,0.32) 0 2px, transparent 2px 7px); }
body.portrait #fine .fine-ridges { background: linear-gradient(180deg, rgba(70,52,34,0.18), transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%, rgba(70,52,34,0.18)), repeating-linear-gradient(90deg, rgba(70,52,34,0.32) 0 2px, transparent 2px 7px); }
#fine .fine-wheel::after { background: linear-gradient(180deg, rgba(244,238,227,0.9), transparent 26%, transparent 74%, rgba(244,238,227,0.9)); }
body.portrait #fine .fine-wheel::after { background: linear-gradient(90deg, rgba(244,238,227,0.9), transparent 26%, transparent 74%, rgba(244,238,227,0.9)); }
.spin-ball { box-shadow: 0 5px 14px rgba(70, 50, 25, 0.3), 0 0 0 2px rgba(184, 137, 63, 0.5); }
.spin-panel { background: rgba(251, 248, 242, 0.97); border: 1px solid var(--line); box-shadow: var(--shadow); }
.spin-big { box-shadow: 0 10px 26px rgba(70, 50, 25, 0.3); }

/* screens and panels */
.screen { background: radial-gradient(ellipse at center, rgba(244, 238, 227, 0.35), rgba(232, 223, 207, 0.72)); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
#menu { background: radial-gradient(ellipse at center, rgba(244, 238, 227, 0.2), rgba(232, 223, 207, 0.6)); }
#splash { background: radial-gradient(ellipse at center, rgba(244, 238, 227, 0.45), rgba(232, 223, 207, 0.86)); }
.menu-card, .panel { background: linear-gradient(180deg, #fdfbf6, #f3ecdf); border: 1px solid var(--line); box-shadow: var(--shadow); }
.logo h1 { background: none; -webkit-background-clip: border-box; background-clip: border-box; color: var(--ink); -webkit-text-fill-color: currentColor; filter: none; }
.logo h1 em { color: var(--felt); }
.logo-sub { color: var(--ink-dim); }
.logo-ball { box-shadow: 0 10px 22px rgba(20, 15, 10, 0.35), inset 0 -4px 10px rgba(255, 255, 255, 0.05); }
.field-label { color: var(--ink-faint); }
.seg { background: rgba(70, 52, 34, 0.07); border: 1px solid var(--line); }
.seg button { color: var(--ink-dim); }
.seg button.on { background: #fffdf8; color: var(--ink); box-shadow: 0 1px 3px rgba(70, 50, 25, 0.18), 0 0 0 1px rgba(30, 107, 95, 0.35); }
.btn { background: linear-gradient(180deg, #fffdf8, #f1e9dc); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 2px 6px rgba(70, 50, 25, 0.08); }
.btn:hover { filter: none; border-color: rgba(30, 107, 95, 0.4); }
.btn.primary { border: none; color: #fbf6ea; background: linear-gradient(180deg, #2f9585 0%, #1e6b5f 55%, #175a50 100%); box-shadow: 0 10px 24px rgba(30, 107, 95, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.25), inset 0 -2px 0 rgba(0, 0, 0, 0.2); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger { background: linear-gradient(180deg, #c4503d, #9e3626); border-color: transparent; color: #fff6f2; }
.lang-row button { color: var(--ink-faint); }
.lang-row button.on { color: var(--ink); border-color: rgba(30, 107, 95, 0.45); }
.row { border-bottom: 1px solid rgba(70, 52, 34, 0.1); }
input[type=range] { background: linear-gradient(90deg, var(--felt) var(--v, 50%), rgba(70, 52, 34, 0.16) var(--v, 50%)); }
input[type=range]::-webkit-slider-thumb { background: #fffdf8; box-shadow: 0 1px 5px rgba(70, 50, 25, 0.35), 0 0 0 2px var(--felt); }
input[type=range]::-moz-range-thumb { background: #fffdf8; box-shadow: 0 0 0 2px var(--felt); }
.toggle { background: rgba(70, 52, 34, 0.14); border: 1px solid var(--line); }
.toggle i { background: #fffdf8; box-shadow: 0 1px 4px rgba(70, 50, 25, 0.35); }
.toggle.on { background: var(--felt); }
.toggle.on i { background: #fffdf8; }
.rules-body { color: var(--ink-dim); }
.rules-body h3 { color: var(--ink); }
.rules-body li::marker { color: var(--felt); }
.result.win .result-title { background: none; color: var(--felt); -webkit-text-fill-color: currentColor; }
.result-reason { color: var(--brass-hi); }
.result-note { color: var(--red); }
.stat { background: rgba(70, 52, 34, 0.05); border: 1px solid var(--line); }
.stat b { color: var(--ink); }
.result-score b { color: var(--felt); }
#loading { background: var(--paper); }
.loading-text { color: var(--ink-faint); }
.tap-start { color: var(--ink); }
.tap-start svg { stroke: var(--felt); filter: none; }
.photo-warn p { color: var(--ink-dim); text-shadow: none; }
.photo-btn { background: #fffdf8; color: var(--ink); border: 1px solid var(--line); box-shadow: 0 2px 6px rgba(70, 50, 25, 0.1); }
.photo-btn.on { border-color: var(--felt); color: var(--felt); }
.pbtn { background: rgba(251, 248, 242, 0.95); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 4px 12px rgba(70, 50, 25, 0.14); }
.pbtn.on { background: var(--felt); color: #fbf6ea; border-color: transparent; }
.toast { background: rgba(251, 248, 242, 0.98); border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(20, 15, 10, 0.25); color: var(--ink); }
.toast small { color: var(--brass-hi); }
.toast .ti { color: #2a1c0a; background: linear-gradient(180deg, #f2d9a0, #c9a05a); }
.rank-form input, .text-input { background: #fffdf9; color: var(--ink); border: 1px solid rgba(70, 52, 34, 0.22); }
.rank-form input:focus, .text-input:focus { border-color: var(--felt); box-shadow: 0 0 0 3px rgba(30, 107, 95, 0.15); }
.rank-status { color: var(--felt); }
.rank-status.error { color: var(--red); }
.ach { background: rgba(70, 52, 34, 0.05); border: 1px solid var(--line); }
.ach .ti { background: rgba(70, 52, 34, 0.08); color: var(--ink-faint); }
.ach.got .ti { color: #2a1c0a; background: linear-gradient(180deg, #f2d9a0, #c9a05a); }
.swatch { background: #fffdf8; color: var(--ink); border: 1px solid var(--line); }
.swatch .chip { box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35); }
.swatch .cue-chip { background: rgba(70, 52, 34, 0.07); }
.swatch.on { border-color: var(--felt); box-shadow: 0 0 0 2px rgba(30, 107, 95, 0.22); }
.rank-row:nth-child(odd) { background: rgba(70, 52, 34, 0.05); }
.rank-row .rk { color: var(--ink-faint); }
.rank-row.top1 .rk { color: #b8892a; } .rank-row.top2 .rk { color: #8a8f96; } .rank-row.top3 .rk { color: #a0623a; }
.rank-row .sc { color: var(--felt); }
.rank-row.me { outline: 2px solid rgba(30, 107, 95, 0.45); background: rgba(30, 107, 95, 0.08); }
.code-input::placeholder { color: rgba(34, 28, 23, 0.2); }
.on-error { background: #fbe6df; border: 1px solid #e3ab9c; color: #8f2f1f; }
.on-icon svg { stroke: var(--brass-hi); }
.link-btn { color: var(--felt); text-decoration-color: rgba(30, 107, 95, 0.4); }
.choice { background: linear-gradient(180deg, #fffdf8, #f1e9dc); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 2px 6px rgba(70, 50, 25, 0.08); }
.choice:hover { filter: none; border-color: rgba(30, 107, 95, 0.4); }
.choice-icon { background: rgba(30, 107, 95, 0.1); }
.choice-icon svg { stroke: var(--felt); }
.choice-text small { color: var(--ink-dim); }
.choice.primary { color: #fbf6ea; background: linear-gradient(180deg, #2f9585 0%, #1e6b5f 55%, #175a50 100%); box-shadow: 0 10px 24px rgba(30, 107, 95, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.choice.primary .choice-icon { background: rgba(255, 255, 255, 0.16); }
.choice.primary .choice-icon svg { stroke: #fbf6ea; }
.choice.primary .choice-text small { color: rgba(251, 246, 234, 0.82); }
.room-code { background: none; -webkit-background-clip: border-box; background-clip: border-box; color: var(--felt-lo); -webkit-text-fill-color: currentColor; }
.lobby-arrived { color: var(--ink); }
.lobby-count { color: var(--felt); }
.seat { background: rgba(70, 52, 34, 0.05); border: 1px solid var(--line); }
.seat .dot { background: rgba(70, 52, 34, 0.3); }
.seat.ready .dot { background: var(--felt-hi); box-shadow: 0 0 8px rgba(42, 138, 123, 0.5); }
.seat.off .dot { background: var(--red); }
.seat.empty { color: var(--ink-faint); }
@keyframes waitPulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; background: var(--felt-hi); } }
.ti svg { stroke: currentColor; }
/* Portrait strip: slim controls, labels tucked inside so they take no extra height */
body.portrait #power .power-handle { width: 26px; height: 40px; border-radius: 9px; }
body.portrait #power .power-handle span { height: 16px; }
body.portrait #power .power-track { height: 12px; }
body.portrait #power .ctrl-label, body.portrait #fine .ctrl-label { left: 10px; bottom: auto; top: 50%; transform: translateY(-50%); font-size: 9px; opacity: 0.8; }
body.portrait #power .ctrl-label { top: -4px; transform: none; }
body.portrait #fine .ctrl-label { color: var(--ink-dim); }
body.portrait .spin-btn .ctrl-label { display: none; }
body.portrait #fine .fine-wheel { border-radius: 10px; }
@media (max-height: 420px) and (min-aspect-ratio: 5/4) {
  .menu-card { padding: 12px 18px; row-gap: 6px; }
  .menu-card .field-label { margin-bottom: 4px; }
  .menu-card .seg button { padding: 7px 8px; }
  .menu-card .logo-ball { width: 40px; height: 40px; }
  .menu-card .logo h1 { font-size: 40px; }
}
body:not(.portrait) #fine .ctrl-label, body:not(.portrait) #power .ctrl-label { white-space: normal; width: 64px; text-align: center; line-height: 1.25; }
/* ---- critic round 1 ---- */
:root { --ink-dim: #463f37; --ink-faint: #5e574d; }
.field-label, .stat span, .result-score span, .ctrl-label, .lang-row button { letter-spacing: 0.08em; }
.ctrl-label { font-size: 10.5px; }
/* portrait: a single control row; labels inside the controls */
body.portrait #power .ctrl-label { top: 3px; left: 50%; transform: translateX(-50%); bottom: auto; font-size: 9.5px; }
body.portrait #fine .ctrl-label { top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 9px; text-align: center; white-space: normal; width: 80%; line-height: 1.15; }
body.portrait #power .power-track { top: 60%; }
body.portrait #power .power-handle { top: 60%; }
/* portrait player pills: all seven rack balls fit */
body.portrait .avatar { width: 34px; height: 34px; font-size: 15px; }
body.portrait .turn-ring { width: 38px; height: 38px; }
body.portrait .prack { gap: 2px; height: 12px; }
body.portrait .prack .mb { width: 12px; height: 12px; }
body.portrait .player { padding: 5px 10px 5px 5px; gap: 7px; }
body.portrait .player.right { padding: 5px 5px 5px 10px; }
/* primary buttons: felt with brass stitching, no shiny gradient */
.btn.primary, .choice.primary { background: #1e5a4c radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.10), transparent 70%); position: relative; box-shadow: 0 6px 16px rgba(30, 90, 76, 0.28), inset 0 -2px 0 rgba(0, 0, 0, 0.18); }
.btn.primary::after, .choice.primary::after { content: ''; position: absolute; inset: 4px; border-radius: inherit; border: 1px dashed rgba(226, 194, 127, 0.55); pointer-events: none; }
/* sliders: brass rail, cue-ball thumb */
input[type=range] { height: 5px; background: linear-gradient(90deg, #b8913f var(--v, 50%), rgba(70, 52, 34, 0.16) var(--v, 50%)); }
input[type=range]::-webkit-slider-thumb { width: 24px; height: 24px; background: radial-gradient(circle at 35% 30%, #ffffff, #efe9dc 45%, #c5bdae 90%); box-shadow: 0 2px 6px rgba(70, 50, 25, 0.4); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; background: radial-gradient(circle at 35% 30%, #ffffff, #efe9dc 45%, #c5bdae 90%); box-shadow: 0 2px 6px rgba(70, 50, 25, 0.4); }
/* result: a club score sheet with dotted leaders instead of a 2x2 card grid */
.stats { grid-template-columns: 1fr; gap: 2px; margin: 4px 0; padding: 10px 14px; border-radius: 12px; background: #fbf7ef; border: 1px solid var(--line); }
.stat { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; background: none; border: none; border-radius: 0; }
.stat span { order: 0; font-family: var(--display); font-size: 15px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--ink-dim); }
.stat::after { content: ''; order: 1; flex: 1; border-bottom: 2px dotted rgba(70, 52, 34, 0.3); transform: translateY(-4px); }
.stat b { order: 2; font-size: 20px; display: inline; }
@media (max-height: 560px) and (min-aspect-ratio: 5/4) { .result .stat { padding: 3px 0; } .result .stat b { font-size: 17px; } .menu-card .logo h1 { font-size: 46px; } }
/* ---- critic round 2 ---- */
/* tap to start: an ivory pill, readable over the blurred table */
.tap-start { background: rgba(251, 247, 239, 0.92); color: #2a2520; border: 1px solid var(--line); border-radius: 999px; padding: 0 26px 0 18px; min-height: 48px; box-shadow: 0 8px 22px rgba(70, 50, 25, 0.18); animation: tapPulseSoft 1.8s ease-in-out infinite; }
.tap-start svg { stroke: var(--felt); width: 26px; height: 26px; }
@keyframes tapPulseSoft { 0%, 100% { opacity: 1; } 50% { opacity: 0.82; } }
/* labels sit right on their control, one line */
.ctrl-label { font-size: 10px; letter-spacing: 0.06em; white-space: nowrap; }
body:not(.portrait) #fine .ctrl-label, body:not(.portrait) #power .ctrl-label { white-space: nowrap; width: auto; font-size: 9.5px; letter-spacing: 0.04em; }
body:not(.portrait) #power .ctrl-label { top: -14px; bottom: auto; }
body:not(.portrait) #fine .ctrl-label { top: -14px; bottom: auto; }
body.portrait #fine .ctrl-label { top: -9px; transform: translateX(-50%); width: auto; white-space: nowrap; color: var(--ink-faint); font-size: 9.5px; }
body.portrait #power .ctrl-label { top: -3px; }
/* the power track reads as a rail even at rest */
#power .power-track { background: linear-gradient(90deg, #d8ccb6, #ece3d3 50%, #d8ccb6); }
body.portrait #power .power-track { background: linear-gradient(180deg, #d8ccb6, #ece3d3 50%, #d8ccb6); }
/* toggles: felt rail with brass stitch and an ivory ball */
.toggle { width: 52px; height: 30px; background: rgba(70, 52, 34, 0.14); }
.toggle i { width: 24px; height: 24px; top: 2px; left: 2px; background: radial-gradient(circle at 35% 30%, #ffffff, #efe9dc 45%, #c5bdae 90%); box-shadow: 0 1px 4px rgba(70, 50, 25, 0.4); }
.toggle.on { background: #1e5a4c; box-shadow: inset 0 0 0 3px #1e5a4c, inset 0 0 0 4px rgba(226, 194, 127, 0.5); }
.toggle.on i { transform: translateX(22px); background: radial-gradient(circle at 35% 30%, #ffffff, #efe9dc 45%, #c5bdae 90%); }
/* the CPU gets a serif monogram, like the player */
.cpu-icon { display: none !important; }
.av-letter { display: block !important; }
.avatar.cpu { background: radial-gradient(circle at 35% 30%, #4a443e, #2a2520 72%); color: #f3ead9; }
/* menu: one main action, two brass-edged secondary actions, a row of four icon buttons */
#onlineBtn, #practiceBtn { border: 1.5px solid #b8913f; background: #fffdf8; }
.menu-grid { grid-template-columns: repeat(4, 1fr); gap: 4px; }
.menu-grid .btn { flex-direction: column; gap: 5px; padding: 8px 2px 6px; background: none; border: none; box-shadow: none; font-size: 11px; font-weight: 700; line-height: 1.15; white-space: normal; text-align: center; min-height: 58px; }
.menu-grid .btn svg { width: 24px; height: 24px; padding: 10px; box-sizing: content-box; border-radius: 50%; background: rgba(30, 90, 76, 0.08); color: var(--felt); stroke-width: 1.6; }
.menu-grid .btn:hover svg { background: rgba(30, 90, 76, 0.14); }
@media (max-height: 560px) and (min-aspect-ratio: 5/4) {
  .menu-card .logo h1 { font-size: 58px; }
  .menu-card .logo-ball { width: 52px; height: 52px; }
  .menu-card > .lang-row { grid-row: auto; align-self: start; margin-top: -6px; }
  .menu-card > .logo { grid-row: 1 / span 4; align-self: end; }
  .menu-grid .btn { min-height: 50px; padding: 4px 2px; }
  .menu-grid .btn svg { padding: 7px; width: 20px; height: 20px; }
}
/* result: a brass medallion instead of repeating the black 8-ball */
.result .logo-ball { background: radial-gradient(circle at 35% 28%, #f6e2ae, #d0a95c 45%, #9b7533 100%); box-shadow: 0 8px 18px rgba(110, 79, 28, 0.35), inset 0 0 0 3px rgba(255, 245, 220, 0.35), inset 0 0 0 5px rgba(110, 79, 28, 0.25); }
.result .logo-ball::after { display: none; }
.result .logo-ball span { background: none; color: #4a3514; font-family: var(--display); font-size: 22px; text-shadow: 0 1px 0 rgba(255, 245, 220, 0.6); }
/* panels arrive after their backdrop: text never shows without the panel behind it */
.screen .panel, .screen .menu-card { opacity: 0; transition: transform 0.3s cubic-bezier(.2,1.2,.4,1) 0.12s, opacity 0.2s ease 0.12s; }
.screen.open .panel, .screen.open .menu-card { opacity: 1; }
body:not(.portrait) #fine .ctrl-label { top: auto; bottom: -15px; }
#hint { font-size: 12.5px; }
/* ---- critic round 3 ---- */
/* online: same brass-edged secondary as the menu, icons without the tinted square */
.choice:not(.primary) { border: 1.5px solid #b8913f; background: #fffdf8; }
.choice-icon, .choice.primary .choice-icon { background: none; width: 36px; height: 36px; }
.choice { grid-template-columns: 36px 1fr; }
.choice-icon svg { width: 28px; height: 28px; }
#menuBtn, #quitBtn { border: 1.5px solid #b8913f; background: #fffdf8; }
/* splash language picker readable over the blurred table */
#splashLang { background: rgba(251, 247, 239, 0.92); border-radius: 999px; padding: 4px; border: 1px solid var(--line); box-shadow: 0 6px 16px rgba(70, 50, 25, 0.14); }
#splashLang button { color: #2a2520; }
#splashLang button.on { border-color: var(--felt); color: var(--felt); }
/* portrait strip labels on one baseline, left-aligned with their control */
body.portrait #power .ctrl-label { top: -12px; left: 2px; transform: none; }
body.portrait #fine .ctrl-label { top: -17px; left: 2px; transform: none; }
body.portrait.hand-left #power .ctrl-label, body.portrait.hand-left #fine .ctrl-label { left: auto; right: 2px; }
body.portrait #power .power-track, body.portrait #power .power-handle { top: 50%; }
/* which way to pull: a brass chevron engraved mid-track */
#power::before { content: ''; position: absolute; z-index: 1; left: 50%; top: 50%; width: 7px; height: 7px; border-right: 2px solid #b8913f; border-bottom: 2px solid #b8913f; transform: translate(-50%, -70%) rotate(45deg); pointer-events: none; opacity: 0.9; }
body.portrait #power::before { transform: translate(-30%, -50%) rotate(135deg); }
body.portrait.hand-left #power::before { transform: translate(-70%, -50%) rotate(-45deg); }
#power.dragging::before { opacity: 0; }
/* the brass medallion is the menu emblem too; the black 8-ball stays on the splash */
.menu-card .logo-ball { width: 64px; height: 64px; background: radial-gradient(circle at 35% 28%, #f6e2ae, #d0a95c 45%, #9b7533 100%); box-shadow: 0 8px 18px rgba(110, 79, 28, 0.35), inset 0 0 0 3px rgba(255, 245, 220, 0.35), inset 0 0 0 5px rgba(110, 79, 28, 0.25); }
.menu-card .logo-ball::after { display: none; }
.menu-card .logo-ball span { background: none; color: #4a3514; font-family: var(--display); font-size: 24px; text-shadow: 0 1px 0 rgba(255, 245, 220, 0.6); }
/* ---- critic round 4 (details) ---- */
body:not(.portrait) #fine .ctrl-label { top: -15px; bottom: auto; }
.menu-grid .btn svg { background: none; box-shadow: inset 0 0 0 1.5px #b8913f; color: var(--felt); }
.menu-grid .btn:hover svg { background: rgba(184, 145, 63, 0.08); }
.as-line { color: var(--ink-faint); font-weight: 500; }
@media (max-height: 560px) and (min-aspect-ratio: 5/4) {
  .menu-card > .logo { grid-row: 1 / span 4; align-self: end; }
  .menu-card > .lang-row { grid-column: 1; grid-row: 5 / span 2; align-self: start; justify-self: center; margin-top: 18px; }
}
#splash.leaving { opacity: 0; transition: opacity 0.15s ease; }

/* ---------- Fullscreen toggle (Android and desktop only; small, under the pause button) ---------- */
#fsBtn { position: absolute; z-index: 5; width: 28px; height: 28px; opacity: 0.7;
  top: calc(env(safe-area-inset-top) + 10px + 42px + 8px); right: calc(var(--sr, env(safe-area-inset-right)) + 14px + 7px); }
#fsBtn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#fsBtn .fs-out { display: none; }
body.is-fs #fsBtn .fs-in { display: none; }
body.is-fs #fsBtn .fs-out { display: block; }
body.compact #fsBtn { top: calc(env(safe-area-inset-top) + 10px + 36px + 8px); right: calc(var(--sr, env(safe-area-inset-right)) + 14px + 4px); }
body.short-land #fsBtn { top: calc(env(safe-area-inset-top) + 5px + 36px + 6px); }
body.is-menu #fsBtn, body.is-demo #fsBtn { display: none; }
#fsBtn[hidden] { display: none; }
#setRows .row[hidden] { display: none !important; }
