/* Wand Duel: midnight arcana. Ink-black sky, gold filigree, six elemental colours.
   Phone-first, with a landscape big-screen layout. */

:root {
  --bg: #070611;
  --bg2: #0e0b1e;
  --ink: #120e26;
  --panel: rgba(255, 240, 210, 0.045);
  --panel2: rgba(255, 240, 210, 0.085);
  --line: rgba(243, 201, 105, 0.15);
  --line2: rgba(243, 201, 105, 0.32);
  --gold: #f3c969;
  --gold2: #ffe3a3;
  --gold3: #b9822d;
  --text: #f6f0e3;
  --muted: #a7a2bf;
  --dim: #6b678a;
  --sun: #f3c969;
  --moon: #b48cff;
  --ember: #ff7a3d;
  --frost: #a6ecff;
  --tide: #3f7bff;
  --ward: #ffcf5c;
  --mend: #62f5a0;
  --hex: #d05cff;
  --red: #ff5d6c;
  --green: #62f5a0;
  --deco: "Cinzel Decorative", "Cinzel", Georgia, serif;
  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  --ui: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
/* a slow nebula and a field of stars behind everything */
body::before {
  content: "";
  position: fixed;
  inset: -25%;
  z-index: -2;
  background:
    radial-gradient(38% 32% at 18% 14%, rgba(122, 76, 214, 0.26), transparent 70%),
    radial-gradient(42% 38% at 86% 86%, rgba(40, 110, 210, 0.2), transparent 70%),
    radial-gradient(30% 26% at 78% 18%, rgba(243, 201, 105, 0.1), transparent 70%),
    radial-gradient(36% 30% at 20% 88%, rgba(208, 92, 255, 0.12), transparent 70%);
  animation: drift 30s ease-in-out infinite alternate;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 12% 22%, rgba(255, 250, 235, 0.8), transparent 60%),
    radial-gradient(1px 1px at 72% 12%, rgba(255, 250, 235, 0.7), transparent 60%),
    radial-gradient(1.5px 1.5px at 38% 68%, rgba(255, 250, 235, 0.6), transparent 60%),
    radial-gradient(1px 1px at 88% 52%, rgba(255, 250, 235, 0.7), transparent 60%),
    radial-gradient(1px 1px at 58% 88%, rgba(255, 250, 235, 0.5), transparent 60%),
    radial-gradient(1.5px 1.5px at 24% 48%, rgba(255, 230, 180, 0.5), transparent 60%);
  background-size: 230px 230px, 310px 310px, 270px 270px, 190px 190px, 350px 350px, 410px 410px;
  animation: twinkle 7s ease-in-out infinite alternate;
  opacity: 0.8;
}
@keyframes drift { to { transform: translate3d(4%, -3%, 0) rotate(3deg); } }
@keyframes twinkle { from { opacity: 0.45; } to { opacity: 0.9; } }

input, button { font: inherit; color: inherit; }
input { -webkit-user-select: text; user-select: text; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
b { font-weight: 700; }
a { color: var(--gold2); }

/* ── back to the hub ───────────────────────────── */
.hub-link {
  position: fixed; z-index: 40; top: calc(12px + var(--sat)); left: calc(12px + var(--sal));
  display: inline-flex; gap: 6px; align-items: center;
  font: 600 13px var(--ui); color: var(--text); text-decoration: none;
  padding: 8px 13px; border-radius: 999px;
  background: rgba(7, 6, 17, 0.62); border: 1px solid var(--line2);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
body[data-screen="scr-home"] .hub-link,
body[data-screen="scr-over"] .hub-link { opacity: 1; pointer-events: auto; }
body.is-tv .hub-link { display: none; }

/* ── screens ───────────────────────────────────── */
.app, .tv { position: fixed; inset: 0; height: 100dvh; }
.screen {
  position: absolute; inset: 0; height: 100dvh;
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
  padding-left: var(--sal); padding-right: var(--sar);
}
.screen.on { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.35s ease; }

/* ── buttons ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 12px 18px; border-radius: 14px;
  font: 700 15px var(--ui); letter-spacing: 0.01em; color: var(--text);
  transition: transform 0.12s ease, filter 0.2s, box-shadow 0.2s, background 0.2s;
}
.btn:active { transform: translateY(1px) scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.big { min-height: 56px; font-size: 17px; border-radius: 16px; width: 100%; }
.btn.primary {
  color: #1d1406;
  background: linear-gradient(180deg, #fff0c4 0%, #f0c562 48%, #cf9336 100%);
  box-shadow: 0 10px 34px rgba(243, 201, 105, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.7), inset 0 -2px 0 rgba(90, 50, 0, 0.25);
}
.btn.primary:not(:disabled):hover { filter: brightness(1.06); box-shadow: 0 12px 40px rgba(243, 201, 105, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.7), inset 0 -2px 0 rgba(90, 50, 0, 0.25); }
.btn.ghost { background: var(--panel); border: 1px solid var(--line2); }
.btn.ghost:hover { background: var(--panel2); }
.btn.link { min-height: 36px; padding: 6px 10px; color: var(--gold2); font-weight: 600; text-decoration: underline dotted rgba(243, 201, 105, 0.5); text-underline-offset: 4px; }
.btn.danger { color: #23060b; background: linear-gradient(180deg, #ffb0b7, #e8505f); }
.btn.on { background: rgba(98, 245, 160, 0.14); border-color: rgba(98, 245, 160, 0.55); color: #c9ffde; }
.btn-ico { font-size: 1.1em; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 7px 14px; border-radius: 999px;
  font: 700 13px var(--ui); color: var(--text);
  background: var(--panel2); border: 1px solid var(--line2);
}
.chip.ghost { background: transparent; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.duo:has(> [hidden]) { grid-template-columns: 1fr; }

/* ── shared bars ───────────────────────────────── */
.bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: calc(12px + var(--sat)) 14px 10px;
}
.bar > :first-child { justify-self: start; }
.bar > :last-child { justify-self: end; }
.bar-title { font: 700 17px var(--display); letter-spacing: 0.06em; text-align: center; color: var(--gold2); }
.bar-acts { display: flex; gap: 6px; }
.foot { margin: auto auto 0; width: min(480px, 100%); padding: 12px 18px calc(16px + var(--sab)); display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.note { color: var(--muted); font-size: 14px; text-align: center; min-height: 1.2em; }
.muted { color: var(--muted); }
.kicker { font: 700 12px var(--ui); letter-spacing: 0.32em; text-transform: uppercase; color: var(--gold); }

/* ── home ──────────────────────────────────────── */
.home { overflow-y: auto; overflow-x: hidden; }
.home-in {
  width: min(440px, 100%); margin: 0 auto; min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: calc(58px + var(--sat)) 20px calc(18px + var(--sab));
}
.crest { position: relative; width: min(56vw, 232px, 30dvh); aspect-ratio: 1; display: grid; place-items: center; }
.rune-ring { position: absolute; inset: 0; width: 100%; height: 100%; animation: spin 60s linear infinite; }
.ring-text { font: 700 8.6px var(--display); letter-spacing: 0.28em; fill: rgba(243, 201, 105, 0.6); }
@keyframes spin { to { transform: rotate(360deg); } }
.home-glyph { position: absolute; inset: 14%; width: 72%; height: 72%; }
.crest-name {
  position: absolute; bottom: 21%; left: 0; right: 0; text-align: center;
  font: 700 12px var(--display); letter-spacing: 0.4em; text-transform: uppercase; color: var(--gold2);
  text-shadow: 0 0 14px rgba(243, 201, 105, 0.6); transition: color 0.5s;
}
.logo { display: flex; gap: 0.28em; align-items: baseline; justify-content: center; font-family: var(--deco); font-weight: 900; line-height: 1; letter-spacing: 0.02em; }
.logo span {
  font-size: clamp(42px, 13.5vw, 66px);
  background: linear-gradient(180deg, #fff6dc 10%, #f3c969 55%, #a86f22 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px rgba(243, 201, 105, 0.28));
}
.logo .l2 { background: linear-gradient(180deg, #f1e7ff 10%, #b48cff 60%, #6a3fc2 100%); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 0 18px rgba(180, 140, 255, 0.3)); }
.pitch { text-align: center; color: var(--muted); font-size: 15px; line-height: 1.5; max-width: 34ch; }
.pitch b { color: var(--text); }
.home-form { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.name-in {
  width: 100%; text-align: center; padding: 10px 8px 9px; font: 600 17px var(--ui);
  background: transparent; border: 0; border-bottom: 1px solid var(--line2); border-radius: 0; outline: none;
}
.name-in:focus { border-bottom-color: var(--gold); }
.name-in::placeholder, .code-in::placeholder { color: var(--dim); }
.join-row { display: grid; grid-template-columns: 1.25fr 1fr auto; gap: 8px; }
.code-in {
  min-width: 0; text-align: center; text-transform: uppercase; letter-spacing: 0.3em; padding: 0 0 0 0.3em;
  font: 700 17px var(--display); background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; outline: none;
}
.code-in:focus { border-color: var(--gold); }
.home-form.has-code #btn-create { display: none; }
.home-form.has-code .join-row { grid-template-columns: 1fr auto; }
.home-foot { color: var(--dim); font-size: 13px; text-align: center; }
.online { display: inline-flex; align-items: center; gap: 6px; }
.online i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.4; } }

/* ── wand check ────────────────────────────────── */
.wand-body { flex: 1; overflow-y: auto; padding: 4px 18px 0; display: flex; flex-direction: column; gap: 16px; width: min(480px, 100%); margin: 0 auto; }
.wand-body > *, .lob-body > *, .book-body > * { flex-shrink: 0; }
.howto { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; }
.howto-art { width: 100%; }
.howto-trail { stroke-dasharray: 260; stroke-dashoffset: 260; animation: trace 2.6s ease-in-out infinite; }
.howto-phone { animation: swing 2.6s ease-in-out infinite; transform-origin: 109px 140px; }
@keyframes trace { 0% { stroke-dashoffset: 260; } 70%, 100% { stroke-dashoffset: 0; } }
@keyframes swing { 0% { transform: translate(-60px, 34px) rotate(-24deg); } 35% { transform: translate(0, -42px) rotate(0); } 70%, 100% { transform: translate(62px, 34px) rotate(24deg); } }
.steps { list-style: none; counter-reset: s; display: grid; gap: 8px; font-size: 14px; color: var(--muted); line-height: 1.35; }
.steps li { counter-increment: s; position: relative; padding-left: 26px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center; font: 800 11px var(--ui); color: #1d1406; background: var(--gold); }
.steps b { color: var(--text); }
.steps li.tip { counter-increment: none; font-size: 12.5px; color: var(--dim); }
.steps li.tip::before { content: "↻"; background: none; color: var(--gold); font-size: 14px; }
.testpad { position: relative; border-radius: 20px; border: 1px solid var(--line2); background: radial-gradient(circle at 50% 45%, rgba(243, 201, 105, 0.07), transparent 70%), rgba(10, 8, 24, 0.6); overflow: hidden; touch-action: none; }
#test-canvas { display: block; width: 100%; height: min(42dvh, 320px); }
.test-msg { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: 14px; color: var(--muted); pointer-events: none; padding: 0 12px; }
.test-msg b { color: var(--gold2); }
.opts { display: grid; gap: 10px; padding-bottom: 6px; }
.toggle { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 44px; height: 26px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); position: relative; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #e9e2ff; transition: transform 0.2s; }
.toggle input:checked + .switch { background: linear-gradient(90deg, #d39a3a, #f3c969); }
.toggle input:checked + .switch::after { transform: translateX(18px); background: #fff; }
.toggle input:disabled ~ * { opacity: 0.45; }
.t-text { display: grid; gap: 2px; font-size: 15px; }
.t-text small { color: var(--muted); font-size: 12.5px; line-height: 1.35; }

/* ── queue ─────────────────────────────────────── */
.queue-in { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px; text-align: center; }
.seek { position: relative; width: 150px; height: 150px; display: grid; place-items: center; margin-bottom: 8px; }
.seek i { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid rgba(243, 201, 105, 0.5); animation: seek 2.4s ease-out infinite; }
.seek i:nth-child(2) { animation-delay: 0.8s; border-color: rgba(180, 140, 255, 0.5); }
.seek i:nth-child(3) { animation-delay: 1.6s; }
.seek span { font-size: 40px; color: var(--gold2); text-shadow: 0 0 24px var(--gold); animation: spin 6s linear infinite; }
@keyframes seek { from { transform: scale(0.35); opacity: 1; } to { transform: scale(1.15); opacity: 0; } }
.big-h { font: 700 26px var(--display); letter-spacing: 0.04em; }

/* ── lobby ─────────────────────────────────────── */
.room-id { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.room-id .lbl { font: 700 10px var(--ui); letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); }
.room-id .code { font: 800 28px var(--display); letter-spacing: 0.2em; padding-left: 0.2em; color: var(--gold2); text-shadow: 0 0 18px rgba(243, 201, 105, 0.45); }
.lob-body { flex: 1; overflow-y: auto; padding: 8px 18px; display: flex; flex-direction: column; gap: 16px; width: min(480px, 100%); margin: 0 auto; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.qr { width: min(200px, 56vw); aspect-ratio: 1; border-radius: 14px; overflow: hidden; box-shadow: 0 0 0 6px #f6f0e3, 0 0 40px rgba(243, 201, 105, 0.3); }
.qr svg { display: block; width: 100%; height: 100%; }
.faceoff { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: stretch; margin-top: 6px; }
.duelist {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 18px 10px 14px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.duelist.s0 { --sc: var(--sun); }
.duelist.s1 { --sc: var(--moon); }
.duelist.ready { border-color: color-mix(in srgb, var(--sc) 70%, transparent); box-shadow: 0 0 34px color-mix(in srgb, var(--sc) 22%, transparent); }
.duelist.empty { border-style: dashed; color: var(--dim); }
.duelist .side { font: 700 10px var(--ui); letter-spacing: 0.3em; text-transform: uppercase; color: var(--sc); }
.duelist .dname { font: 700 18px var(--display); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duelist .me { font: 700 10px var(--ui); letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.duelist .state { font-size: 12.5px; color: var(--muted); }
.duelist.ready .state { color: var(--sc); font-weight: 700; }
.duelist .badges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.vs { align-self: center; font: 900 20px var(--deco); color: var(--gold); text-shadow: 0 0 20px rgba(243, 201, 105, 0.6); }
.sigil {
  width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center;
  font: 800 26px var(--display); color: var(--sc, var(--gold));
  background: radial-gradient(circle at 50% 35%, #2a2250, #120e26);
  border: 2px solid var(--sc, var(--gold));
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.03), 0 0 26px color-mix(in srgb, var(--sc, var(--gold)) 35%, transparent);
}
.duelist.empty .sigil { border-style: dashed; color: var(--dim); box-shadow: none; animation: breathe 2.4s ease-in-out infinite; }
.badge { font: 700 11px var(--ui); padding: 3px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); color: var(--muted); white-space: nowrap; }
.badge.air { color: var(--gold2); }
.badge.voice { color: #c9b6ff; }
.badge.dim { opacity: 0.7; }
.lob-tip, .lob-tv { text-align: center; color: var(--muted); font-size: 14px; line-height: 1.45; }
.lob-tv { color: var(--dim); font-size: 13px; }

/* ── bot select ────────────────────────────────── */
.bot-list { flex: 1; overflow-y: auto; display: grid; gap: 12px; align-content: start; padding: 8px 18px calc(20px + var(--sab)); width: min(480px, 100%); margin: 0 auto; }
.bot-card {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; text-align: left;
  padding: 16px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); transition: border-color 0.2s, transform 0.15s;
}
.bot-card:hover, .bot-card:focus-visible { border-color: var(--line2); }
.bot-card:active { transform: scale(0.99); }
.bot-card .sigil { width: 52px; height: 52px; font-size: 20px; --sc: var(--moon); }
.bot-card h3 { font: 700 18px var(--display); }
.bot-card p { color: var(--muted); font-size: 13.5px; line-height: 1.4; margin-top: 3px; }
.bot-card .stars { color: var(--gold); letter-spacing: 2px; font-size: 13px; }
.bot-card .go { color: var(--gold2); font-size: 22px; }

/* ── duel ──────────────────────────────────────── */
.duel { touch-action: none; -webkit-user-select: none; user-select: none; }
#arena { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud { position: absolute; left: 0; right: 0; z-index: 2; pointer-events: none; display: flex; flex-direction: column; gap: 6px; padding-left: calc(14px + var(--sal)); padding-right: calc(14px + var(--sar)); }
.hud.top { top: 0; padding-top: calc(10px + var(--sat)); padding-right: calc(96px + var(--sar)); }
.hud.bottom { bottom: 0; padding-bottom: calc(10px + var(--sab)); }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hud-name { font: 700 15px var(--display); letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud.top .hud-name { color: var(--opp-c, var(--moon)); }
.hud.bottom .hud-name { color: var(--my-c, var(--sun)); }
.hud-badges { display: flex; gap: 4px; }
.hud-badges .badge { font-size: 10px; padding: 2px 6px; }
.pips { display: inline-flex; gap: 5px; margin-left: auto; }
.pips i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid rgba(243, 201, 105, 0.7); }
.pips i.won { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.pips.big i { width: 16px; height: 16px; }
.clock { font: 700 12px var(--ui); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.bars { display: grid; gap: 4px; }
.bar-hp { position: relative; height: 13px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); }
.bar-hp i { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(90deg, #8f63e8, #c6a6ff); transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.bar-hp.mine i, .bar-hp.sun i { background: linear-gradient(90deg, #c98d33, #ffe3a3); }
.bar-hp.low i { background: linear-gradient(90deg, #c22f42, #ff8a93) !important; animation: lowhp 0.8s ease-in-out infinite; }
@keyframes lowhp { 50% { filter: brightness(1.4); } }
.bar-hp b { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font: 800 10px var(--ui); color: rgba(10, 6, 20, 0.85); }
.bar-mana { position: relative; height: 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); }
.bar-mana i { position: absolute; inset: 0; border-radius: inherit; transform-origin: left; background: linear-gradient(90deg, #4f8cff, #8fd8ff); box-shadow: 0 0 10px rgba(111, 195, 255, 0.5); }
.bar-mana.mine { height: 8px; }
.ticks { position: absolute; inset: 0; }
.ticks span { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 1px; background: rgba(255, 255, 255, 0.3); }
.ticks span::after { content: attr(data-l); position: absolute; top: -13px; left: 50%; transform: translateX(-50%); font: 700 8px var(--ui); color: var(--dim); white-space: nowrap; }
.pad-hint {
  text-align: center; font: 700 12px var(--ui); letter-spacing: 0.22em; text-transform: uppercase; color: rgba(243, 201, 105, 0.75);
  animation: breathe 2.6s ease-in-out infinite; transition: opacity 0.2s;
}
body.tracing .pad-hint, body.clashing .pad-hint { opacity: 0; }
.legend { display: flex; justify-content: center; align-items: center; gap: 5px; font: 600 10.5px var(--ui); color: var(--dim); flex-wrap: wrap; }
.legend .g { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; }
.legend .g svg { width: 14px; height: 14px; }
.x-btn, .snd-btn {
  position: absolute; z-index: 3; top: calc(9px + var(--sat)); width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; color: var(--muted); background: rgba(7, 6, 17, 0.55); border: 1px solid var(--line);
  font-size: 14px;
}
.x-btn { right: calc(12px + var(--sar)); }
.snd-btn { right: calc(54px + var(--sar)); font-size: 15px; }
.overlay { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; padding: 20px; }
.count-n { font: 900 min(34vw, 150px) / 1 var(--deco); color: var(--gold2); text-shadow: 0 0 40px rgba(243, 201, 105, 0.7); animation: countpop 0.9s ease-out both; }
.count-n.go { color: #fff; font-size: min(22vw, 110px); }
.count-sub { color: var(--muted); font-size: 14px; max-width: 28ch; margin-top: 8px; }
@keyframes countpop { from { transform: scale(1.6); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); opacity: 1; } }
.clashov { justify-content: flex-end; padding-bottom: calc(31vh + var(--sab)); }
.clash-t { font: 900 clamp(24px, 8vw, 40px) var(--deco); color: #fff; text-shadow: 0 0 24px rgba(255, 255, 255, 0.7), 0 0 60px var(--gold); animation: thrust 0.42s ease-in-out infinite alternate; }
.clash-s { color: var(--gold2); font-size: 13px; margin-top: 6px; max-width: 30ch; }
@keyframes thrust { from { transform: scale(0.94); } to { transform: scale(1.06); } }
.boutov { background: radial-gradient(circle, rgba(7, 6, 17, 0.75), rgba(7, 6, 17, 0.35) 70%); animation: fadein 0.4s ease both; }
.bout-t { font: 900 clamp(34px, 11vw, 60px) / 1.05 var(--deco); margin: 10px 0 8px; }
.bout-t.won { background: linear-gradient(180deg, #fff6dc, #f3c969 60%, #a86f22); -webkit-background-clip: text; background-clip: text; color: transparent; }
.bout-t.lost { color: #c9c3e2; }
.bout-s { color: var(--muted); font-size: 15px; margin-bottom: 14px; }
.found { background: radial-gradient(circle, rgba(7, 6, 17, 0.85), rgba(7, 6, 17, 0.5) 70%); animation: fadein 0.4s ease both; }
.found-name { font: 900 clamp(32px, 10vw, 54px) var(--deco); color: var(--moon); text-shadow: 0 0 30px rgba(180, 140, 255, 0.6); margin: 10px 0 6px; }
.found-sub { color: var(--muted); }
@keyframes fadein { from { opacity: 0; } }
.confirm { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; background: rgba(4, 3, 10, 0.72); padding: 20px; }
.confirm-card { width: min(360px, 100%); padding: 20px; border-radius: 20px; background: #120e26; border: 1px solid var(--line2); display: grid; gap: 16px; text-align: center; font-size: 16px; }
.confirm-card span { color: var(--muted); display: block; font-size: 14px; margin-top: 4px; }

/* ── results ───────────────────────────────────── */
.over { overflow-y: auto; }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.over-in { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: calc(64px + var(--sat)) 18px 8px; width: min(480px, 100%); margin: 0 auto; text-align: center; }
.over-t { font: 900 clamp(46px, 15vw, 78px) / 1 var(--deco); margin-top: 6px; animation: countpop 0.8s ease-out both; }
.over-t.win { background: linear-gradient(180deg, #fff6dc 10%, #f3c969 55%, #a86f22); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 24px rgba(243, 201, 105, 0.35)); }
.over-t.lose { color: #b9b3d6; }
.over-t.draw { color: var(--moon); }
.over-s { color: var(--muted); font-size: 15.5px; margin-bottom: 10px; }
.statsheet { width: 100%; display: grid; grid-template-columns: 1fr auto auto; gap: 0; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: var(--panel); }
.statsheet > div { padding: 9px 14px; border-top: 1px solid rgba(243, 201, 105, 0.08); font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
.statsheet > div:nth-child(-n + 3) { border-top: 0; font: 700 11px var(--ui); letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.statsheet > .lbl { text-align: left; color: var(--muted); }
.statsheet > .c0 { color: var(--sun); font-weight: 700; }
.statsheet > .c1 { color: var(--moon); font-weight: 700; }
.statsheet > .best { text-shadow: 0 0 12px currentColor; }
.drill-score { font: 900 64px var(--deco); color: var(--gold2); }

/* ── spellbook ─────────────────────────────────── */
.book-body { flex: 1; overflow-y: auto; padding: 4px 16px calc(24px + var(--sab)); width: min(560px, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.mastery { font: 700 12px var(--ui); color: var(--muted); }
.cycle { display: grid; place-items: center; }
.cycle svg { width: min(290px, 78vw); height: auto; overflow: visible; }
.cycle-lbl { font: 700 10.5px var(--ui); letter-spacing: 0.14em; text-transform: uppercase; fill: var(--muted); }
.cycle-name { font: 700 13px var(--display); letter-spacing: 0.06em; }
.cycle-note { text-align: center; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.cycle-note b { color: var(--text); }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.gcard {
  --gc: var(--gold); position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 14px 10px 12px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line);
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.gcard:hover, .gcard:focus-visible { border-color: color-mix(in srgb, var(--gc) 60%, transparent); box-shadow: 0 0 30px color-mix(in srgb, var(--gc) 16%, transparent); }
.gcard:active { transform: scale(0.98); }
.gcard svg.glyph-ico { width: 64px; height: 64px; filter: drop-shadow(0 0 8px var(--gc)); }
.gcard h3 { font: 700 18px var(--display); color: var(--gc); }
.gcard .mark { font-size: 12px; font-style: italic; color: var(--muted); }
.gcard .eff { font-size: 12.5px; color: var(--text); line-height: 1.35; min-height: 2.7em; }
.gcard .meta { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 2px; }
.gcard .cost { font: 700 11px var(--ui); color: #8fd8ff; background: rgba(79, 140, 255, 0.14); padding: 2px 8px; border-radius: 999px; }
.gcard .pips i { width: 8px; height: 8px; }
.gcard.learned::after { content: "✓"; position: absolute; top: 8px; right: 10px; font: 800 12px var(--ui); color: var(--green); }
.drill-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 20px; background: linear-gradient(135deg, rgba(243, 201, 105, 0.12), rgba(180, 140, 255, 0.08)); border: 1px solid var(--line2); }
.drill-card h3 { font: 700 18px var(--display); color: var(--gold2); }
.drill-card p { color: var(--muted); font-size: 13.5px; line-height: 1.45; margin-top: 4px; }

/* ── learn ─────────────────────────────────────── */
.learn { touch-action: none; }
#learn-canvas { flex: 1; width: 100%; min-height: 0; display: block; touch-action: none; }
.learn-info { padding: 6px 18px calc(16px + var(--sab)); display: flex; flex-direction: column; gap: 6px; align-items: center; text-align: center; }
.learn-mark { font: 700 12px var(--ui); letter-spacing: 0.24em; text-transform: uppercase; color: var(--muted); }
.learn-how { font-size: 15px; color: var(--text); max-width: 34ch; line-height: 1.4; }
.learn-res { font-size: 14px; color: var(--muted); min-height: 2.6em; max-width: 36ch; line-height: 1.4; }
.learn-res.good { color: var(--green); font-weight: 700; }
.learn-res.bad { color: #ffb3ba; }
.learn-nav { display: flex; gap: 14px; align-items: center; }
.learn-nav .chip { width: 44px; justify-content: center; font-size: 20px; padding: 0; }
.learn-dots { display: flex; gap: 6px; }
.learn-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.15); }
.learn-dots i.on { background: var(--gold); }
.learn-dots i.done { background: var(--green); }

/* ── toast ─────────────────────────────────────── */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 14px; font-size: 14px; text-align: center;
  background: rgba(18, 14, 38, 0.95); border: 1px solid var(--line2); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: toast 0.3s ease both;
}
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ══════════════════════════ BIG SCREEN ══════════════════════════ */
body.is-tv { cursor: default; }
.tv-lobby { flex-direction: row; align-items: center; gap: 5vw; padding: 5vh 6vw; }
.tv-left { flex: 1.2; display: flex; flex-direction: column; gap: 3vh; }
.tvlogo { justify-content: flex-start; }
.tvlogo span { font-size: clamp(56px, 7vw, 120px); }
.tv-pitch { font-size: clamp(16px, 1.5vw, 24px); color: var(--muted); line-height: 1.5; max-width: 40ch; }
.tv-pitch b { color: var(--text); }
.join-card { display: flex; gap: 2.5vw; align-items: center; padding: 2.4vh 2vw; border-radius: 24px; background: var(--panel); border: 1px solid var(--line2); width: fit-content; }
.join-card .qr { width: clamp(140px, 16vw, 260px); }
.join-text .lbl { color: var(--muted); font-size: clamp(13px, 1.1vw, 18px); }
.join-text .url { font: 700 clamp(18px, 1.8vw, 30px) var(--ui); color: var(--gold2); margin: 4px 0 10px; }
.join-text .code { font: 800 clamp(48px, 6vw, 104px) / 1 var(--display); letter-spacing: 0.18em; color: var(--gold2); text-shadow: 0 0 30px rgba(243, 201, 105, 0.45); }
.tv-right { flex: 1; display: flex; flex-direction: column; gap: 3vh; }
.tvface .duelist { padding: 3vh 1vw; }
.tvface .sigil { width: clamp(70px, 7vw, 120px); height: clamp(70px, 7vw, 120px); font-size: clamp(30px, 3vw, 52px); }
.tvface .dname { font-size: clamp(18px, 1.8vw, 30px); }
.tvface .vs { font-size: clamp(22px, 2.4vw, 40px); }
.tv-actions { display: flex; gap: 12px; align-items: center; }
.tv-actions .btn.big { width: auto; padding: 0 34px; }
.tv-join { display: flex; gap: 10px; align-items: center; color: var(--dim); font-size: 14px; flex-wrap: wrap; }
.tv-join input { width: 110px; text-align: center; letter-spacing: 0.25em; text-transform: uppercase; font: 700 16px var(--display); padding: 8px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line2); outline: none; }
#tv-arena { position: absolute; inset: 0; width: 100%; height: 100%; }
.tv-hud { position: absolute; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; gap: 3vw; padding: 3vh 4vw; z-index: 2; }
.tv-side { display: grid; gap: 1vh; }
.tv-side .bar-hp { height: clamp(14px, 1.6vh, 22px); }
.tv-side .bar-mana { height: 7px; }
.tv-side.s1 .bar-hp i, .tv-side.s1 .bar-mana i { transform-origin: right; }
.tv-side.s0 .bar-hp i { background: linear-gradient(90deg, #c98d33, #ffe3a3); }
.tv-side.s1 { text-align: right; }
.tv-side.s1 .bar-hp b { right: auto; left: 10px; }
.tv-who { font: 700 clamp(18px, 1.9vw, 34px) var(--display); display: flex; gap: 12px; align-items: center; }
.tv-side.s1 .tv-who { justify-content: flex-end; }
.tv-side.s0 .tv-who b { color: var(--sun); }
.tv-side.s1 .tv-who b { color: var(--moon); }
.tv-who .seat { font: 700 clamp(10px, 0.8vw, 14px) var(--ui); letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); }
.tv-who .pips { margin: 0; }
.tv-mid { text-align: center; display: grid; gap: 4px; align-content: start; }
.tv-bout { font: 800 clamp(16px, 1.6vw, 26px) var(--display); letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold2); }
.tv-clock { font: 700 clamp(14px, 1.2vw, 20px) var(--ui); color: var(--muted); font-variant-numeric: tabular-nums; }
.tv-code-chip { font-size: 13px; color: var(--dim); }
.tv-code-chip b { color: var(--gold2); letter-spacing: 0.15em; font-family: var(--display); }
.tv-call { position: absolute; left: 0; right: 0; top: 23vh; text-align: center; z-index: 3; pointer-events: none; font: 900 clamp(32px, 5vw, 90px) var(--deco); text-shadow: 0 0 40px currentColor; }
.tv-call.pop { animation: callpop 1.4s ease-out both; }
@keyframes callpop { 0% { transform: scale(1.5); opacity: 0; } 12% { transform: scale(1); opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
.tv-legend { position: absolute; left: 0; right: 0; bottom: 3vh; display: flex; justify-content: center; gap: 12px; color: var(--dim); font: 600 clamp(12px, 1vw, 16px) var(--ui); z-index: 2; }
.tv-legend .g { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; }
.tv-legend svg { width: 22px; height: 22px; }
.tv-over { align-items: center; justify-content: center; gap: 2vh; text-align: center; padding: 4vh; }
.tv-over .over-t { font-size: clamp(60px, 9vw, 150px); }
.tvstats { width: min(820px, 90vw); font-size: 18px; }
.tvstats > div { font-size: clamp(14px, 1.3vw, 20px); padding: 1.2vh 1.6vw; }

@media (prefers-reduced-motion: reduce) {
  body::before, body::after, .rune-ring, .seek span, .seek i, .howto-trail, .howto-phone, .pad-hint, .clash-t { animation: none !important; }
}
@media (min-width: 700px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
}
