:root {
  --bg: #14161c;
  --bg2: #1b1e26;
  --card: rgba(255,255,255,.045);
  --card-b: rgba(255,255,255,.08);
  --text: #eceef3;
  --muted: #9097a6;
  --accent: #e2b45c;
  --accent-2: #c8913a;
  --danger: #e0645c;
  --ok: #5fcf8a;
  --light: #ecdcbf;
  --dark: #a97e58;
  --sel: rgba(226,180,92,.55);
  --last: rgba(240,210,90,.42);
  --radius: 14px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  overflow-x: hidden;
}
.bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 600px at 15% -10%, rgba(226,180,92,.13), transparent 60%),
    radial-gradient(800px 600px at 110% 110%, rgba(110,130,220,.10), transparent 60%),
    var(--bg);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--card-b);
  background: rgba(255,255,255,.06);
  padding: 11px 16px;
  border-radius: 11px;
  font-weight: 600;
  transition: transform .08s, background .15s, border-color .15s;
}
.btn:hover { background: rgba(255,255,255,.1); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #1a1408; border-color: transparent;
  box-shadow: 0 6px 20px -8px rgba(226,180,92,.7);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: #ffb4ae; border-color: rgba(224,100,92,.35); background: rgba(224,100,92,.08); }
.btn.danger:hover { background: rgba(224,100,92,.16); }
.btn.wide { width: 100%; margin-top: 12px; padding: 13px; font-size: 16px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 8px; margin-top: 6px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  border: 1px solid var(--card-b); background: var(--card);
}

/* ---------- lobby ---------- */
.view { min-height: 100%; }
#lobby {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 16px calc(24px + env(safe-area-inset-bottom));
}
.brand { text-align: center; margin-bottom: 22px; }
.logo {
  font-size: 54px; line-height: 1; width: 84px; height: 84px; margin: 0 auto 12px;
  display: grid; place-items: center; border-radius: 24px;
  background: linear-gradient(160deg, rgba(226,180,92,.25), rgba(226,180,92,.05));
  border: 1px solid rgba(226,180,92,.3); color: var(--accent);
  box-shadow: 0 10px 40px -15px rgba(226,180,92,.6);
}
h1 { margin: 0; font-size: 30px; letter-spacing: -.02em; }
.tag { margin: 6px 0 0; color: var(--muted); }
.card {
  width: 100%; max-width: 400px; padding: 20px;
  background: var(--card); border: 1px solid var(--card-b); border-radius: 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 60px -30px rgba(0,0,0,.8);
}
.field span, .label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
.field input, .join input {
  width: 100%; padding: 12px 14px; border-radius: 11px;
  border: 1px solid var(--card-b); background: rgba(0,0,0,.25); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .join input:focus { border-color: rgba(226,180,92,.6); box-shadow: 0 0 0 3px rgba(226,180,92,.15); }
.block { margin-top: 18px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px; background: rgba(0,0,0,.25); border-radius: 12px; border: 1px solid var(--card-b); }
.seg button { border: 0; background: transparent; padding: 9px 4px; border-radius: 9px; font-weight: 600; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 7px; }
.seg button.on { background: rgba(255,255,255,.1); color: var(--text); }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1px solid rgba(255,255,255,.35); }
.dot.w { background: #f4f1ea; }
.dot.b { background: #23252b; }
.dot.r { background: linear-gradient(90deg, #f4f1ea 50%, #23252b 50%); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 20px 0 14px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--card-b); }
.join { display: flex; gap: 8px; }
.join input { text-transform: uppercase; letter-spacing: .25em; font-weight: 700; text-align: center; font-size: 18px; }
.join input::placeholder { letter-spacing: .25em; color: rgba(255,255,255,.2); }
.foot { color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ---------- game ---------- */
#game { padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.code-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--card-b); background: var(--card);
}
.code-chip strong { letter-spacing: .18em; color: var(--accent); }
.conn { margin-left: auto; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 4px rgba(255,255,255,.05); }
.conn.on { background: var(--ok); box-shadow: 0 0 0 4px rgba(95,207,138,.15); }
.conn.off { background: var(--danger); box-shadow: 0 0 0 4px rgba(224,100,92,.15); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .35; } }

.layout { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
}
.board-col { width: 100%; max-width: min(640px, calc(100svh - 170px)); min-width: 260px; margin: 0 auto; }

.player { display: flex; align-items: center; gap: 9px; padding: 8px 2px; min-height: 44px; }
.avatar { width: 28px; height: 28px; border-radius: 8px; flex: none; border: 1px solid rgba(255,255,255,.25); }
.avatar.w { background: #f4f1ea; }
.avatar.b { background: #23252b; }
.pname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.presence { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.presence.on { background: var(--ok); }
.player.turn .avatar { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.captured { margin-left: auto; font-size: 17px; letter-spacing: -2px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.captured .adv { font-size: 12px; letter-spacing: 0; margin-left: 6px; font-weight: 700; color: var(--text); }

.board-wrap { position: relative; }
.board {
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1 / 1; width: 100%;
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 24px 60px -20px rgba(0,0,0,.85);
  touch-action: none; user-select: none; -webkit-user-select: none;
  container-type: inline-size;
}
.sq { position: relative; display: grid; place-items: center; }
.sq.l { background: var(--light); }
.sq.d { background: var(--dark); }
.sq.last::before { content: ""; position: absolute; inset: 0; background: var(--last); }
.sq.sel::before { content: ""; position: absolute; inset: 0; background: var(--sel); }
.sq.check::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle, rgba(255,40,40,.85) 0%, rgba(230,30,30,.45) 45%, transparent 72%);
}
.sq .hint { position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(20,20,20,.28); z-index: 2; pointer-events: none; }
.sq .hint.cap { width: 92%; height: 92%; background: transparent; border: calc(.6cqi) solid rgba(20,20,20,.3); }
.sq .coord { position: absolute; font-size: max(9px, 1.6cqi); font-weight: 700; z-index: 1; pointer-events: none; }
.sq .coord.f { right: 4%; bottom: 2%; }
.sq .coord.r { left: 5%; top: 3%; }
.sq.l .coord { color: var(--dark); }
.sq.d .coord { color: var(--light); }
.pc {
  position: relative; z-index: 3; font-size: 9.6cqi; line-height: 1;
  cursor: grab; transition: transform .12s;
  font-family: "Segoe UI Symbol", "DejaVu Sans", "Noto Sans Symbols 2", "Apple Symbols", serif;
}
.pc.w { color: #fbf8f1; text-shadow: 0 0 1px #000, 0 0 1px #000, 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000, 0 -1px 0 #000, 0 3px 4px rgba(0,0,0,.45); }
.pc.b { color: #1d1e22; text-shadow: 0 0 1px rgba(255,255,255,.35), 0 3px 4px rgba(0,0,0,.4); }
.pc.drag { opacity: .25; }
.ghost { position: fixed; pointer-events: none; z-index: 50; transform: translate(-50%, -60%) scale(1.15); }

.promo {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(10,10,14,.55); backdrop-filter: blur(2px); border-radius: 10px;
}
.promo .choices { display: flex; gap: 8px; padding: 10px; background: var(--bg2); border: 1px solid var(--card-b); border-radius: 14px; }
.promo button { width: 13cqi; height: 13cqi; min-width: 52px; min-height: 52px; border-radius: 10px; border: 1px solid var(--card-b); background: var(--light); display: grid; place-items: center; }
.promo button .pc { font-size: 10cqi; cursor: pointer; }

.side { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 640px; margin: 0 auto; }
.status {
  padding: 14px 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--card-b);
  font-weight: 700; font-size: 16px; text-align: center;
}
.status.you { border-color: rgba(226,180,92,.5); background: rgba(226,180,92,.1); color: var(--accent); }
.status.win { border-color: rgba(95,207,138,.5); background: rgba(95,207,138,.1); color: var(--ok); }
.status.lose { border-color: rgba(224,100,92,.45); background: rgba(224,100,92,.08); color: #ffb4ae; }
.status small { display: block; font-weight: 500; font-size: 13px; color: var(--muted); margin-top: 2px; }
.offer { padding: 12px; border-radius: var(--radius); background: rgba(110,130,220,.1); border: 1px solid rgba(110,130,220,.35); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.offer span { flex: 1 1 100%; text-align: center; font-weight: 600; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .btn.primary { grid-column: 1 / -1; }
.moves-card { background: var(--card); border: 1px solid var(--card-b); border-radius: var(--radius); overflow: hidden; }
.moves-head { display: flex; justify-content: space-between; padding: 10px 14px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; border-bottom: 1px solid var(--card-b); }
.moves { list-style: none; margin: 0; padding: 6px 0; max-height: 260px; overflow-y: auto; counter-reset: mv; font-variant-numeric: tabular-nums; }
@media (max-width: 899px) { .moves { max-height: 150px; } }
.moves li { display: grid; grid-template-columns: 38px 1fr 1fr; padding: 3px 14px; font-size: 14px; }
.moves li:nth-child(odd) { background: rgba(255,255,255,.025); }
.moves li .n { color: var(--muted); }
.moves li .cur { color: var(--accent); font-weight: 700; }
.moves .empty { display: block; color: var(--muted); text-align: center; padding: 10px; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: rgba(8,9,12,.7); backdrop-filter: blur(6px);
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 380px; text-align: center; padding: 26px 20px 18px;
  background: var(--bg2); border: 1px solid var(--card-b); border-radius: 22px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.9);
  animation: pop .25s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { transform: translateY(12px) scale(.97); opacity: 0; } }
.sheet h2 { margin: 0 0 4px; font-size: 20px; }
.sheet.small h2 { margin-bottom: 18px; }
.sheet p { margin: 0; }
.big-code { font-size: 40px; font-weight: 800; letter-spacing: .22em; color: var(--accent); margin: 16px 0 18px; padding-left: .22em; user-select: all; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.row .btn { flex: 1; }
.pulse { width: 14px; height: 14px; margin: 0 auto 14px; border-radius: 50%; background: var(--accent); animation: ring 1.6s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(226,180,92,.6); } 100% { box-shadow: 0 0 0 18px rgba(226,180,92,0); } }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #2a2e38; border: 1px solid var(--card-b); padding: 10px 16px; border-radius: 12px;
  font-weight: 600; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(224,100,92,.5); }

/* ---------- hint, sound ---------- */
.foot a { color: var(--muted); }
.actions { grid-template-columns: 1fr 1fr 1fr; }
.hint-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: #9ff7ff; border-color: rgba(43,243,255,.35); background: rgba(43,243,255,.07); }
.hint-btn .count { font-size: 11px; min-width: 18px; padding: 1px 5px; border-radius: 9px; background: rgba(43,243,255,.2); }
.hint-btn.thinking svg { animation: think .8s ease-in-out infinite alternate; }
@keyframes think { to { transform: scale(1.25); filter: drop-shadow(0 0 6px #2bf3ff); } }
.sound { margin-left: auto; }
.sound + .conn { margin-left: 4px; }
.sound .off-i, .sound.muted-on .on-i { display: none; }
.sound.muted-on .off-i { display: block; }
.sound.muted-on { color: var(--muted); }
.arrow { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 8; overflow: visible; }
.arrow-line { filter: drop-shadow(0 0 .08px #2bf3ff); stroke-dasharray: 12; stroke-dashoffset: 12; animation: drawline .45s ease-out forwards; opacity: .9; }
@keyframes drawline { to { stroke-dashoffset: 0; } }
.sq.hinted::before { content: ""; position: absolute; inset: 0; background: rgba(43,243,255,.35); animation: hintpulse 1s ease-in-out infinite alternate; }
@keyframes hintpulse { from { opacity: .35; } to { opacity: .85; } }
.pc.mine { cursor: grab; }
@media (hover: hover) { .pc.mine:hover { transform: scale(1.08) translateY(-2%); } }

/* ---------- mobile first tweaks ---------- */
@media (max-width: 899px) {
  #game { padding-left: 8px; padding-right: 8px; }
  .board-col { max-width: min(640px, calc(100svh - 230px)); }
  .board { border-radius: 6px; }
  .actions .btn { padding: 12px 6px; font-size: 14px; }
  .side { gap: 10px; }
}
@media (max-width: 380px) { .code-chip .muted { display: none; } }

/* ---------- FX: 90s bowling alley ---------- */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.fx-layer > * { position: fixed; pointer-events: none; }
.fx-flash { inset: 0; mix-blend-mode: screen; }
.fx-pin { filter: drop-shadow(0 4px 4px rgba(0,0,0,.5)); }
.fx-spark { width: 9px; height: 9px; border-radius: 2px; box-shadow: 0 0 10px currentColor; }
.fx-spark.star { width: 6px; height: 6px; border-radius: 50%; box-shadow: 0 0 8px #fff6a8; }
.fx-burst { border-radius: 50%; mix-blend-mode: screen; -webkit-mask: radial-gradient(circle, #000 0 20%, transparent 70%); mask: radial-gradient(circle, #000 0 20%, transparent 70%); }
.fx-ball {
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 30%, #000 0 7%, transparent 8%),
    radial-gradient(circle at 56% 28%, #000 0 7%, transparent 8%),
    radial-gradient(circle at 46% 46%, #000 0 8%, transparent 9%),
    radial-gradient(circle at 32% 25%, #ff7ae0, #8a1fd1 45%, #2a0a4a 90%);
  box-shadow: 0 6px 14px rgba(0,0,0,.55), inset -4px -6px 12px rgba(0,0,0,.5);
}
.fx-taken { z-index: 2; }
.fx-taken.ghosty { filter: drop-shadow(0 0 8px #b84dff); }
.fx-confetti { top: 0; border-radius: 2px; }
.fx-word {
  left: 50%; top: 42%; text-align: center; white-space: nowrap;
  font-family: Impact, "Arial Black", "Helvetica Neue", system-ui, sans-serif; font-weight: 900; font-style: italic;
}
.fx-word-line { display: inline-block; transform: skewX(-10deg); line-height: 1; letter-spacing: .02em;
  font-size: min(calc(76vw / var(--len, 7) * 1.25), 110px); }
.fx-word.small .fx-word-line { font-size: min(calc(60vw / var(--len, 7) * 1.25), 70px); }
.fx-word.big .fx-word-line { font-size: min(calc(84vw / var(--len, 7) * 1.25), 130px); }
.fx-word.mega .fx-word-line { font-size: min(calc(90vw / var(--len, 7) * 1.25), 160px); }
.fx-word-line span {
  display: inline-block;
  background: linear-gradient(180deg, #fffbe0 0%, #ffe600 30%, #ff9a1a 58%, #ff2bd6 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: .045em #1a0633;
  filter: drop-shadow(.04em .04em 0 #2bf3ff) drop-shadow(.05em .06em 0 #1a0633) drop-shadow(0 .1em .15em rgba(0,0,0,.6));
  animation: letterpop .5s cubic-bezier(.2,1.6,.4,1) both, letterbob 1s ease-in-out .5s infinite alternate;
}
.fx-word.castle .fx-word-line span { background-image: linear-gradient(180deg, #ffffff 0%, #9fd3ff 35%, #3d7bff 70%, #1a2a8a 100%); }
.fx-word.sneaky .fx-word-line span { background-image: linear-gradient(180deg, #ffffff 0%, #e2b3ff 35%, #b84dff 65%, #3d0a6e 100%); filter: drop-shadow(.04em .04em 0 #7cff3b) drop-shadow(.05em .06em 0 #1a0633) drop-shadow(0 .1em .15em rgba(0,0,0,.6)); }
.fx-word.power .fx-word-line span { background-image: linear-gradient(180deg, #ffffff 0%, #fff6a8 30%, #7cff3b 65%, #0b7a3b 100%); }
.fx-sub {
  margin-top: 6px; font-size: clamp(14px, 4vw, 22px); letter-spacing: .3em; font-style: normal; font-weight: 800;
  color: #fff; text-shadow: 0 0 8px #ff2bd6, 0 0 16px #ff2bd6, 0 2px 0 #1a0633;
}
@keyframes letterpop { from { transform: translateY(-120%) scale(.3) rotate(-30deg); opacity: 0; } }
@keyframes letterbob { to { transform: translateY(-6%); } }
.fx-word-line span:nth-child(even) { animation-direction: normal, alternate-reverse; }
.fx-hazard {
  left: 0; right: 0; height: 64px; display: grid; place-items: center;
  background: repeating-linear-gradient(-45deg, #ffe600 0 22px, #111 22px 44px);
  box-shadow: 0 0 30px rgba(255,230,0,.6); border-block: 4px solid #111;
}
.fx-hazard span { background: #111; color: #ffe600; padding: 4px 22px; font: italic 900 34px/1 Impact, "Arial Black", sans-serif; letter-spacing: .1em; border-radius: 6px; }
.fx-tower { filter: drop-shadow(0 8px 6px rgba(0,0,0,.6)); }
.fx-dust { border-radius: 50%; background: radial-gradient(circle, rgba(230,220,200,.9), rgba(230,220,200,0) 70%); }
.fx-vortex { border-radius: 50%; background: repeating-conic-gradient(from 0deg, rgba(184,77,255,.9) 0 15deg, rgba(43,243,255,.5) 15deg 30deg); -webkit-mask: radial-gradient(circle, transparent 0 10%, #000 25%, transparent 70%); mask: radial-gradient(circle, transparent 0 10%, #000 25%, transparent 70%); }
.fx-pillar { top: 0; bottom: 0; background: linear-gradient(90deg, transparent, rgba(255,246,168,.85) 30%, #fff 50%, rgba(255,246,168,.85) 70%, transparent); filter: blur(2px); mix-blend-mode: screen; }
.fx-score {
  left: 50%; top: 45%; text-align: center; padding: 22px 34px 18px; border-radius: 18px; white-space: nowrap;
  background: #10061f; border: 6px solid #10061f;
  box-shadow: 0 0 0 4px #ffe600, 0 0 40px 6px rgba(255,43,214,.7), 0 30px 80px rgba(0,0,0,.8);
  font-family: Impact, "Arial Black", sans-serif; font-style: italic;
}
.fx-score::before {
  content: ""; position: absolute; inset: -14px; border-radius: 24px; pointer-events: none;
  background: radial-gradient(circle, #fff6a8 0 3px, transparent 4px) 0 0 / 18px 18px;
  -webkit-mask: linear-gradient(#000 0 0) exclude, linear-gradient(#000 0 0) content-box; mask: linear-gradient(#000 0 0) exclude, linear-gradient(#000 0 0) content-box;
  padding: 8px; animation: bulbs .3s steps(2) infinite;
}
@keyframes bulbs { 50% { opacity: .35; } }
.fx-score-text { font-size: clamp(28px, 9vw, 64px); color: #2bf3ff; text-shadow: 0 0 12px #2bf3ff, 3px 3px 0 #ff2bd6; }
.fx-score-big { font-size: clamp(80px, 28vw, 200px); line-height: .95; background: linear-gradient(180deg, #fffbe0, #ffe600 40%, #ff2bd6); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 3px #fff; animation: letterbob .4s ease-in-out infinite alternate; }
.fx-score.lose .fx-score-text { color: #999; text-shadow: 3px 3px 0 #333; }
.fx-score.lose .fx-score-big { background: linear-gradient(180deg, #aaa, #555); -webkit-background-clip: text; background-clip: text; -webkit-text-stroke: 2px #777; animation: none; }
.fx-score.lose { box-shadow: 0 0 0 4px #555, 0 30px 80px rgba(0,0,0,.8); }
.fx-score.lose::before { display: none; }
@media (prefers-reduced-motion: reduce) {
  .fx-word-line span, .fx-score-big, .fx-score::before { animation: none !important; }
}
.handoff { margin: -4px auto 0; font-size: 13px; }
.join.invited .btn { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #1a1408; border-color: transparent; }

/* ---------- FX: evolution-style promotion ---------- */
.fx-evo { inset: 0; background: radial-gradient(circle at 50% 45%, rgba(40,60,110,.85), rgba(4,6,14,.96) 70%); }
.fx-evo > * { position: absolute; pointer-events: none; }
.fx-evo-fig { left: 50%; top: 45%; line-height: 1; transition: transform .05s; will-change: transform, filter; }
.fx-evo-glow { left: 50%; top: 45%; width: 60vmin; height: 60vmin; border-radius: 50%; opacity: 0; transform: translate(-50%,-50%) scale(.6);
  background: radial-gradient(circle, rgba(255,255,255,.95) 0%, rgba(160,230,255,.55) 35%, transparent 70%); transition: opacity .1s, transform .1s; }
.fx-evo-rays { left: 50%; top: 45%; width: 150vmax; height: 150vmax;
  background: repeating-conic-gradient(rgba(255,255,255,.16) 0 6deg, transparent 6deg 18deg);
  -webkit-mask: radial-gradient(circle, #000 0 15%, transparent 60%); mask: radial-gradient(circle, #000 0 15%, transparent 60%); }
.fx-evo-mote { left: 50%; top: 45%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: #fff; box-shadow: 0 0 12px #9fe8ff, 0 0 24px #fff; }
.fx-evo-cap { left: 50%; bottom: 12%; transform: translateX(-50%); width: min(92vw, 520px); text-align: center;
  padding: 14px 18px; border-radius: 12px; background: rgba(250,250,255,.96); color: #1b1d2a; border: 4px solid #3b4a7a;
  box-shadow: 0 0 0 3px #fff inset, 0 10px 30px rgba(0,0,0,.6); font: 700 clamp(16px, 4.6vw, 22px)/1.25 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.fx-evo-cap.done { background: #fff6a8; border-color: #c8913a; }

/* ---------- FX: 3D canvas + momentum swing ---------- */
.fx3d-backdrop { position: fixed; inset: 0; z-index: 68; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(circle at 50% 45%, rgba(45,12,80,.9), rgba(5,2,12,.97) 75%); }
.fx3d { position: fixed; inset: 0; z-index: 69; pointer-events: none; opacity: 0; transition: opacity .3s; }
.fx3d.on, .fx3d-backdrop.on { opacity: 1; }
.fx-swing { inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding-top: 22vh;
  background: repeating-linear-gradient(115deg, rgba(255,255,255,.04) 0 14px, transparent 14px 40px), radial-gradient(circle at 50% 50%, rgba(30,10,60,.8), rgba(5,2,12,.94) 75%); }
.fx-swing.good { background: repeating-linear-gradient(115deg, rgba(124,255,59,.06) 0 14px, transparent 14px 40px), radial-gradient(circle at 50% 50%, rgba(10,60,40,.82), rgba(3,10,6,.94) 75%); }
.fx-swing.bad { background: repeating-linear-gradient(115deg, rgba(255,60,60,.07) 0 14px, transparent 14px 40px), radial-gradient(circle at 50% 50%, rgba(80,10,20,.82), rgba(12,2,4,.94) 75%); }
.fx-swing > * { position: relative; }
.fx-swing-bar { width: min(86vw, 640px); height: 34px; border-radius: 17px; background: #15161b; border: 3px solid #fff; overflow: hidden; box-shadow: 0 0 30px rgba(255,255,255,.35); }
.fx-swing-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(180deg, #ffffff, #d9d4ca); }
.fx-swing-mark { position: absolute; top: -6px; bottom: -6px; width: 6px; margin-left: -3px; background: #ffe600; box-shadow: 0 0 16px #ffe600, 0 0 30px #ff2bd6; }
.fx-swing-labels { width: min(86vw, 640px); display: flex; justify-content: space-between; margin-top: 8px; color: #fff; font: 800 13px/1 var(--font); letter-spacing: .2em; text-shadow: 0 0 8px #ff2bd6; }
.fx-bolt { position: absolute !important; top: 0; width: 60px; height: 34vh; opacity: 0; filter: drop-shadow(0 0 12px #ffe600) drop-shadow(0 0 30px #fff); animation: bolt .5s steps(1) 3; }
@keyframes bolt { 0% { opacity: 1; } 20% { opacity: 0; } 40% { opacity: 1; } 60%, 100% { opacity: 0; } }
.fx-word.swingword .fx-word-line span { background-image: linear-gradient(180deg, #ffffff 0%, #ffe600 35%, #ff3b3b 70%, #6e0a2a 100%); }
.fx-swing.good ~ .fx-word.swingword .fx-word-line span { background-image: linear-gradient(180deg, #ffffff 0%, #c8ff9a 35%, #2bd66b 70%, #0a4a2a 100%); }

/* ---------- Stockfish mode ---------- */
.ai-block { display: flex; flex-direction: column; gap: 10px; }
.level-card {
  --lvl: 90;
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 16px;
  background: linear-gradient(135deg, hsla(var(--lvl), 90%, 55%, .16), rgba(0,0,0,.25) 70%);
  border: 1px solid hsla(var(--lvl), 90%, 60%, .4);
  box-shadow: inset 0 0 30px hsla(var(--lvl), 90%, 50%, .08);
  transition: background .3s, border-color .3s;
}
.level-pins { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: none; }
.pin-row { display: flex; gap: 3px; }
.pin { width: 13px; height: 32px; display: block; }
.pin svg { width: 100%; height: 100%; fill: rgba(255,255,255,.12); transition: fill .2s, filter .2s; }
.pin svg rect { fill: rgba(255,255,255,.08); }
.pin.on svg { fill: #fbf8f1; filter: drop-shadow(0 0 5px hsla(var(--lvl), 100%, 60%, .9)); }
.pin.on svg rect { fill: #e0242b; }
.level-readout { min-width: 0; flex: 1; }
.level-name {
  font: italic 900 clamp(24px, 7.4vw, 32px)/1.05 Impact, "Arial Black", system-ui, sans-serif; transform: skewX(-8deg); transform-origin: left;
  background: linear-gradient(180deg, #fff 0%, hsl(var(--lvl), 100%, 70%) 45%, hsl(var(--lvl), 90%, 45%) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(2px 2px 0 #1a0633);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 4px;
}
.level-elo { margin-top: 4px; color: var(--muted); font-size: 13px; }
.level-elo strong { color: #fff; font-size: 18px; font-variant-numeric: tabular-nums; }
.level-desc { margin: -2px 2px 0; color: var(--muted); font-size: 13px; min-height: 2.6em; }
#elo { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; margin: 0; touch-action: pan-y; }
#elo::-webkit-slider-runnable-track { height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, transparent var(--pct, 30%), rgba(10,10,14,.75) var(--pct, 30%)), linear-gradient(90deg, #5fcf8a, #e2d45c 40%, #ff9a1a 70%, #e0445c); }
#elo::-moz-range-track { height: 10px; border-radius: 5px; background: linear-gradient(90deg, #5fcf8a, #e2d45c 40%, #ff9a1a 70%, #e0445c); opacity: .55; }
#elo::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -9px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #000 0 9%, transparent 10%), radial-gradient(circle at 60% 30%, #000 0 9%, transparent 10%), radial-gradient(circle at 48% 52%, #000 0 9%, transparent 10%), radial-gradient(circle at 32% 28%, #ff7ae0, #8a1fd1 50%, #2a0a4a 95%);
  border: 2px solid rgba(255,255,255,.8); box-shadow: 0 3px 10px rgba(0,0,0,.6), 0 0 14px rgba(184,77,255,.6); cursor: grab; }
#elo::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: radial-gradient(circle at 32% 28%, #ff7ae0, #8a1fd1 50%, #2a0a4a 95%); }
.tiers { display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity; padding: 2px 2px 6px; margin: 0 -2px; scrollbar-width: none; -webkit-mask: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent); mask: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent); }
.tiers::-webkit-scrollbar { display: none; }
.tier { flex: none; scroll-snap-align: center; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 12px; border-radius: 12px;
  border: 1px solid var(--card-b); background: rgba(255,255,255,.04); color: var(--muted); transition: background .15s, border-color .15s, color .15s, transform .1s; }
.tier:first-child { margin-left: 10px; }
.tier:last-child { margin-right: 10px; }
.tier:active { transform: scale(.95); }
.tier-name { font-weight: 700; font-size: 13px; white-space: nowrap; }
.tier-elo { font-size: 11px; opacity: .75; font-variant-numeric: tabular-nums; }
.tier.on { color: #fff; border-color: rgba(43,243,255,.6); background: rgba(43,243,255,.12); box-shadow: 0 0 14px -4px rgba(43,243,255,.7); }
.btn.ai { display: inline-flex; align-items: center; justify-content: center; gap: 8px; margin-top: 4px; color: #06262a; border-color: transparent;
  background: linear-gradient(180deg, #7ff9ff, #22c8d6); box-shadow: 0 6px 20px -8px rgba(43,243,255,.7); }
.avatar.bot { position: relative; background: linear-gradient(160deg, #2bf3ff, #1b6f9a); }
.avatar.bot::after { content: ""; position: absolute; inset: 7px 6px; border-radius: 3px;
  background: radial-gradient(circle at 30% 50%, #06262a 0 2px, transparent 2.5px), radial-gradient(circle at 70% 50%, #06262a 0 2px, transparent 2.5px); }
.status.bot-thinking { border-color: rgba(43,243,255,.35); color: #9ff7ff; }

/* ---------- Chess Turkey title ---------- */
.title-art { font: italic 900 clamp(40px, 12vw, 58px)/1 Impact, "Arial Black", system-ui, sans-serif; letter-spacing: .01em; transform: skewX(-8deg); }
.title-art span {
  background: linear-gradient(180deg, #fffbe0 0%, #ffe600 35%, #ff9a1a 62%, #ff2bd6 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: .03em #1a0633;
  filter: drop-shadow(.035em .035em 0 #2bf3ff) drop-shadow(.04em .05em 0 #1a0633);
}
.title-art span + span { background-image: linear-gradient(180deg, #ffffff 0%, #9ff7ff 35%, #2bf3ff 60%, #1b6f9a 100%); filter: drop-shadow(.035em .035em 0 #ff2bd6) drop-shadow(.04em .05em 0 #1a0633); }
.elo-badge { flex: none; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  color: #9ff7ff; background: rgba(43,243,255,.12); border: 1px solid rgba(43,243,255,.4); font-variant-numeric: tabular-nums; }
@media (max-width: 380px) { .elo-badge { font-size: 10px; padding: 2px 6px; } }

/* ---------- QR codes ---------- */
.qr { width: 150px; margin: 0 auto 6px; border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 4px #fff, 0 10px 30px -10px rgba(0,0,0,.8); background: #fff; }
.qr:empty { display: none; }
.qr svg { display: block; width: 100%; height: auto; }
.qr.big { width: min(240px, 66vw); margin: 16px auto 12px; }
.qr-cap { font-size: 12px; margin: 6px 0 14px !important; }
.warn { margin: 0 0 14px !important; font-size: 13px; color: #ffb4ae; }
#handoff .sheet p.muted { margin-top: 6px; }
