/* ═══════════════════════════════════════════════════════════
   Chess-Pong Online — tokens follow ../css/main.css
   gold = chess, teal = pong, red = danger
   ═══════════════════════════════════════════════════════════ */
:root {
  --bg:           #0d0d0d;
  --bg-2:         #121212;
  --bg-card:      rgba(24,24,24,.72);
  --border:       rgba(255,255,255,.08);
  --border-hover: rgba(255,255,255,.18);
  --text:         #e8e8e8;
  --text-muted:   #8a8a8a;
  --text-dim:     #555;
  --accent:       #c9a84c;
  --accent-hi:    #f2d27a;
  --accent-glow:  rgba(201,168,76,.35);
  --accent-2:     #4ca8c9;
  --accent-2-glow: rgba(76,168,201,.35);
  --danger:       #e05c5c;
  --ok:           #5ce07c;
  --font-display: 'Bebas Neue', Impact, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --r-sm: 6px; --r-md: 12px; --r-lg: 20px;
  --t: .22s cubic-bezier(.2,.8,.2,1);
  --hud-h: 64px;
  --bar-h: 54px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input { font: inherit; }
[hidden] { display: none !important; }
a { color: inherit; }

/* ── Background (same mood as the site hero) ───────────────── */
.bg-fx { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.bg-fx__glow {
  position: absolute; inset: -20%;
  background:
    radial-gradient(ellipse 50% 40% at 20% 30%, rgba(76,168,201,.16), transparent 60%),
    radial-gradient(ellipse 45% 40% at 80% 70%, rgba(201,168,76,.13), transparent 60%),
    radial-gradient(ellipse 30% 25% at 70% 15%, rgba(224,92,92,.07), transparent 60%),
    linear-gradient(168deg, var(--bg-2) 0%, var(--bg) 45%, #0a1622 100%);
  animation: drift 22s ease-in-out infinite alternate;
}
.bg-fx__grain {
  position: absolute; inset: 0; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px;
}
body.party .bg-fx__glow { animation: drift 22s ease-in-out infinite alternate, partyHue 3s linear infinite; }
@keyframes drift { to { transform: translate3d(4%, -3%, 0) scale(1.08); } }
@keyframes partyHue { to { filter: hue-rotate(360deg); } }

/* ── Screens ────────────────────────────────────────────────── */
.screen {
  position: relative; z-index: 1;
  height: 100dvh;
  display: grid; place-items: center; grid-template-columns: minmax(0, 1fr);
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow-y: auto;
  animation: screenIn .45s var(--t) both;
}
@keyframes screenIn { from { opacity: 0; transform: translateY(14px) scale(.985); } }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: clamp(1.25rem, 4vw, 2.25rem);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
  width: min(560px, 100%);
}
h2 { font-family: var(--font-display); font-weight: 400; letter-spacing: .04em; font-size: clamp(2rem, 6vw, 3rem); margin: 0 0 1rem; line-height: 1; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1.6rem; min-height: 48px;
  border-radius: var(--r-sm);
  font-weight: 700; letter-spacing: .04em;
  transition: transform var(--t), box-shadow var(--t), background var(--t), border-color var(--t), color var(--t);
  text-decoration: none; user-select: none;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn--primary { background: var(--accent); color: #000; box-shadow: 0 4px 22px rgba(201,168,76,.25); }
.btn--primary:hover { box-shadow: 0 8px 34px rgba(201,168,76,.5); background: var(--accent-hi); }
.btn--outline { border: 1px solid var(--border-hover); color: var(--text); background: rgba(0,0,0,.2); }
.btn--outline:hover { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.btn--big { font-family: var(--font-display); font-size: 1.5rem; font-weight: 400; letter-spacing: .08em; padding: .7rem 2.2rem; }

/* ── Menu ───────────────────────────────────────────────────── */
.menu { width: min(760px, 100%); display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.1rem; justify-items: start; padding-block: 1rem; }
.site-links { display: flex; flex-wrap: wrap; gap: .5rem; }
.site-links .btn { text-decoration: none; }
.rules-link { color: var(--accent); font-weight: 600; text-decoration: none; border-bottom: 1px solid transparent; }
.rules-link:hover { border-bottom-color: var(--accent); }
a.tbtn, .result__actions a.btn { text-decoration: none; color: inherit; }
.brand-valley { margin: .5rem 0 0; font-weight: 700; letter-spacing: .18em; font-size: clamp(.75rem, 2vw, .95rem); color: var(--accent); }
.brand-title {
  margin: 0; font-family: var(--font-display); font-weight: 400; line-height: .88;
  font-size: clamp(4rem, 15vw, 9.5rem); letter-spacing: .04em; color: #fff;
  text-shadow: 0 0 80px rgba(201,168,76,.25);
}
.brand-title span { display: inline-block; animation: titleIn .8s var(--t) both; }
.brand-title span:nth-child(2) { animation-delay: .08s; }
.brand-title span:nth-child(3) { animation-delay: .16s; }
.brand-title .dash { color: var(--accent-2); margin-inline: .04em; text-shadow: 0 0 30px var(--accent-2-glow); }
@keyframes titleIn { from { opacity: 0; transform: translateY(30px) rotate(-3deg); filter: blur(6px); } }
.brand-sub { margin: 0 0 .4rem; font-family: var(--font-display); font-size: clamp(1.3rem, 4vw, 2rem); letter-spacing: .06em; color: var(--text-muted); }
.brand-sub em { font-style: normal; color: var(--danger); }

.field { display: grid; gap: .3rem; }
.field span { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim); font-weight: 700; }
.field input, .join-row input {
  background: rgba(0,0,0,.35); color: var(--text);
  border: 1px solid var(--border-hover); border-radius: var(--r-sm);
  padding: .75rem 1rem; min-height: 48px; outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}
.field input:focus, .join-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.name-field { width: min(320px, 100%); }

.menu-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; width: 100%; }
.mode-card {
  position: relative; overflow: hidden; text-align: left;
  display: grid; gap: .35rem; align-content: start;
  padding: 1.4rem 1.4rem 1.5rem; min-height: 170px;
  border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--bg-card); backdrop-filter: blur(10px);
  transition: transform var(--t), border-color var(--t), box-shadow var(--t);
}
.mode-card::before {
  content: ''; position: absolute; inset: 0; opacity: .0; transition: opacity var(--t);
  background: radial-gradient(circle at 30% 0%, var(--glow, var(--accent-glow)), transparent 70%);
}
.mode-card:hover { transform: translateY(-4px) rotate(-.4deg); border-color: var(--c, var(--accent)); box-shadow: 0 16px 50px rgba(0,0,0,.45), 0 0 0 1px var(--c, var(--accent)); }
.mode-card:hover::before { opacity: 1; }
.mode-card--online { --c: var(--accent-2); --glow: var(--accent-2-glow); }
.mode-card--cpu { --c: var(--accent); }
.mode-card > * { position: relative; }
.mode-card__icon { font-size: 2rem; }
.mode-card__title { font-family: var(--font-display); font-size: 2rem; letter-spacing: .04em; line-height: 1; color: #fff; }
.mode-card__text { color: var(--text-muted); font-size: .92rem; }

.join-row { display: flex; gap: .6rem; width: min(380px, 100%); }
.join-row input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: .3em; font-weight: 700; text-align: center; }

.rule-chips { list-style: none; margin: .6rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.rule-chips li {
  font-size: .8rem; color: var(--text-muted); padding: .4rem .75rem;
  border: 1px solid var(--border); border-radius: 99px; background: rgba(0,0,0,.25);
}
.rule-chips b { color: var(--text); font-weight: 600; }

/* ── Setup ──────────────────────────────────────────────────── */
.setup { display: grid; gap: 1.2rem; }
.opt { display: grid; gap: .5rem; }
.opt__label { font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); }
.opt__label small { font-weight: 400; letter-spacing: .04em; text-transform: none; color: var(--text-dim); margin-left: .4rem; }
.seg { display: flex; flex-wrap: wrap; gap: .4rem; }
.seg button {
  flex: 1 1 auto; min-height: 46px; padding: .55rem .9rem;
  border-radius: var(--r-sm); border: 1px solid var(--border-hover); background: rgba(0,0,0,.3);
  font-weight: 600; transition: all var(--t);
}
.seg button:hover { border-color: var(--accent); }
.seg button.on { background: var(--accent); color: #000; border-color: var(--accent); box-shadow: 0 0 22px var(--accent-glow); }
.setup__actions { display: flex; justify-content: space-between; gap: .8rem; margin-top: .4rem; flex-wrap: wrap; }

/* ── Lobby ──────────────────────────────────────────────────── */
.lobby { text-align: center; display: grid; gap: 1rem; justify-items: center; }
.lobby__eyebrow { margin: 0; font-size: .78rem; letter-spacing: .2em; text-transform: uppercase; color: var(--accent-2); font-weight: 700; }
.lobby__code {
  font-family: var(--font-display); font-size: clamp(4rem, 18vw, 7rem); letter-spacing: .18em; line-height: 1;
  color: #fff; text-shadow: 0 0 40px var(--accent-2-glow), 0 0 2px #fff; padding-left: .18em;
}
.lobby__share { display: flex; gap: .5rem; width: 100%; flex-wrap: wrap; justify-content: center; }
.lobby__share input { flex: 1 1 220px; min-width: 0; background: rgba(0,0,0,.35); color: var(--text-muted); border: 1px solid var(--border-hover); border-radius: var(--r-sm); padding: .6rem .8rem; font-size: .85rem; }
.lobby__status { margin: 0; display: flex; gap: .6rem; align-items: center; color: var(--text); font-weight: 600; }
.lobby__hint { margin: 0; color: var(--text-muted); font-size: .9rem; max-width: 40ch; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-hover); border-top-color: var(--accent-2); animation: spin .8s linear infinite; display: inline-block; }
.spinner--big { width: 46px; height: 46px; border-width: 3px; margin-bottom: 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Game layout ────────────────────────────────────────────── */
.screen--game {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); place-items: stretch;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  gap: 8px; overflow: hidden;
}
.hud { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; min-height: var(--hud-h); }
.hud__mid { display: grid; justify-items: center; line-height: 1; }
.hud__set { font-size: .7rem; letter-spacing: .2em; color: var(--text-dim); font-weight: 700; }
.hud__phase { font-family: var(--font-display); font-size: clamp(1.4rem, 4vw, 2.1rem); letter-spacing: .08em; color: var(--accent-2); text-shadow: 0 0 18px var(--accent-2-glow); }
.hud__phase.is-chess { color: var(--accent); text-shadow: 0 0 18px var(--accent-glow); }
.hud__phase.is-shot { color: var(--danger); animation: wobble .6s ease-in-out infinite; }

.pcard {
  display: flex; align-items: center; gap: .6rem; min-width: 0;
  padding: .45rem .7rem; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--bg-card); backdrop-filter: blur(10px);
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.pcard--right { justify-content: flex-end; text-align: right; }
.pcard.is-me { border-color: rgba(76,168,201,.35); }
.pcard.is-turn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 28px var(--accent-glow); transform: translateY(-1px); }
.pcard__piece { font-size: 1.7rem; line-height: 1; width: 1.6rem; text-align: center; }
.pcard__piece.w { color: #fff; text-shadow: 0 0 2px #000, 0 0 12px rgba(255,255,255,.4); }
.pcard__piece.b { color: #111; text-shadow: 0 0 1px var(--accent), 0 0 1px var(--accent), 0 0 10px var(--accent-glow); }
.pcard__body { display: grid; min-width: 0; line-height: 1.15; }
.pcard__name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; }
.pcard__name .you { font-size: .62rem; letter-spacing: .14em; color: var(--accent-2); margin-left: .35rem; vertical-align: middle; }
.pcard--right .pcard__name .you { margin: 0 .35rem 0 0; }
.pcard__sets { font-size: .72rem; color: var(--text-muted); letter-spacing: .04em; }
.pcard__clock {
  margin-left: auto; font-family: var(--font-display); font-size: clamp(1.3rem, 3.6vw, 1.9rem); letter-spacing: .05em;
  padding: .1rem .55rem; border-radius: var(--r-sm); background: rgba(0,0,0,.45); border: 1px solid var(--border);
  font-variant-numeric: tabular-nums; min-width: 4.2ch; text-align: center;
}
.pcard--right .pcard__clock { margin: 0 auto 0 0; }
.pcard__clock:empty { display: none; }
.pcard.is-turn .pcard__clock { color: #000; background: var(--accent); border-color: var(--accent); }
.pcard__clock.low { color: #fff !important; background: var(--danger) !important; border-color: var(--danger) !important; animation: pulse .8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.07); } }

.stage { position: relative; min-height: 0; container-type: size; display: grid; place-items: center; }

/* PONG */
.pong-wrap {
  position: relative;
  width: min(100cqw, 160cqh); aspect-ratio: 8 / 5;
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 0 0 2px rgba(255,255,255,.08), 0 0 60px rgba(76,168,201,.18), 0 30px 80px rgba(0,0,0,.6);
  touch-action: none; user-select: none; cursor: none;
  animation: screenIn .4s var(--t) both;
}
#pong-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.crt {
  position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(255,255,255,.035) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%);
  mix-blend-mode: screen;
}
.pong-hint {
  position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%);
  font-size: clamp(.7rem, 1.8vw, .9rem); color: rgba(255,255,255,.6); letter-spacing: .06em; text-align: center;
  padding: .35rem .8rem; border-radius: 99px; background: rgba(0,0,0,.5); pointer-events: none;
  transition: opacity .6s; max-width: 92%; width: max-content; line-height: 1.35;
}
.pong-hint.gone { opacity: 0; }
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-family: var(--font-display); font-size: clamp(4rem, 22cqh, 11rem); color: #fff; line-height: 1;
  text-shadow: 0 0 40px var(--accent-2), 0 0 4px #fff;
}
.countdown span { animation: countPop .9s ease-out both; }
@keyframes countPop { from { transform: scale(2.2); opacity: 0; } 30% { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(.7); } }

/* CHESS */
.chess-wrap {
  --board: min(calc(100cqh - 44px), calc(100cqw - 230px));
  display: grid; grid-template-columns: var(--board) 210px; grid-template-rows: auto var(--board);
  gap: 8px 14px; align-content: center; justify-content: center;
  animation: screenIn .4s var(--t) both;
}
.turn-banner {
  grid-column: 1 / -1; text-align: center; font-family: var(--font-display); letter-spacing: .08em;
  font-size: clamp(1.1rem, 3vw, 1.6rem); line-height: 36px; height: 36px; color: var(--text-muted);
}
.turn-banner { display: flex; align-items: center; justify-content: center; gap: .8rem; white-space: nowrap; }
.turn-banner__text { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.turn-banner.review { color: var(--text); }
.btn--small { min-height: 32px; padding: .2rem .9rem; font-size: .85rem; font-family: var(--font-body); letter-spacing: .03em; }
.btn--small:disabled { opacity: .6; cursor: default; transform: none; }
#btn-ready:not(:disabled) { animation: pulse 1.2s ease-in-out infinite; }
.ready-count { font-variant-numeric: tabular-nums; opacity: .7; margin-left: .2rem; }
.turn-banner.mine { color: var(--accent); text-shadow: 0 0 20px var(--accent-glow); }
.turn-banner.double { color: var(--danger); text-shadow: 0 0 20px rgba(224,92,92,.5); animation: wobble .7s ease-in-out infinite; }
@keyframes wobble { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-1.5deg) scale(1.03); } 75% { transform: rotate(1.5deg) scale(1.03); } }

.board {
  position: relative; width: var(--board); height: var(--board);
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  border-radius: 8px; overflow: hidden; touch-action: none; user-select: none;
  box-shadow: 0 0 0 2px rgba(201,168,76,.35), 0 0 60px rgba(201,168,76,.12), 0 30px 80px rgba(0,0,0,.6);
  container-type: inline-size;
}
.board--active { box-shadow: 0 0 0 2px var(--accent), 0 0 70px rgba(201,168,76,.3), 0 30px 80px rgba(0,0,0,.6); }
.sq { position: relative; display: grid; place-items: center; }
.sq--light { background: #3b3528; }
.sq--dark  { background: #1b1915; }
.sq--last::before { content: ''; position: absolute; inset: 0; background: rgba(76,168,201,.28); }
.sq--prev::before { content: ''; position: absolute; inset: 0; background: rgba(201,168,76,.2); }
.sq--last.sq--light::before, .sq--last.sq--dark::before { box-shadow: inset 0 0 0 3px rgba(76,168,201,.65); }
.sq--sel::before  { content: ''; position: absolute; inset: 0; background: rgba(201,168,76,.45); }
.sq--check::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle, rgba(224,92,92,.9) 0%, rgba(224,92,92,.35) 55%, transparent 75%); animation: pulse 1s ease-in-out infinite; }
.sq--own { cursor: grab; }
.sq--dot::after { content: ''; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(201,168,76,.55); box-shadow: 0 0 12px var(--accent-glow); }
.sq--cap::after { content: ''; position: absolute; inset: 5%; border-radius: 50%; border: 4px solid rgba(201,168,76,.7); }
.sq--danger::after { background: rgba(224,92,92,.75); border-color: rgba(224,92,92,.8); box-shadow: 0 0 12px rgba(224,92,92,.6); }
.sq--kill::after { inset: 2%; border-color: var(--danger); border-width: 5px; animation: pulse .6s ease-in-out infinite; box-shadow: 0 0 20px var(--danger); }
.board--active .sq--dot, .board--active .sq--cap { cursor: pointer; }
.pc {
  position: relative; z-index: 2; font-size: 10cqw; line-height: 1; pointer-events: none;
  font-family: 'DejaVu Sans', 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'Apple Symbols', serif;
  transition: transform .08s;
}
.pc--w { color: #faf6ea; text-shadow: 0 0 1px #000, 0 1px 1px #000, 0 -1px 1px #000, 1px 0 1px #000, -1px 0 1px #000, 0 4px 10px rgba(0,0,0,.55); }
.pc--b { color: #0d0d0d; text-shadow: 0 0 1px var(--accent), 0 1px 0 rgba(201,168,76,.8), 0 -1px 0 rgba(201,168,76,.8), 1px 0 0 rgba(201,168,76,.8), -1px 0 0 rgba(201,168,76,.8), 0 4px 10px rgba(0,0,0,.6); }
.pc--drag { z-index: 10; transition: none; filter: drop-shadow(0 10px 14px rgba(0,0,0,.6)); }
.coord { position: absolute; font-size: 2.1cqw; font-weight: 700; color: rgba(255,255,255,.28); pointer-events: none; z-index: 1; }
.coord--file { right: 5%; bottom: 2%; }
.coord--rank { left: 5%; top: 2%; }
.promo-picker {
  position: absolute; inset: 0; z-index: 20; display: grid; place-content: center; grid-auto-flow: column; gap: 3cqw;
  background: rgba(0,0,0,.75); backdrop-filter: blur(4px);
}
.promo-picker p { grid-column: 1 / -1; grid-row: 1; margin: 0; text-align: center; font-family: var(--font-display); font-size: 6cqw; letter-spacing: .08em; color: var(--accent); }
.promo-picker button {
  grid-row: 2; width: 16cqw; height: 16cqw; border-radius: 12px; font-size: 11cqw; pointer-events: auto;
  background: #2a261c; border: 2px solid var(--accent); transition: transform var(--t);
}
.promo-picker button:hover { transform: scale(1.08); }

#board { grid-column: 1; grid-row: 2; }
.moves {
  grid-column: 2; grid-row: 2; overflow-y: auto; font-size: .86rem; padding: .7rem; border-radius: var(--r-md);
  background: var(--bg-card); border: 1px solid var(--border); scrollbar-width: thin;
}
.moves .set-h { font-size: .66rem; letter-spacing: .16em; color: var(--text-dim); font-weight: 700; margin: .5rem 0 .2rem; text-transform: uppercase; }
.moves .set-h:first-child { margin-top: 0; }
.moves .mv { display: flex; gap: .45rem; align-items: center; padding: .12rem .3rem; border-radius: 4px; }
.moves .mv:last-child { background: rgba(201,168,76,.12); }
.moves .mv i { font-style: normal; width: 1.1em; text-align: center; }
.moves .mv .dbl { color: var(--danger); font-weight: 700; font-size: .7rem; letter-spacing: .06em; margin-left: auto; }
.moves .empty { color: var(--text-dim); font-size: .8rem; }

/* Toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: var(--bar-h); }
.emotes, .toolbar__right { display: flex; gap: 6px; }
.emotes button, .tbtn {
  width: 46px; height: 46px; border-radius: 12px; font-size: 1.3rem; display: grid; place-items: center;
  background: var(--bg-card); border: 1px solid var(--border); transition: transform var(--t), border-color var(--t);
}
.emotes button:hover, .tbtn:hover { transform: translateY(-2px) scale(1.06); border-color: var(--accent); }
.emotes button:active, .tbtn:active { transform: scale(.92); }
.tbtn { font-size: 1.1rem; font-weight: 700; }
.tbtn--danger:hover { border-color: var(--danger); }

/* ── Overlays ───────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(5,5,5,.72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fadeIn .25s ease both; overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; } }
.result { width: min(640px, 100%); }
.overlay .panel { text-align: center; animation: popIn .45s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes popIn { from { transform: scale(.8); opacity: 0; } }

/* Banner — big transient announcements */
.banner {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; pointer-events: none; text-align: center; padding: 16px;
}
.banner .b-inner { display: grid; gap: .4rem; justify-items: center; animation: bannerIn 1.9s cubic-bezier(.2,.9,.2,1) both; }
.banner .b-title {
  font-family: var(--font-display); line-height: .9; letter-spacing: .05em;
  font-size: clamp(3.2rem, 13vw, 8.5rem); color: #fff;
  text-shadow: 0 0 40px var(--c, var(--accent)), 0 0 4px #fff, 0 6px 0 rgba(0,0,0,.4);
}
.banner .b-sub { font-weight: 700; letter-spacing: .2em; text-transform: uppercase; font-size: clamp(.8rem, 2.4vw, 1.1rem); color: var(--c, var(--accent)); background: rgba(0,0,0,.6); padding: .3rem .9rem; border-radius: 99px; }
.banner--teal { --c: var(--accent-2); }
.banner--red  { --c: var(--danger); }
@keyframes bannerIn {
  0% { opacity: 0; transform: scale(2.4) rotate(-6deg); filter: blur(10px); }
  14% { opacity: 1; transform: scale(.94) rotate(1deg); filter: blur(0); }
  22% { transform: scale(1.04) rotate(-1deg); }
  30%, 78% { opacity: 1; transform: scale(1) rotate(0); }
  100% { opacity: 0; transform: scale(.9) translateY(-30px); }
}
body.shake .screen--game { animation: shake .5s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake { 10%,90% { transform: translate(-2px, 1px); } 20%,80% { transform: translate(4px, -2px); } 30%,50%,70% { transform: translate(-7px, 3px) rotate(-.4deg); } 40%,60% { transform: translate(7px, -3px) rotate(.4deg); } }

/* SHOT TIME */
.overlay--shot {
  background:
    radial-gradient(circle at 50% 40%, rgba(201,168,76,.28), transparent 60%),
    radial-gradient(circle at 20% 80%, rgba(224,92,92,.25), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(76,168,201,.25), transparent 50%),
    rgba(5,5,5,.86);
}
.overlay--shot::before {
  content: ''; position: absolute; inset: -50%; pointer-events: none; opacity: .18;
  background: repeating-conic-gradient(from 0deg, var(--accent) 0 8deg, transparent 8deg 24deg);
  animation: spin 14s linear infinite;
}
.shot { position: relative; display: grid; justify-items: center; gap: .35rem; text-align: center; max-width: 560px; }
.shot__score { margin: 0; font-family: var(--font-display); font-size: clamp(1.6rem, 6vw, 2.6rem); letter-spacing: .2em; color: var(--accent-2); text-shadow: 0 0 20px var(--accent-2-glow); }
.shot__title {
  margin: 0; font-size: clamp(3.4rem, min(20vw, 15vh), 10rem); line-height: .85; color: #fff;
  text-shadow: 0 0 30px var(--accent), 0 0 80px var(--accent), 0 0 4px #fff;
  animation: shotTitle 1s cubic-bezier(.2,1.6,.4,1) both, neon 1.4s ease-in-out .9s infinite alternate;
}
@keyframes shotTitle { from { transform: scale(3) rotate(-12deg); opacity: 0; } }
@keyframes neon { to { text-shadow: 0 0 18px var(--danger), 0 0 60px var(--danger), 0 0 4px #fff; transform: scale(1.04) rotate(-1deg); } }
.shot__level {
  margin: 0; font-weight: 800; letter-spacing: .3em; font-size: clamp(.9rem, 3vw, 1.2rem); color: #000;
  background: var(--accent); padding: .3rem 1rem .3rem 1.3rem; border-radius: 4px; transform: rotate(-2deg);
  box-shadow: 0 0 30px var(--accent-glow);
}
.shot__glass { width: clamp(56px, min(22vw, 14vh), 130px); margin: .6rem 0 .1rem; filter: drop-shadow(0 0 20px rgba(201,168,76,.55)); animation: glassTilt 2.4s ease-in-out infinite; }
.shot__liquid { animation: fill 1.4s cubic-bezier(.3,.8,.3,1) .3s both; }
@keyframes fill { from { transform: translateY(130px); } }
@keyframes glassTilt { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg) translateY(-4px); } }
.bubble { fill: rgba(255,255,255,.7); animation: bubble 1.6s ease-in infinite; }
.bubble.b2 { animation-delay: .5s; } .bubble.b3 { animation-delay: 1s; }
@keyframes bubble { from { transform: translateY(0); opacity: 0; } 20% { opacity: 1; } to { transform: translateY(-90px); opacity: 0; } }
.shot__line { margin: 0; color: var(--text); font-size: clamp(1rem, 3vw, 1.2rem); font-style: italic; }
.shot__btn { margin-top: .5rem; font-size: 2rem; padding: .6rem 3rem; animation: pulse 1.2s ease-in-out infinite; }
.shot__btn:disabled { animation: none; opacity: .5; cursor: default; transform: none; }
.shot__status { margin: 0; min-height: 1.5em; color: var(--accent-2); font-weight: 600; }
.shot__count { margin: 0; color: var(--text-muted); font-size: .85rem; letter-spacing: .08em; }
.shot__note { margin: .6rem 0 0; color: var(--text-dim); font-size: .75rem; max-width: 40ch; }

/* Result */
.result { display: grid; gap: .6rem; justify-items: center; }
.result__reason { margin: 0; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--accent-2); font-size: .85rem; }
.result__title { margin: 0; font-size: clamp(3.4rem, 14vw, 7rem); white-space: nowrap; line-height: .9; color: #fff; text-shadow: 0 0 50px var(--accent); }
.result.lose .result__title { text-shadow: 0 0 50px var(--danger); }
.result__stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: .5rem; width: 100%; margin: .6rem 0; }
.stat { padding: .7rem; border-radius: var(--r-md); background: rgba(0,0,0,.35); border: 1px solid var(--border); }
.stat b { display: block; font-family: var(--font-display); font-size: 2rem; font-weight: 400; line-height: 1; color: var(--accent); }
.stat span { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }
.result__actions, .conn__actions { display: flex; gap: .7rem; flex-wrap: wrap; justify-content: center; }
.result__status { margin: 0; min-height: 1.4em; color: var(--accent-2); font-size: .9rem; }
.conn p { color: var(--text-muted); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 24px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #1c1c1c; border: 1px solid var(--border-hover); border-radius: 99px;
  padding: .7rem 1.2rem; font-weight: 600; box-shadow: 0 10px 40px rgba(0,0,0,.5);
  transition: opacity var(--t), transform var(--t); display: flex; gap: .7rem; align-items: center; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { padding: .35rem .8rem; border-radius: 99px; background: var(--accent); color: #000; font-weight: 700; }
.toast button.no { background: transparent; border: 1px solid var(--border-hover); color: var(--text); }

/* Emotes */
.emote-layer { position: fixed; inset: 0; z-index: 45; pointer-events: none; overflow: hidden; }
.emote-fly { position: absolute; bottom: 60px; font-size: clamp(2.5rem, 8vw, 4rem); animation: fly 2.4s cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes fly {
  0% { transform: translateY(0) scale(.4) rotate(0); opacity: 0; }
  12% { opacity: 1; transform: translateY(-40px) scale(1.25) rotate(-10deg); }
  100% { transform: translateY(-70vh) scale(1) rotate(20deg); opacity: 0; }
}
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 70; pointer-events: none; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 760px) {
  .chess-wrap {
    --board: min(100cqw, calc(100cqh - 44px - 74px));
    grid-template-columns: var(--board); grid-template-rows: auto var(--board) 66px;
  }
  .moves { scrollbar-width: none; }
  .moves::-webkit-scrollbar { display: none; }
  .moves { grid-column: 1; grid-row: 3; display: flex; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; gap: .3rem; padding: .45rem; align-items: center; }
  .moves .set-h { margin: 0 .2rem; white-space: nowrap; }
  .moves .mv { white-space: nowrap; }
  .moves .mv .dbl { margin-left: 0; }
}
@media (max-width: 600px) {
  .menu-cards { grid-template-columns: 1fr; }
  .mode-card { min-height: 0; }
  :root { --hud-h: 54px; --bar-h: 48px; }
  .pcard { padding: .35rem .45rem; gap: .35rem; }
  .pcard__piece { font-size: 1.3rem; width: 1.2rem; }
  .pcard__name { font-size: .8rem; }
  .pcard__name .you { display: none; }
  .pcard.is-me .pcard__name { color: var(--accent-2); }
  .pcard__sets { font-size: .62rem; white-space: nowrap; }
  .hud { gap: 6px; }
  .emotes button, .tbtn { width: 40px; height: 40px; font-size: 1.1rem; }
  .emotes { gap: 4px; }
  .toolbar__right { gap: 4px; }
}
@media (max-width: 420px) {
  .emotes button:nth-child(n+4) { display: none; }
}
/* Phone held sideways — maximise the table */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --hud-h: 44px; --bar-h: 40px; }
  .screen--game { grid-template-rows: auto 1fr auto; gap: 4px; }
  .pcard { padding: .2rem .5rem; }
  .pcard__sets { display: none; }
  .emotes button, .tbtn { width: 36px; height: 36px; font-size: 1rem; }
  .chess-wrap { --board: min(calc(100cqh - 30px), calc(100cqw - 200px)); grid-template-columns: var(--board) 180px; grid-template-rows: 26px var(--board); }
  .turn-banner { height: 26px; line-height: 26px; font-size: 1.1rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
