/* =========================================================
 * 史問 BATTLE — 스타일
 * 먹(墨) 남색 바탕 + 금박 포인트, 등급별 카드 프레임
 * ========================================================= */
:root {
  --bg: #0b0e1a;
  --bg2: #121729;
  --panel: #171d33;
  --panel2: #1f2742;
  --line: #2c3557;
  --text: #e9ecf5;
  --muted: #8d96b5;
  --gold: #e8c170;
  --gold2: #fff0c2;
  --red: #ff5d5d;
  --green: #3fd58a;
  --blue: #4c9bf5;
  --radius: 14px;
  --font: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --gN: #b9c4d6;
  --gR: #4c9bf5;
  --gSR: #b07cf7;
  --gSSR: #f4c542;
  --cw: 200px; /* 카드 기본 너비 — 감싸는 요소에서 덮어씀 */
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 10% -10%, #1b2550 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #2a1a45 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 30px 10px; }
.boot, .empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 8px; }
.empty .btn { margin-top: 18px; }
code { background: var(--panel2); padding: 2px 6px; border-radius: 6px; font-size: .9em; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel2); cursor: pointer; font-weight: 600; text-decoration: none;
  transition: transform .1s, background .2s, border-color .2s;
}
.btn:hover:not(:disabled) { border-color: #4a5684; background: #27304f; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #f3cf7f, #d6a447); color: #2a1d00; border-color: #f3cf7f; }
.btn.danger { background: linear-gradient(180deg, #ff6f6f, #d63a3a); color: #fff; border-color: #ff7b7b; }
.btn.ghost { background: transparent; }
.btn.big { padding: 14px 22px; font-size: 1.1rem; width: 100%; }
.btn.sm { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
.icon-btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; width: 38px; height: 38px; cursor: pointer; font-size: 1.05rem; }

/* ---------- 상단 바 ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 20px;
  background: rgba(11, 14, 26, .75); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 800; text-decoration: none; letter-spacing: -0.02em; font-size: 1.1rem; }
.brand b { color: var(--gold); }
.tb-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.tb-space { flex: 1; }
.badge { font-size: .78rem; padding: 4px 10px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.live { color: var(--green); }
.badge.local { color: #ffb84d; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--tc); box-shadow: 0 0 10px var(--tc); margin-right: 6px; vertical-align: middle; }

/* ---------- 탭 ---------- */
.tabs { display: flex; gap: 6px; padding: 14px 20px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  border: none; background: none; padding: 12px 16px; font-weight: 700; color: var(--muted);
  border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs button.on { color: var(--text); border-bottom-color: var(--gold); }
.tabs .cnt:not(:empty) { background: var(--red); color: #fff; border-radius: 99px; padding: 1px 7px; font-size: .75rem; margin-left: 4px; }
.sec-h { margin: 26px 20px 12px; font-size: 1.05rem; display: flex; align-items: baseline; gap: 8px; }
.sec-h small { color: var(--muted); font-weight: 500; }

/* ---------- 토스트 ---------- */
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #222a47; border: 1px solid var(--line); padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: 0 10px 30px #0008; animation: toastIn .3s ease; transition: opacity .4s, transform .4s; }
.toast.good { border-color: var(--green); }
.toast.bad { border-color: var(--red); }
.toast.out { opacity: 0; transform: translateY(10px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- 효과 레이어 ---------- */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 300; overflow: hidden; }
.fx-p { position: absolute; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.fx-flash { position: absolute; inset: 0; mix-blend-mode: screen; }
.fx-float { position: absolute; font-weight: 900; font-size: 2rem; text-shadow: 0 3px 0 #000a, 0 0 18px currentColor; white-space: nowrap; }
.fx-float.dmg { color: #ff5252; }
.fx-float.dmg.big { font-size: 3.4rem; }
.fx-float.gain { color: #7dffb2; font-size: 1.3rem; }

/* =========================================================
 * 카드
 * ========================================================= */
.hcard {
  width: var(--cw); aspect-ratio: 63 / 88; position: relative;
  font-size: calc(var(--cw) / 14); border-radius: calc(var(--cw) / 14);
  padding: calc(var(--cw) / 36);
  background: var(--frame);
  box-shadow: 0 calc(var(--cw)/40) calc(var(--cw)/10) #0009, inset 0 0 0 1px #ffffff30;
  overflow: hidden; user-select: none;
}

.g-N  .hc-frame, .hcard.g-N  { --gc: var(--gN); }
.hcard.g-N   { --frame: linear-gradient(145deg, #e3e9f2, #8e9bb2 45%, #dfe6f0 70%, #7c879c); }
.hcard.g-R   { --gc: var(--gR);  --frame: linear-gradient(145deg, #9ccbff, #2c6fd1 45%, #8ec2ff 70%, #1f4f9e); }
.hcard.g-SR  { --gc: var(--gSR); --frame: linear-gradient(145deg, #e7cbff, #7b3fd6 40%, #f1a7ff 65%, #5a2aa8); }
.hcard.g-SSR { --gc: var(--gSSR); --frame: linear-gradient(145deg, #fff3c2, #e0a526 30%, #fff8dd 50%, #c98a12 70%, #ffe28a); }

.hc-frame {
  height: 100%; border-radius: calc(var(--cw) / 20);
  background: linear-gradient(180deg, #1b2138, #10142a);
  display: flex; flex-direction: column; padding: calc(var(--cw) / 30); gap: calc(var(--cw) / 60);
}
.hc-top { display: flex; align-items: center; gap: .35em; }
.hc-grade {
  font-weight: 900; font-size: .78em; padding: .1em .45em; border-radius: .35em;
  background: var(--gc); color: #0d1020; letter-spacing: .02em;
}
.g-SSR .hc-grade { background: linear-gradient(90deg, #ffd75e, #ff9f43, #ff6b9d, #6be3ff, #a0ff8a); }
.hc-name { flex: 1; font-weight: 800; font-size: 1em; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-el { font-size: .95em; }
.hc-art {
  flex: 0 0 44%; border-radius: calc(var(--cw) / 30); position: relative; overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--ec) 70%, #fff 0%) 0%, transparent 62%),
    repeating-linear-gradient(45deg, #ffffff08 0 6px, transparent 6px 12px),
    linear-gradient(160deg, color-mix(in srgb, var(--ec) 40%, #0b0e1a), #0b0e1a);
  display: grid; place-items: center; border: 1px solid #ffffff22;
  background-size: cover; background-position: center;
}
.hc-art.has-img { background-size: cover; }
.hc-art-icon { font-size: 2.6em; filter: drop-shadow(0 4px 10px #0008); z-index: 1; }
.hc-art-word { position: absolute; right: .1em; bottom: -.25em; font-size: 4.2em; font-weight: 900; color: #ffffff12; line-height: 1; }
.hc-era { position: absolute; left: .4em; top: .4em; font-size: .6em; background: #000a; padding: .15em .5em; border-radius: 99px; font-weight: 600; }
.hc-type { font-size: .62em; color: var(--gc); font-weight: 800; letter-spacing: .02em; }
.hc-text {
  flex: 1; font-size: .64em; line-height: 1.4; color: #c8cee3; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical;
  background: #ffffff08; border-radius: .4em; padding: .4em .5em;
}
.hc-stats { display: flex; justify-content: space-between; align-items: center; font-size: .6em; font-weight: 700; color: var(--muted); }
.hc-atk b { color: #ff7b7b; font-size: 1.5em; font-weight: 900; }
.hc-holo {
  position: absolute; inset: 0; pointer-events: none; mix-blend-mode: color-dodge; opacity: .35;
  background: linear-gradient(115deg, transparent 20%, #ff6b9d 35%, #ffd75e 45%, #6be3ff 55%, #a0ff8a 65%, transparent 80%);
  background-size: 300% 100%; background-repeat: no-repeat; animation: holo 4s ease-in-out infinite alternate;
}
.g-SR .hc-holo { opacity: .18; }
@keyframes holo { from { background-position: 100% 0; } to { background-position: 0% 0; } }

/* 카드 뒷면 */
.hback { --frame: linear-gradient(145deg, #3a2a10, #c99a3d 30%, #4a3510 60%, #e8c170); }
.hb-inner {
  height: 100%; border-radius: calc(var(--cw) / 20); position: relative; display: grid; place-items: center; overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, #3b1f5e 0%, #170d2b 60%, #0b0716 100%);
}
.hb-inner::before {
  content: ""; position: absolute; inset: 0; opacity: .35;
  background:
    repeating-conic-gradient(from 0deg at 50% 50%, #e8c17033 0deg 6deg, transparent 6deg 18deg),
    repeating-linear-gradient(0deg, transparent 0 14px, #e8c17014 14px 15px),
    repeating-linear-gradient(90deg, transparent 0 14px, #e8c17014 14px 15px);
}
.hb-ring { position: absolute; width: 62%; aspect-ratio: 1; border-radius: 50%; border: calc(var(--cw)/60) double var(--gold); box-shadow: 0 0 30px #e8c17055, inset 0 0 30px #e8c17033; }
.hb-emblem { font-size: 3.6em; font-weight: 900; color: var(--gold); text-shadow: 0 0 20px #e8c170aa; z-index: 1; font-family: "Noto Serif KR", serif; }
.hb-title { position: absolute; bottom: 9%; font-size: .55em; letter-spacing: .3em; text-align: center; color: #e8c170cc; font-weight: 700; line-height: 1.5; }

/* 3D 플립 */
.flip { perspective: 1200px; width: var(--cw); aspect-ratio: 63/88; }
.flip-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .8s cubic-bezier(.2, .8, .2, 1); }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flip-front { transform: rotateY(180deg); }
.flip.is-flipped .flip-inner { transform: rotateY(180deg); }
.flip.anim-reveal .flip-inner { animation: flipReveal 1.2s cubic-bezier(.3, .7, .2, 1) forwards; transition: none; }
@keyframes flipReveal {
  0%   { transform: rotateY(0) scale(1); }
  25%  { transform: rotateY(-15deg) scale(1.08) translateY(-10px); }
  45%  { transform: rotateY(90deg) scale(1.2) translateY(-24px); }
  75%  { transform: rotateY(200deg) scale(1.05); }
  100% { transform: rotateY(180deg) scale(1); }
}
.flip.anim-throw { animation: throwIn .8s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes throwIn { from { transform: translate(-60vw, -20vh) rotate(-40deg) scale(.6); opacity: 0; } }

/* 미니 카드 그리드 */
.card-grid { display: flex; flex-wrap: wrap; gap: 16px; padding: 0 20px; --cw: 158px; }
.mini { position: relative; cursor: default; transition: transform .2s; }
.mini[data-action] { cursor: pointer; }
.mini[data-action]:hover { transform: translateY(-6px) rotate(-1deg); }
.mini.sel { transform: translateY(-8px); }
.mini.sel .hcard { outline: 3px solid var(--gold); outline-offset: 3px; box-shadow: 0 0 30px #e8c17088; }
.mini.cant .hcard { filter: saturate(.4) brightness(.75); }
.mini.used .hcard { filter: grayscale(1) brightness(.5); }
.ribbon {
  position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%);
  font-size: .72rem; font-weight: 800; padding: 3px 10px; border-radius: 99px; white-space: nowrap;
  background: #333c5e; border: 1px solid #ffffff22;
}
.st-blank { background: #ffb84d; color: #2a1a00; animation: bob 1.6s ease-in-out infinite; }
.st-pending { background: #4c6ef5; }
.st-rejected { background: var(--red); }
.st-approved { background: var(--green); color: #002914; }
.st-inBattle { background: #ff7b3a; }
@keyframes bob { 50% { transform: translateX(-50%) translateY(-3px); } }

/* 원소 */
.pill {
  display: inline-flex; align-items: center; gap: 3px; padding: 3px 8px; border-radius: 99px;
  background: color-mix(in srgb, var(--ec) 18%, #141a2f); border: 1px solid color-mix(in srgb, var(--ec) 50%, transparent);
  font-size: .9rem;
}
.pill b { font-weight: 800; }
.pill.sm { font-size: .78rem; padding: 2px 6px; }
.pill.pick { --ec: var(--gold); color: var(--gold); font-weight: 800; }
.pill.gain { animation: gain 1s ease; }
@keyframes gain { 30% { transform: scale(1.4); box-shadow: 0 0 20px var(--ec); } }
.pill-btn { border: 1px solid var(--ec); background: color-mix(in srgb, var(--ec) 25%, #141a2f); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-weight: 700; }
.pill-btn:hover { background: color-mix(in srgb, var(--ec) 45%, #141a2f); }

/* =========================================================
 * 조 패널 / HP
 * ========================================================= */
.team-strip, .dash-teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; padding: 0 20px 30px; }
.tp {
  position: relative; background: linear-gradient(180deg, var(--panel2), var(--panel)); border-radius: var(--radius);
  padding: 12px 14px; border: 1px solid var(--line); border-top: 4px solid var(--tc); overflow: hidden;
}
.tp.is-me { box-shadow: 0 0 0 2px var(--tc); }
.tp.is-atk { box-shadow: 0 0 24px #ff7b3a66; }
.tp.is-def { box-shadow: 0 0 24px #4c9bf566; animation: defPulse 1.4s ease-in-out infinite; }
@keyframes defPulse { 50% { box-shadow: 0 0 40px #4c9bf5aa; } }
.tp-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.tp-name { font-weight: 800; flex: 1; font-size: 1.05rem; }
.tp-tag { font-size: .7rem; font-weight: 800; padding: 2px 7px; border-radius: 6px; }
.tp-tag.atk { background: #ff7b3a; color: #2a0f00; }
.tp-tag.def { background: var(--blue); color: #001a33; }
.tp-tk { font-size: .85rem; color: var(--gold); font-weight: 700; }
.tp-els { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tp.dead { filter: grayscale(1); opacity: .55; }
.tp-ko { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2rem; font-weight: 900; color: var(--red); transform: rotate(-12deg); text-shadow: 0 0 20px #000; letter-spacing: .2em; }
.tp.hit { animation: hit .6s ease; }
@keyframes hit {
  0%, 100% { transform: none; }
  10% { transform: translate(-8px, 2px) rotate(-1deg); background: #5a1a22; }
  30% { transform: translate(7px, -2px) rotate(1deg); }
  50% { transform: translate(-5px, 1px); }
  70% { transform: translate(3px, 0); }
}

.hp { position: relative; height: 22px; background: #0a0d1a; border-radius: 99px; overflow: hidden; border: 1px solid #ffffff18; }
.hp.big { height: 34px; }
.hp-fill, .hp-ghost { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; }
.hp-ghost { background: #fff; opacity: .55; transition: width .8s ease .1s; }
.hp-fill { background: linear-gradient(90deg, #2ecc71, #7dffb2); transition: width .45s cubic-bezier(.3, .9, .3, 1); box-shadow: inset 0 -4px 0 #0002; }
.hp-fill.low { background: linear-gradient(90deg, #ff3b3b, #ff8a65); animation: lowHp 1s ease-in-out infinite; }
@keyframes lowHp { 50% { filter: brightness(1.4); } }
.hp-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 1px; font-weight: 900; font-size: .85rem; text-shadow: 0 1px 3px #000; }
.hp.big .hp-num { font-size: 1.1rem; }
.hp-num small { opacity: .7; font-weight: 600; }

/* =========================================================
 * 전투 무대
 * ========================================================= */
.stage { padding: 20px; }
.stage-vs { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 18px; }
.vs-team { font-size: 1.4rem; font-weight: 900; color: var(--tc); text-shadow: 0 0 18px color-mix(in srgb, var(--tc) 60%, transparent); display: flex; flex-direction: column; align-items: center; }
.vs-team small { font-size: .75rem; color: var(--muted); font-weight: 600; }
.vs-x { font-weight: 900; font-style: italic; font-size: 1.6rem; color: var(--gold); text-shadow: 0 0 20px #e8c17088; }
.stage-body { display: flex; gap: 28px; align-items: flex-start; justify-content: center; flex-wrap: wrap; }
.stage-card { position: relative; --cw: 250px; display: grid; place-items: center; padding: 10px; }
.stage-card .aura { position: absolute; inset: -30px; border-radius: 50%; filter: blur(30px); opacity: 0; transition: opacity .6s; }
.stage-card.g-hidden .aura { background: #6a3fbf; opacity: .35; animation: auraPulse 2s ease-in-out infinite; }
.stage-card.g-N .aura { background: var(--gN); }
.stage-card.g-R .aura { background: var(--gR); }
.stage-card.g-SR .aura { background: var(--gSR); }
.stage-card.g-SSR .aura { background: conic-gradient(#ffd75e, #ff6b9d, #6be3ff, #a0ff8a, #ffd75e); animation: spin 4s linear infinite; }
.stage-card.revealed .aura, .stage-card:not(.g-hidden) .aura { opacity: .45; }
@keyframes auraPulse { 50% { opacity: .55; transform: scale(1.05); } }
@keyframes spin { to { transform: rotate(360deg); } }
.stage-card .flip { position: relative; z-index: 1; }
.stage-card.g-hidden .flip { animation: floaty 3s ease-in-out infinite; }
@keyframes floaty { 50% { transform: translateY(-8px); } }

.verdict-stamp {
  position: absolute; z-index: 3; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-14deg);
  font-size: 3.2rem; font-weight: 900; letter-spacing: .06em; padding: 4px 20px; border: 6px solid; border-radius: 14px;
  opacity: 0; pointer-events: none; background: #0b0e1acc;
}
.verdict-stamp.show { opacity: 1; }
.verdict-stamp.anim { animation: stamp .6s cubic-bezier(.2, 1.6, .4, 1) forwards; }
@keyframes stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-14deg) scale(3); }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(-14deg) scale(1); }
}
.v-great { color: #5dffa8; border-color: #5dffa8; text-shadow: 0 0 20px #5dffa8; }
.v-good { color: #ffd75e; border-color: #ffd75e; text-shadow: 0 0 20px #ffd75e; }
.v-bad { color: #ff5d5d; border-color: #ff5d5d; text-shadow: 0 0 20px #ff5d5d; }

.stage-info { flex: 1 1 340px; max-width: 620px; display: flex; flex-direction: column; gap: 12px; }
.q-box, .a-box, .key-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
}
.q-box { border-left: 5px solid var(--gold); }
.q-label { font-size: .78rem; color: var(--muted); font-weight: 700; margin: 4px 0 4px; letter-spacing: .02em; }
.q-text { font-size: 1.35rem; font-weight: 700; line-height: 1.5; word-break: keep-all; }
.a-box { border-left: 5px solid var(--blue); }
.a-text { font-size: 1.1rem; line-height: 1.5; white-space: pre-wrap; }
.a-box.timeout { border-left-color: var(--red); }
.key-box { border-left: 5px solid var(--green); line-height: 1.55; position: relative; }
.key-box.secret { border-style: dashed; border-left-style: solid; background: #142a20; }
.secret-tag { position: absolute; right: 12px; top: 10px; font-size: .72rem; color: #7dffb2; font-weight: 700; }
.expl { color: #c8cee3; white-space: pre-wrap; }
.hint { color: var(--muted); margin: 4px 0; line-height: 1.5; }
.hint b { color: var(--gold); }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.result { padding: 14px 18px; border-radius: var(--radius); font-weight: 600; line-height: 1.6; border: 2px solid; }
.result b { font-size: 1.3rem; margin-right: 6px; }
.result.r-great { border-color: #5dffa8; background: #0f2e20; }
.result.r-good { border-color: #ffd75e; background: #2e2810; }
.result.r-bad { border-color: #ff5d5d; background: #2e1014; }

.timer {
  --p: 1; width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center; align-self: flex-start;
  background: radial-gradient(closest-side, var(--bg2) 82%, transparent 83% 100%), conic-gradient(var(--gold) calc(var(--p) * 360deg), #2a3150 0);
  position: relative; grid-template-rows: auto auto; align-content: center;
}
.tm-num { font-size: 2.6rem; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.timer small { color: var(--muted); font-size: .75rem; }
.timer.urgent { background: radial-gradient(closest-side, #2a0c12 82%, transparent 83% 100%), conic-gradient(var(--red) calc(var(--p) * 360deg), #2a3150 0); animation: urgent .5s ease-in-out infinite alternate; }
.timer.urgent .tm-num { color: var(--red); }
@keyframes urgent { to { transform: scale(1.08); } }
.answer-form { display: flex; flex-direction: column; gap: 10px; }
.answer-form textarea, .fm-form textarea, .fm-form input, .setup textarea, .setup input, .t-ctrl select, .rv-actions input, .game-switch input, .pin input {
  width: 100%; background: #0d1122; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; resize: vertical; line-height: 1.5;
}
textarea:focus, input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

/* 대기 화면 */
.stage.idle { text-align: center; padding: 50px 20px; }
.idle-title { font-size: 2rem; font-weight: 900; }
.idle-sub { color: var(--muted); margin: 8px 0 30px; }
.rank { list-style: none; padding: 0; margin: 0 auto; max-width: 640px; display: flex; flex-direction: column; gap: 8px; counter-reset: r; }
.rank li { counter-increment: r; display: grid; grid-template-columns: 40px 1fr auto; grid-template-rows: auto auto; align-items: center; text-align: left; background: var(--panel); border-radius: 12px; padding: 10px 16px; border-left: 5px solid var(--tc); }
.rank li::before { content: counter(r); grid-row: span 2; font-weight: 900; font-size: 1.4rem; color: var(--gold); }
.rank li span { font-weight: 800; font-size: 1.15rem; }
.rank li b { grid-row: span 2; font-size: 1.6rem; font-weight: 900; }
.rank li small { color: var(--muted); }
.rank li.out { opacity: .4; }

/* =========================================================
 * 가챠
 * ========================================================= */
.gacha-ov {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  background: radial-gradient(circle at 50% 45%, #1d1640 0%, #07060f 70%); animation: fadeIn .3s ease; overflow: hidden;
}
@keyframes fadeIn { from { opacity: 0; } }
.gacha-rays {
  position: absolute; width: 180vmax; height: 180vmax; left: 50%; top: 45%; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, var(--glow) 0deg 6deg, transparent 6deg 20deg);
  opacity: 0; transition: opacity .8s; animation: spin 20s linear infinite; mask-image: radial-gradient(circle, #000 0%, transparent 55%);
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 55%);
}
.gacha-ov.revealed .gacha-rays { opacity: .25; }
.gacha-ov.g-SSR.revealed .gacha-rays { opacity: .6; background: repeating-conic-gradient(from 0deg, #ffd75e 0 6deg, transparent 6deg 14deg, #ff6b9d 14deg 20deg, transparent 20deg 28deg, #6be3ff 28deg 34deg, transparent 34deg 42deg); }
.gacha-ov.g-SR.revealed .gacha-rays { opacity: .4; }
.gacha-stage { position: relative; width: 300px; height: 420px; display: grid; place-items: center; }

.pack {
  position: absolute; width: 230px; height: 340px; border-radius: 16px; cursor: pointer;
  background: linear-gradient(150deg, #5a2aa8, #22114a 40%, #7a1f4f 70%, #e8c170);
  box-shadow: 0 30px 60px #000a, inset 0 0 0 3px #e8c17088, inset 0 0 40px #0008;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; overflow: hidden;
  animation: packDrop .7s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes packDrop { from { transform: translateY(-80vh) rotate(-20deg); } }
.pack:hover { filter: brightness(1.1); }
.pack-top { position: absolute; top: 0; left: 0; right: 0; height: 26px; background: repeating-linear-gradient(90deg, #e8c170 0 8px, #b88a2e 8px 16px); clip-path: polygon(0 0, 100% 0, 100% 60%, 95% 100%, 90% 60%, 85% 100%, 80% 60%, 75% 100%, 70% 60%, 65% 100%, 60% 60%, 55% 100%, 50% 60%, 45% 100%, 40% 60%, 35% 100%, 30% 60%, 25% 100%, 20% 60%, 15% 100%, 10% 60%, 5% 100%, 0 60%); }
.pack-shine { position: absolute; inset: -50%; background: linear-gradient(115deg, transparent 40%, #ffffff55 50%, transparent 60%); animation: shine 2.4s ease-in-out infinite; }
@keyframes shine { from { transform: translateX(-60%); } to { transform: translateX(60%); } }
.pack-seal { width: 90px; height: 90px; border-radius: 50%; display: grid; place-items: center; font-size: 3rem; font-weight: 900; color: #2a1d00; background: radial-gradient(circle, #fff0c2, #e8c170 60%, #a8781f); box-shadow: 0 0 30px #e8c170aa; z-index: 1; }
.pack-title { font-size: 1.5rem; font-weight: 900; text-align: center; line-height: 1.25; z-index: 1; text-shadow: 0 2px 8px #000; }
.pack-sub { font-size: .62rem; letter-spacing: .2em; color: var(--gold); z-index: 1; }
.pack.shaking { animation: shake .12s linear infinite; box-shadow: 0 0 40px var(--glow), inset 0 0 0 3px #e8c17088; }
.pack.shaking-hard { animation: shakeHard .07s linear infinite; box-shadow: 0 0 90px 20px var(--glow), inset 0 0 60px var(--glow); }
@keyframes shake { 0% { transform: translate(0, 0) rotate(0); } 25% { transform: translate(-4px, 2px) rotate(-2deg); } 50% { transform: translate(3px, -2px) rotate(1.5deg); } 75% { transform: translate(-2px, -1px) rotate(-1deg); } }
@keyframes shakeHard { 0% { transform: translate(0, 0) rotate(0) scale(1.03); } 25% { transform: translate(-9px, 4px) rotate(-4deg) scale(1.05); } 50% { transform: translate(8px, -5px) rotate(4deg) scale(1.04); } 75% { transform: translate(-6px, -3px) rotate(-3deg) scale(1.06); } }
.pack.burst { animation: burst .45s ease-out forwards; pointer-events: none; }
@keyframes burst { to { transform: scale(1.8); opacity: 0; filter: brightness(3) blur(6px); } }
.gacha-card { opacity: 0; transform: scale(.3) rotate(-30deg); pointer-events: none; }
.gacha-card.show { pointer-events: auto; animation: cardIn .7s cubic-bezier(.2, 1.4, .4, 1) forwards; }
@keyframes cardIn { to { opacity: 1; transform: scale(1) rotate(0); } }
.gacha-caption { font-size: 1.3rem; font-weight: 800; text-align: center; z-index: 1; min-height: 3.4em; padding: 0 20px; line-height: 1.5; }
.gacha-caption small { display: block; font-size: .9rem; color: var(--muted); font-weight: 500; }
.cap-grade { font-weight: 900; padding: 2px 10px; border-radius: 8px; margin-right: 4px; background: var(--glow); color: #0d1020; }
.g-SSR .cap-grade { background: linear-gradient(90deg, #ffd75e, #ff9f43, #ff6b9d, #6be3ff); }
.gacha-actions { display: flex; gap: 10px; z-index: 1; min-height: 46px; }

/* =========================================================
 * 모달 (카드 제작)
 * ========================================================= */
.modal-ov { position: fixed; inset: 0; background: #000b; z-index: 90; display: grid; place-items: center; padding: 20px; animation: fadeIn .2s; overflow-y: auto; }
.modal { position: relative; background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; max-width: 980px; width: 100%; display: flex; gap: 28px; padding: 28px; flex-wrap: wrap; box-shadow: 0 30px 80px #000c; }
.modal-x { position: absolute; right: 14px; top: 12px; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--muted); }
.fm-left { display: flex; flex-direction: column; gap: 14px; align-items: center; flex: 0 0 250px; margin: 0 auto; }
.fm-card { --cw: 230px; }
.guide { background: var(--panel); border-radius: 12px; padding: 14px; font-size: .9rem; line-height: 1.55; border: 1px solid var(--line); }
.guide p { margin: 6px 0 0; }
.guide-type { font-weight: 900; color: var(--gold); }
.guide .ex { color: var(--muted); }
.fm-form { flex: 1 1 380px; display: flex; flex-direction: column; gap: 14px; }
.fm-form h2 { font-size: 1.35rem; }
.fm-form label, .setup label, .t-ctrl label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.fm-form label small, .setup label small { color: var(--muted); font-weight: 500; }
.reject-note { background: #3a1218; border: 1px solid var(--red); border-radius: 10px; padding: 10px 14px; }
.fm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* =========================================================
 * 홈
 * ========================================================= */
.home-hero { text-align: center; padding: 60px 20px 30px; }
.home-hero h1 { font-size: clamp(2.4rem, 7vw, 4.4rem); font-weight: 900; }
.home-hero h1 b { color: var(--gold); text-shadow: 0 0 30px #e8c17066; }
.home-hero p { color: var(--muted); font-size: 1.15rem; margin-top: 6px; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; max-width: 760px; margin: 0 auto; padding: 0 20px; }
.mode-card { display: flex; flex-direction: column; gap: 6px; padding: 26px; border-radius: 18px; background: linear-gradient(160deg, var(--panel2), var(--panel)); border: 1px solid var(--line); text-decoration: none; transition: transform .2s, border-color .2s; }
.mode-card:hover { transform: translateY(-4px); border-color: var(--gold); }
.mode-card span { font-size: 2.2rem; }
.mode-card b { font-size: 1.25rem; }
.mode-card small { color: var(--muted); }
.home-h3 { text-align: center; margin: 40px 0 14px; }
.home-teams { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 0 20px; }
.team-link { padding: 14px 26px; border-radius: 14px; background: var(--panel); border: 2px solid var(--tc); font-weight: 800; text-decoration: none; font-size: 1.1rem; }
.team-link:hover { background: color-mix(in srgb, var(--tc) 25%, var(--panel)); }
.game-switch-old { display: flex; gap: 8px; max-width: 420px; margin: 40px auto; padding: 0 20px; align-items: flex-end; }
.game-switch label { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); }

/* =========================================================
 * 학생 화면
 * ========================================================= */
.my-status { padding: 16px 20px 0; }
.ms { display: grid; grid-template-columns: 2fr 2fr auto; gap: 18px; align-items: end; background: linear-gradient(160deg, var(--panel2), var(--panel)); border: 1px solid var(--line); border-top: 4px solid var(--tc); border-radius: var(--radius); padding: 16px 18px; position: relative; }
.ms.hit { animation: hit .6s ease; }
.ms.dead { filter: grayscale(.8); }
.ms-label { font-size: .78rem; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.els { display: flex; flex-wrap: wrap; gap: 6px; }
.tk { font-size: 1.4rem; } .tk b { color: var(--gold); font-size: 1.8rem; }
.picks { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: #2b2410; border: 1px solid var(--gold); border-radius: 12px; padding: 10px 14px; animation: pulse 2s ease-in-out infinite; }
.ms-ko { grid-column: 1 / -1; color: var(--red); font-weight: 800; }
.battle-slot { margin: 16px 20px 0; border-radius: 18px; }
.battle-slot.on { background: linear-gradient(160deg, #1a1530, #10142a); border: 1px solid #3b2f66; }
.battle-slot.defending { border: 2px solid var(--blue); box-shadow: 0 0 40px #4c9bf544; }
.battle-slot.defending::before { content: "🛡️ 우리 조가 공격받고 있다! 질문에 답하세요"; display: block; text-align: center; padding: 10px; background: var(--blue); color: #001a33; font-weight: 900; border-radius: 16px 16px 0 0; }

.pack-zone { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding: 20px 20px 0; }
.pack-btn {
  display: flex; align-items: center; gap: 16px; padding: 14px 24px 14px 14px; border-radius: 16px; cursor: pointer; text-align: left;
  background: linear-gradient(135deg, #3b1f6e, #1c1240); border: 2px solid var(--gold); box-shadow: 0 0 30px #e8c17033; transition: transform .15s;
}
.pack-btn:hover:not(:disabled) { transform: translateY(-3px) scale(1.02); box-shadow: 0 0 40px #e8c17066; }
.pack-btn:disabled { opacity: .45; cursor: not-allowed; }
.pack-btn b { display: block; font-size: 1.25rem; }
.pack-btn small { color: var(--muted); }
.mini-pack { width: 54px; height: 76px; border-radius: 8px; display: grid; place-items: center; background: linear-gradient(150deg, #5a2aa8, #22114a 50%, #e8c170); box-shadow: inset 0 0 0 2px #e8c17088; }
.mini-pack i { font-style: normal; font-weight: 900; color: var(--gold); font-size: 1.5rem; }
.pack-btn:hover:not(:disabled) .mini-pack { animation: shake .15s linear infinite; }
.rates { display: flex; gap: 6px; flex-wrap: wrap; }
.rate { font-size: .8rem; font-weight: 800; padding: 4px 10px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); }
.gtag { padding: 2px 8px; border-radius: 6px; color: #0d1020; }
.rate.g-N, .gtag.g-N { color: var(--gN); } .gtag.g-N { background: var(--gN); color: #0d1020; }
.rate.g-R { color: var(--gR); } .gtag.g-R { background: var(--gR); color: #0d1020; }
.rate.g-SR { color: var(--gSR); } .gtag.g-SR { background: var(--gSR); color: #0d1020; }
.rate.g-SSR { color: var(--gSSR); } .gtag.g-SSR { background: linear-gradient(90deg, #ffd75e, #ff9f43, #ff6b9d); color: #0d1020; }

.card-grid + .sec-h, .forge .card-grid { margin-bottom: 18px; }
.targets { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 20px; }
.target { padding: 14px 22px; border-radius: 14px; background: var(--panel); border: 2px solid var(--line); border-left: 6px solid var(--tc); cursor: pointer; font-weight: 800; font-size: 1.05rem; display: flex; flex-direction: column; align-items: flex-start; }
.target small { color: var(--muted); font-weight: 600; font-size: .8rem; }
.target.sel { border-color: var(--red); background: #2e1418; box-shadow: 0 0 20px #ff5d5d55; }
.attack-bar { position: sticky; bottom: 0; margin: 20px 0 0; padding: 14px 20px; display: flex; gap: 16px; align-items: center; justify-content: space-between; background: rgba(11, 14, 26, .92); border-top: 1px solid var(--line); backdrop-filter: blur(8px); flex-wrap: wrap; }
.attack-bar .btn.big { width: auto; min-width: 200px; }

/* =========================================================
 * 대시보드 (프로젝터)
 * ========================================================= */
body[data-view="dashboard"] { overflow: hidden; }
.dash { height: 100vh; display: grid; grid-template-rows: auto auto 1fr auto; }
.dash-head { display: flex; align-items: center; gap: 10px; padding: 12px 24px; }
.dash-head .brand { font-size: 1.5rem; }
.dash-teams { padding: 0 24px 6px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.dash-teams .tp-name { font-size: 1.2rem; }
.dash-stage { overflow: auto; display: flex; align-items: center; justify-content: center; }
.dash-stage > .stage { width: 100%; }
.dash-stage .stage-card { --cw: min(300px, 26vw); }
.dash-stage .q-text { font-size: clamp(1.4rem, 2.4vw, 2.2rem); }
.dash-stage .vs-team { font-size: 2rem; }
.dash-stage .timer { width: 140px; height: 140px; }
.dash-stage .tm-num { font-size: 3.4rem; }
.dash-log { display: flex; gap: 22px; padding: 10px 24px; overflow: hidden; white-space: nowrap; font-size: .9rem; color: var(--muted); border-top: 1px solid var(--line); background: #0008; }
.dash-log span:first-child { color: var(--text); font-weight: 700; }
.log-ko { color: var(--red) !important; }
.log-great { color: #5dffa8 !important; }

/* =========================================================
 * 교사 화면
 * ========================================================= */
.t-battle { display: grid; grid-template-columns: 1fr 320px; gap: 18px; padding: 18px 20px 0; align-items: start; }
.t-stage { background: linear-gradient(160deg, #1a1530, #10142a); border: 1px solid #3b2f66; border-radius: 18px; min-height: 300px; }
.t-stage:empty::before { content: "진행 중인 전투가 없습니다. 오른쪽에서 새 전투를 시작하세요."; display: block; padding: 120px 20px; text-align: center; color: var(--muted); }
.t-stage .stage-card { --cw: 210px; }
.t-ctrl { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 76px; }
.t-ctrl h3 { font-size: 1.1rem; }
label.chk { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 600 !important; }
label.chk input { width: auto; }
.verdicts { display: flex; flex-direction: column; gap: 10px; }
.vbtn { border: 2px solid; border-radius: 14px; padding: 14px; cursor: pointer; background: #0d1122; text-align: left; display: flex; flex-direction: column; gap: 2px; transition: transform .1s; text-shadow: none; }
.vbtn b { font-size: 1.5rem; font-weight: 900; }
.vbtn small { color: var(--muted); font-size: .8rem; }
.vbtn:hover { transform: scale(1.02); background: #161b33; }
.t-pane { padding: 0 0 40px; }
.review-row { display: flex; gap: 20px; margin: 0 20px 16px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; flex-wrap: wrap; }
.rv-card { --cw: 170px; }
.rv-body { flex: 1 1 320px; line-height: 1.55; }
.rv-team { font-weight: 800; color: var(--tc); margin-bottom: 6px; }
.rv-q { font-size: 1.15rem; font-weight: 700; }
.rv-actions { display: flex; gap: 8px; margin-top: 14px; }
.rv-actions input { flex: 1; }
.tbl-wrap { overflow-x: auto; padding: 0 20px; }
.tbl { border-collapse: collapse; width: calc(100% - 40px); margin: 0 20px; font-size: .92rem; }
.tbl-wrap .tbl { margin: 0; width: 100%; }
.tbl th, .tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 700; font-size: .82rem; }
.tbl td:first-child, .tbl th:first-child { text-align: left; }
.teams-tbl tr.dead td { opacity: .5; }
.adj button { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; font-weight: 800; }
.adj b { display: inline-block; min-width: 32px; }
.name-in { background: transparent; border: 1px solid transparent; border-left: 4px solid var(--tc); padding: 6px 8px; border-radius: 6px; font-weight: 800; width: 120px; }
.name-in:hover, .name-in:focus { border-color: var(--line); border-left-color: var(--tc); }
.log-list { list-style: none; padding: 0 20px; margin: 0; font-size: .9rem; display: flex; flex-direction: column; gap: 6px; }
.log-list time { color: var(--muted); margin-right: 10px; font-variant-numeric: tabular-nums; }
.setup { padding: 0 20px 40px; display: flex; flex-direction: column; gap: 14px; max-width: 900px; }
.setup .sec-h { margin-left: 0; }
.setup .row { display: flex; gap: 12px; flex-wrap: wrap; }
.setup .row label { flex: 1 1 150px; }
.rules { margin-top: 20px; }
.rules h4 { margin-bottom: 10px; }
.rules .tbl { margin: 0; width: 100%; }
.pin { max-width: 340px; margin: 80px auto; display: flex; flex-direction: column; gap: 12px; text-align: center; padding: 0 20px; }

/* ---------- 반응형 ---------- */
@media (max-width: 860px) {
  .t-battle { grid-template-columns: 1fr; }
  .t-ctrl { position: static; }
  .ms { grid-template-columns: 1fr; }
  .stage-card { --cw: 200px; }
  .topbar .badge.code { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* =========================================================
 * 교사: 카드 설정 탭
 * ========================================================= */
.cards-cfg { padding-bottom: 40px; }
.grade-cfg { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; padding: 0 20px; }
.gc-item { background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--gc, var(--line)); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.gc-item.g-N { --gc: var(--gN); } .gc-item.g-R { --gc: var(--gR); } .gc-item.g-SR { --gc: var(--gSR); } .gc-item.g-SSR { --gc: var(--gSSR); }
.gc-item > span { font-weight: 700; }
.gc-item label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .9rem; color: var(--muted); }
.gc-item input { width: 90px; background: #0d1122; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; text-align: right; }
.gc-item small { color: var(--muted); }
.gc-save { grid-column: 1 / -1; display: flex; justify-content: flex-end; align-items: center; gap: 14px; }
.warn { color: var(--red); font-weight: 800; }
.pool-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 0 20px 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 700; }
.chip.on { background: var(--gold); color: #2a1d00; border-color: var(--gold); }
.pool-grid { --cw: 150px; row-gap: 26px; }
.pool-item.off .hcard { filter: grayscale(1) brightness(.5); }
.bulk { padding: 0 20px; display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.bulk textarea { width: 100%; background: #0d1122; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; line-height: 1.6; }
.bulk .row { display: flex; gap: 10px; flex-wrap: wrap; }
.capacity { margin: 26px 20px 0; max-width: 760px; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.cap-bar { height: 10px; border-radius: 99px; background: #0a0d1a; overflow: hidden; border: 1px solid var(--line); }
.cap-bar i { display: block; height: 100%; background: var(--green); }
.cap-bar i.warn { background: var(--red); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fm-form select, .setup select { width: 100%; background: #0d1122; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.img-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; color: var(--muted); font-weight: 500; transition: .2s; }
.drop.over { border-color: var(--gold); background: #2b2410; color: var(--gold); }
.center-s { text-align: center; margin: 0; font-size: .85rem; }
.fm-actions { align-items: center; }

/* =========================================================
 * 공격 차례 표시줄
 * ========================================================= */
.turn-slot:empty, .dash-turn:empty { display: none; }
.turn-slot { padding: 14px 20px 0; }
.dash-turn { padding: 0 24px 4px; }
.turn-strip { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; }
.ts-round { font-weight: 900; color: var(--gold); background: #2b2410; border: 1px solid var(--gold); border-radius: 8px; padding: 3px 10px; font-size: .85rem; }
.ts-label { color: var(--muted); font-size: .85rem; font-weight: 700; }
.ts-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; }
.ts-chip { padding: 4px 12px; border-radius: 99px; border: 1px solid color-mix(in srgb, var(--tc) 60%, transparent); background: color-mix(in srgb, var(--tc) 12%, var(--panel)); font-weight: 700; font-size: .9rem; }
.ts-chip.now { background: var(--tc); color: #0b0e1a; font-weight: 900; box-shadow: 0 0 18px color-mix(in srgb, var(--tc) 60%, transparent); animation: nowPulse 1.6s ease-in-out infinite; }
@keyframes nowPulse { 50% { transform: scale(1.06); } }
.ts-chip.me { outline: 2px solid #fff; outline-offset: 1px; }
.ts-chip.out { opacity: .35; text-decoration: line-through; --tc: #666; }
.ts-arrow { color: var(--muted); font-style: normal; }
.ts-me { font-size: .9rem; color: var(--muted); }
.ts-me b { color: var(--gold); }
.dash-turn .turn-strip { padding: 8px 14px; }
.dash-turn .ts-chip { font-size: 1rem; }
.turn-box { background: color-mix(in srgb, var(--tc) 14%, #0d1122); border: 1px solid var(--tc); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.turn-box b { color: var(--tc); font-size: 1.1rem; }
.turn-box .row { display: flex; gap: 6px; flex-wrap: wrap; }
.warn-note { margin: 0; font-size: .85rem; color: #ffb84d; line-height: 1.5; }

/* =========================================================
 * 조별 카드덱
 * ========================================================= */
.decks { padding-bottom: 40px; }
.decks-view .decks { padding-top: 16px; }
.deck-chips { display: flex; gap: 8px; flex-wrap: wrap; padding: 16px 20px 0; }
.deck-chip { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 12px; border: 2px solid var(--line); border-left: 6px solid var(--tc); background: var(--panel); cursor: pointer; font-weight: 800; }
.deck-chip b { background: #0b0e1a; border-radius: 8px; padding: 1px 8px; color: var(--gold); }
.deck-chip.on { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 18%, var(--panel)); }
.deck-chip.out { opacity: .5; }
.deck-head { margin: 16px 20px 18px; padding: 18px; border-radius: 16px; background: linear-gradient(160deg, color-mix(in srgb, var(--tc) 14%, var(--panel2)), var(--panel)); border: 1px solid var(--line); border-top: 4px solid var(--tc); display: grid; grid-template-columns: auto 1fr; gap: 14px 28px; align-items: center; }
.dh-name { font-size: 1.6rem; font-weight: 900; color: var(--tc); }
.dh-name small { font-size: .9rem; color: var(--red); }
.dh-stats { display: flex; gap: 22px; flex-wrap: wrap; }
.dh-stats span { display: flex; flex-direction: column; color: var(--muted); font-size: .8rem; font-weight: 600; }
.dh-stats b { font-size: 1.6rem; color: var(--text); font-weight: 900; line-height: 1.1; }
.dh-dist { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px 18px; align-items: center; }
.dd { display: grid; grid-template-columns: 46px 1fr 28px; align-items: center; gap: 8px; }
.dd .gtag { text-align: center; font-weight: 900; font-size: .8rem; }
.dd i { display: block; height: 10px; border-radius: 99px; min-width: 3px; }
.dd.g-N i { background: var(--gN); } .dd.g-R i { background: var(--gR); } .dd.g-SR i { background: var(--gSR); }
.dd.g-SSR i { background: linear-gradient(90deg, #ffd75e, #ff9f43, #ff6b9d, #6be3ff); }
.dd b { text-align: right; }
.dd-hidden { color: var(--muted); font-weight: 700; }
.dh-els { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.dh-els .pill b { margin-left: 4px; }
.deck-grid { --cw: 160px; row-gap: 26px; }
.deck-grid .mini { cursor: pointer; }
.deck-grid .mini:hover { transform: translateY(-6px); }
.hidden-card { cursor: default !important; }
.hidden-card:hover { transform: none !important; }
.deck-note { padding: 0 20px; margin-top: 22px; }
.detail-modal .fm-form { gap: 12px; }
@media (max-width: 860px) { .deck-head { grid-template-columns: 1fr; } }

.warn-box { margin-top: 18px; background: #2e2410; border: 1px solid #ffb84d; color: #ffd9a0; border-radius: 12px; padding: 12px 14px; line-height: 1.55; }
.import .row { display: flex; gap: 8px; flex-wrap: wrap; }
.import input, .import select { flex: 1 1 200px; background: #0d1122; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.pin .small { font-size: .82rem; }

/* 게임 코드 입력 */
.code-entry { max-width: 560px; margin: 10px auto 30px; padding: 26px; background: linear-gradient(160deg, var(--panel2), var(--panel)); border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: 18px; display: flex; flex-direction: column; gap: 12px; }
.code-entry h2 { font-size: 1.3rem; }
.code-entry p { margin: 0; line-height: 1.5; font-size: .9rem; }
.code-entry input { font-size: 1.5rem; font-weight: 800; text-align: center; letter-spacing: .04em; padding: 14px; border-radius: 12px; background: #0d1122; border: 2px solid var(--line); }
.code-entry input:focus { border-color: var(--gold); }
.code-preview { min-height: 1.2em; text-align: center; font-size: .9rem; }
.code-preview b { color: var(--gold); }
.ce-btns { display: flex; flex-direction: column; gap: 8px; }
.recent { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); font-size: .9rem; }
.recent .chip { text-decoration: none; font-size: .85rem; padding: 4px 12px; }
.how { max-width: 760px; margin: 0 auto 40px; padding: 0 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.how > div { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; line-height: 1.6; font-size: .92rem; color: #c8cee3; }
.how b { display: block; color: var(--text); margin-bottom: 4px; }
.code-big { color: var(--gold); font-size: 1.3em; letter-spacing: .04em; }
.home .warn-note { max-width: 640px; margin: 0 auto; padding: 0 20px; }
@media (max-width: 700px) { .how { grid-template-columns: 1fr; } }

/* =========================================================
 * 여러 전투 동시 진행 (보드)
 * ========================================================= */
.board { display: grid; gap: 14px; }
.board.count-0 { display: none; }
.board.count-1 { grid-template-columns: 1fr; }
.board.count-2, .board.count-3, .board.count-4 { grid-template-columns: repeat(auto-fit, minmax(520px, 1fr)); }
.board-item { background: linear-gradient(160deg, #1a1530, #10142a); border: 1px solid #3b2f66; border-radius: 18px; animation: fadeIn .4s ease; transition: opacity .4s, transform .4s; }
.board-item.leaving { opacity: 0; transform: scale(.96); }
.board-item.is-def { border: 2px solid var(--blue); box-shadow: 0 0 40px #4c9bf544; }
.board-item.is-def::before { content: "🛡️ 우리 조가 공격받고 있다!"; display: block; text-align: center; padding: 8px; background: var(--blue); color: #001a33; font-weight: 900; border-radius: 16px 16px 0 0; }
.board-item.is-atkjudge { border: 2px solid var(--gold); box-shadow: 0 0 40px #e8c17044; }
.board-item.is-dispute { border: 2px solid var(--red); box-shadow: 0 0 40px #ff5d5d55; animation: disputePulse 1.6s ease-in-out infinite; }
@keyframes disputePulse { 50% { box-shadow: 0 0 60px #ff5d5d88; } }
.board:not(.count-1) .stage { padding: 14px; }
.board:not(.count-1) .stage-card { --cw: 170px; }
.board:not(.count-1) .q-text { font-size: 1.1rem; }
.board:not(.count-1) .vs-team { font-size: 1.15rem; }
.board:not(.count-1) .timer { width: 86px; height: 86px; }
.board:not(.count-1) .tm-num { font-size: 2rem; }
.board:not(.count-1) .stage-body { gap: 16px; }
.board:not(.count-1) .verdict-stamp { font-size: 2rem; }
.dash-stage .board { width: 100%; padding: 0 24px 10px; }
.dash-stage .board.count-1 .stage-card { --cw: min(300px, 26vw); }
.dash-stage { align-items: flex-start; }
.dash-stage > .board-idle:empty { display: none; }
.battle-slot { margin: 16px 20px 0; }
.battle-slot .board { gap: 12px; }
.t-stage { background: none; border: none; min-height: 0; }
.t-stage:empty::before { content: none; }
.board-empty { padding: 80px 20px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: 18px; margin: 0; }
.ph-badge { margin-left: 10px; font-size: .75rem; font-weight: 800; padding: 3px 10px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.ph-badge.ph-question { color: var(--blue); border-color: var(--blue); }
.ph-badge.ph-reveal { color: var(--gold); border-color: var(--gold); }
.ph-badge.ph-verdict { color: #ffb84d; border-color: #ffb84d; }
.ph-badge.ph-disputed { color: #fff; background: var(--red); border-color: var(--red); }
.ph-badge.ph-judged { color: var(--green); border-color: var(--green); }

.vrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.vrow .vbtn { padding: 10px; }
.vrow .vbtn b { font-size: 1.15rem; }
.vrow .vbtn small { font-size: .72rem; }
.judge-box, .object-box, .dispute-box, .t-judge { border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; line-height: 1.5; }
.judge-box { background: #2b2410; border: 2px solid var(--gold); }
.object-box { background: #10233d; border: 2px solid var(--blue); }
.object-box input { background: #0d1122; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%; }
.object-box .row, .t-judge .row { display: flex; gap: 8px; flex-wrap: wrap; }
.object-box .row .btn { flex: 1; }
.js-otimer { font-weight: 900; color: var(--gold); }
.dispute-box { background: #3a1218; border: 2px solid var(--red); }
.dispute-box .reason { color: #ffd0d0; font-style: italic; }
.t-judge { background: #12182e; border: 1px dashed var(--line); }
.t-judge.urgent { border: 2px solid var(--red); background: #2a1016; }
.result.provisional { border-style: dashed; opacity: .9; }
.prov-tag { font-size: .72rem; font-weight: 900; background: #ffb84d; color: #2a1a00; padding: 2px 8px; border-radius: 6px; margin-right: 6px; vertical-align: middle; }
.verdict-stamp.provisional { border-style: dashed; opacity: .75; font-size: 2.4rem; }
.verdict-stamp.provisional.show, .verdict-stamp.provisional.anim { opacity: .75; }
.tp-tag.rest { background: #2a2f4a; color: #b8c2ff; }
.rank li span em { font-style: normal; font-size: .8rem; color: #b8c2ff; }
.rule-mini { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--muted); background: #0d1122; border-radius: 10px; padding: 10px 12px; }
.rule-mini b { color: var(--text); }
.target.busy { opacity: .45; cursor: not-allowed; }
.t-battle { grid-template-columns: 1fr 300px; }
@media (max-width: 1100px) { .board.count-2, .board.count-3, .board.count-4 { grid-template-columns: 1fr; } }
