/* 스쿨 스타즈 — «공책·포스트잇·스티커» UI. 글자·터치 타깃은 DOM, 월드는 캔버스. 색은 전부 토큰 경유(design-gate). */
:root {
  --background: 45 62% 95%;
  --foreground: 226 36% 15%;
  --card: 0 0% 100%;
  --card-foreground: 226 36% 15%;
  --popover: 0 0% 100%;
  --popover-foreground: 226 36% 15%;
  --primary: 42 96% 55%;
  --primary-foreground: 226 40% 13%;
  --secondary: 212 88% 42%;
  --secondary-foreground: 0 0% 100%;
  --muted: 45 32% 87%;
  --muted-foreground: 226 18% 32%;
  --accent: 24 94% 55%;
  --accent-foreground: 226 40% 12%;
  --destructive: 0 72% 42%;
  --destructive-foreground: 0 0% 100%;
  --border: 226 20% 78%;
  --ring: 212 88% 42%;
  --team-a: 212 88% 48%;
  --team-b: 24 94% 52%;
  --paper-line: 205 60% 85%;
  --shadow: 226 40% 10%;
  --overlay: 226 40% 8%;
  --z-hud: 10;
  --z-overlay: 20;
  --z-modal: 30;
  --z-toast: 40;
  --radius: 14px;
  --fs: 16px;
  font-size: var(--fs);
}
.dark {
  --background: 226 30% 11%;
  --foreground: 45 40% 94%;
  --card: 226 26% 17%;
  --card-foreground: 45 40% 94%;
  --popover: 226 26% 17%;
  --popover-foreground: 45 40% 94%;
  --primary: 42 96% 58%;
  --primary-foreground: 226 40% 11%;
  --secondary: 212 80% 58%;
  --secondary-foreground: 226 40% 10%;
  --muted: 226 20% 22%;
  --muted-foreground: 45 20% 78%;
  --accent: 24 94% 58%;
  --accent-foreground: 226 40% 10%;
  --destructive: 0 80% 62%;
  --destructive-foreground: 226 40% 10%;
  --border: 226 18% 32%;
  --ring: 42 96% 58%;
  --paper-line: 226 20% 20%;
}
.bigtext { --fs: 20px; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: hsl(var(--background));
  background-image: repeating-linear-gradient(0deg, hsl(var(--paper-line)) 0 1px, transparent 1px 32px);
  color: hsl(var(--foreground));
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
input, textarea { -webkit-user-select: text; user-select: text; font: inherit; }

/* 캔버스: 16:9 고정 영역(남는 곳 = 여백, D53). 크기는 JS 가 --gw/--gh 로 준다 */
#stage { position: fixed; inset: 0; display: grid; place-items: center; background: hsl(var(--overlay)); }
#stage[data-idle] { background: transparent; }
#game { width: var(--gw, 100vw); height: var(--gh, 56.25vw); display: block; touch-action: none; }

.screen { position: fixed; inset: 0; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow-y: auto; height: 100dvh; z-index: var(--z-overlay); }
.screen.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.overlay { position: fixed; inset: 0; z-index: var(--z-modal); background: hsl(var(--background)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 16px; }

h1, h2, h3 { margin: 0.2em 0; line-height: 1.25; }
.logo { font-size: 2.2rem; letter-spacing: -0.02em; transform: rotate(-2deg); }
.logo span { color: hsl(var(--accent-foreground)); background: hsl(var(--primary)); padding: 0 0.25em; border-radius: 8px; box-shadow: 3px 3px 0 hsl(var(--shadow) / 0.25); }
.logo.big { font-size: clamp(2.4rem, 8vw, 4.2rem); }
.tagline { font-size: 1.15rem; }
.muted { color: hsl(var(--muted-foreground)); }
.small { font-size: 0.9rem; }
.fine { font-size: 0.85rem; max-width: 34em; }
.center-text { text-align: center; }
.pad { padding: 0 4px; }
.err { color: hsl(var(--destructive)); min-height: 1.4em; font-weight: 600; }

.btn { min-height: 44px; min-width: 44px; padding: 10px 18px; border-radius: var(--radius); border: 2px solid hsl(var(--border));
  background: hsl(var(--card)); color: hsl(var(--card-foreground)); font: inherit; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 0 hsl(var(--shadow) / 0.18); transition: transform 0.08s; touch-action: manipulation; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 hsl(var(--shadow) / 0.18); }
.btn:focus-visible, .mode-card:focus-visible, .choice:focus-visible, input:focus-visible, textarea:focus-visible, .char-cell:focus-visible { outline: 3px solid hsl(var(--ring)); outline-offset: 2px; }
.btn.primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: hsl(var(--primary)); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.xl { font-size: 1.2rem; padding: 14px 26px; min-height: 56px; }
.btn.icon { padding: 6px; width: 48px; height: 48px; font-size: 1.3rem; position: relative; }
.btn.icon.sm { width: 44px; height: 44px; font-size: 1.1rem; }
.btn.icon em { position: absolute; top: 4px; right: 4px; width: 10px; height: 10px; border-radius: 50%; background: hsl(var(--destructive)); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; width: min(420px, 100%); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: hsl(var(--muted)); color: hsl(var(--foreground)); font-weight: 700; }
.chip.star::before { content: "⭐"; }
.card { background: hsl(var(--card)); color: hsl(var(--card-foreground)); border: 2px solid hsl(var(--border)); border-radius: var(--radius); padding: 14px 16px; box-shadow: 4px 4px 0 hsl(var(--shadow) / 0.12); }

.bar { width: min(360px, 80vw); height: 14px; border-radius: 999px; background: hsl(var(--muted)); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: hsl(var(--primary)); transition: width 0.2s; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.topbar h2 { flex: 1; text-align: center; }
.me { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nick { font-weight: 800; }
.iconbar { display: flex; gap: 8px; }

.lobby-grid { display: grid; gap: 14px; max-width: 880px; margin: 0 auto; }
.hero-card { display: flex; gap: 16px; align-items: center; background: hsl(var(--card)); border: 2px solid hsl(var(--border)); border-radius: var(--radius); padding: 12px; box-shadow: 4px 4px 0 hsl(var(--shadow) / 0.12); }
.hero-char img { width: 120px; height: 160px; object-fit: contain; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.mode-card { text-align: left; min-height: 84px; padding: 14px 16px; border-radius: var(--radius); border: 3px solid hsl(var(--border)); background: hsl(var(--card)); color: hsl(var(--card-foreground)); font: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.mode-card b { font-size: 1.15rem; }
.mode-card[aria-pressed="true"] { border-color: hsl(var(--primary)); background: hsl(var(--primary) / 0.18); box-shadow: 4px 4px 0 hsl(var(--primary) / 0.5); }
.play-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.play-row .btn { flex: 1 1 200px; }
.small-row .btn { flex: 1 1 120px; }

.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.char-cell { position: relative; border: 3px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--card)); color: hsl(var(--card-foreground)); padding: 6px; cursor: pointer; min-height: 44px; font: inherit; }
.char-cell img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; display: block; }
.char-cell[aria-pressed="true"] { border-color: hsl(var(--primary)); }
.char-cell.locked img { filter: grayscale(1) brightness(0.6); }
.char-cell .lock { position: absolute; top: 6px; right: 8px; }
.detail { margin-top: 12px; }
.detail table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.detail td { padding: 3px 4px; border-bottom: 1px dashed hsl(var(--border)); }

.road { list-style: none; padding: 0; display: grid; gap: 10px; max-width: 640px; margin: 0 auto; }
.road li { display: flex; gap: 12px; align-items: center; background: hsl(var(--card)); border: 2px solid hsl(var(--border)); border-radius: var(--radius); padding: 10px 12px; }
.road li.done { border-color: hsl(var(--primary)); }
.road img { width: 56px; height: 72px; object-fit: contain; }
.road .prog { flex: 1; }
.road .bar { width: 100%; }

.codex { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.codex .card img { width: 64px; height: 84px; object-fit: contain; float: left; margin-right: 10px; }
.codex .card.locked img { filter: grayscale(1); }
.missions { list-style: none; padding: 0; display: grid; gap: 10px; max-width: 560px; margin: 0 auto; }
.missions li { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.settings { display: grid; gap: 12px; max-width: 640px; margin: 0 auto; }
fieldset { border: 2px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--card)); padding: 10px 14px; display: grid; gap: 8px; }
legend { font-weight: 800; padding: 0 6px; }
label.row { justify-content: flex-start; min-height: 44px; }
input[type="checkbox"] { width: 24px; height: 24px; accent-color: hsl(var(--secondary)); }
input[type="range"] { width: 100%; min-height: 32px; accent-color: hsl(var(--secondary)); }
textarea { width: 100%; border-radius: 10px; border: 2px solid hsl(var(--border)); padding: 8px; background: hsl(var(--background)); color: hsl(var(--foreground)); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; min-height: 44px; padding: 0 10px; border-radius: 10px; background: hsl(var(--muted)); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { min-height: 44px; padding: 6px 14px; border-radius: 10px; border: 2px solid hsl(var(--border)); background: hsl(var(--background)); color: hsl(var(--foreground)); font: inherit; font-weight: 700; cursor: pointer; }
.seg button[aria-pressed="true"] { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); border-color: hsl(var(--secondary)); }

.class-top { text-align: center; }
.code { font-size: 2.4rem; font-weight: 900; letter-spacing: 0.25em; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); display: inline-block; padding: 4px 16px; border-radius: 12px; }
.seats { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; max-width: 760px; margin: 12px auto; }
.seats li { display: flex; align-items: center; gap: 8px; justify-content: space-between; background: hsl(var(--card)); border: 2px solid hsl(var(--border)); border-radius: 10px; padding: 6px 10px; min-height: 48px; }
#class-host { max-width: 760px; margin: 0 auto; display: grid; gap: 8px; }
.codebox { font-size: 2rem; text-align: center; letter-spacing: 0.3em; width: min(320px, 90vw); text-transform: uppercase; border-radius: 12px; border: 3px solid hsl(var(--border)); padding: 8px; background: hsl(var(--card)); color: hsl(var(--card-foreground)); }

.spinner { width: 48px; height: 48px; border-radius: 50%; border: 5px solid hsl(var(--muted)); border-top-color: hsl(var(--primary)); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.fact { max-width: 440px; }
.rotate-icon { font-size: 3rem; animation: tilt 1.6s ease-in-out infinite; }
@keyframes tilt { 50% { transform: rotate(90deg); } }

/* ── HUD(경기 화면 위 DOM) ── */
#hud { position: fixed; inset: 0; z-index: var(--z-hud); pointer-events: none; }
#hud button, #hud .stick, #hud .wheel { pointer-events: auto; }
.hud-top { position: absolute; top: max(6px, env(safe-area-inset-top)); left: 0; right: 0; display: flex; justify-content: center; gap: 10px; align-items: center; }
.score { display: flex; gap: 10px; align-items: center; font-weight: 900; font-size: 1.3rem; background: hsl(var(--card) / 0.92); color: hsl(var(--card-foreground)); padding: 4px 14px; border-radius: 999px; border: 2px solid hsl(var(--border)); }
.score .sa { color: hsl(var(--secondary)); }
.score .sb { color: hsl(var(--destructive)); }
.dark .score .sb { color: hsl(var(--accent)); }
.alive { font-weight: 800; background: hsl(var(--card) / 0.92); color: hsl(var(--card-foreground)); padding: 4px 12px; border-radius: 999px; }
.lag { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); padding: 4px 8px; border-radius: 999px; }
.banner { position: absolute; top: 22%; left: 50%; transform: translateX(-50%); font-size: clamp(1.4rem, 4vw, 2.4rem); font-weight: 900; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); padding: 6px 20px; border-radius: 14px; box-shadow: 4px 4px 0 hsl(var(--shadow) / 0.3); width: max-content; max-width: min(86vw, 900px); text-align: center; word-break: keep-all; line-height: 1.25; }
.banner.long { font-size: clamp(1rem, 2.6vw, 1.5rem); }   /* 설명 배너(필살기 안내) — 폰 화면 밖으로 잘렸다(실측) */
.hint { position: absolute; bottom: max(8px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); font-size: 0.85rem; background: hsl(var(--card) / 0.85); color: hsl(var(--card-foreground)); padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.feed { position: absolute; top: 52px; right: 10px; display: grid; gap: 4px; font-size: 1.1rem; }
.feed span { background: hsl(var(--card) / 0.9); color: hsl(var(--card-foreground)); padding: 2px 8px; border-radius: 8px; }
.hud-left { position: absolute; top: max(6px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); display: flex; gap: 6px; }
.wheel { position: absolute; top: 58px; left: 8px; display: grid; grid-template-columns: repeat(4, 48px); gap: 6px; background: hsl(var(--card) / 0.95); padding: 8px; border-radius: 14px; border: 2px solid hsl(var(--border)); }
.wheel button { width: 48px; height: 48px; font-size: 1.5rem; border-radius: 10px; border: 0; background: hsl(var(--muted)); cursor: pointer; }
/* 이동 = 왼쪽 55 % 어디든 플로팅 스틱 · 공격·필살기 = 오른쪽 아래 고정 버튼(끌면 조준) */
.stick { position: absolute; bottom: 0; width: 55%; height: 70%; touch-action: none; }
#stick-l { left: 0; }
.lefty #stick-l { left: auto; right: 0; }
.stick i { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 3px solid hsl(var(--card) / 0.7); background: hsl(var(--card) / 0.15); display: none; }
.stick i::after { content: ""; position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: hsl(var(--card) / 0.8); transform: translate(var(--kx, 0), var(--ky, 0)); }
.stick.on i { display: block; }
.atkbtn, .super { position: absolute; border-radius: 50%; touch-action: none; font: inherit; font-weight: 900; cursor: pointer; display: grid; place-items: center; user-select: none; -webkit-user-select: none; }
.atkbtn { --r: max(28px, 4%); right: max(var(--r), env(safe-area-inset-right)); bottom: max(26px, env(safe-area-inset-bottom)); width: 108px; height: 108px;
  border: 4px solid hsl(0 0% 100% / 0.9); background: hsl(8 82% 52% / 0.88); color: #fff; font-size: 1rem; box-shadow: 0 4px 0 hsl(8 70% 34% / 0.9); }
.atkbtn span { position: relative; z-index: 1; margin-top: -10px; text-shadow: 0 1px 2px #0008; }
.atkbtn .ammo { position: absolute; bottom: 18px; display: flex; gap: 4px; z-index: 1; }
.atkbtn .ammo i { width: 20px; height: 7px; border-radius: 4px; background: hsl(0 0% 100% / 0.3); }
.atkbtn .ammo i.full { background: #ffd23f; }
.atkbtn.empty { animation: shake 0.25s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: hsl(0 0% 100% / 0.35); pointer-events: none; opacity: 0; transition: opacity 0.1s; }
.aiming .knob { opacity: 1; }
.super { right: calc(max(28px, 4%) + 118px); bottom: max(70px, calc(env(safe-area-inset-bottom) + 44px)); width: 84px; height: 84px; border: 3px solid hsl(var(--border));
  background: hsl(var(--muted)); color: hsl(var(--foreground)); font-size: 0.72rem; line-height: 1.1; overflow: hidden; padding: 6px; text-align: center; }
.lefty .atkbtn { right: auto; left: max(28px, 4%); }
.lefty .super { right: auto; left: calc(max(28px, 4%) + 118px); }
.super span { position: relative; z-index: 1; word-break: keep-all; }
.super > i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: hsl(var(--primary) / 0.55); }
.super.ready { border-color: hsl(var(--primary)); background: hsl(var(--primary) / 0.25); box-shadow: 0 0 0 4px hsl(var(--primary) / 0.5), 0 0 18px hsl(var(--primary)); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.autoaim { position: absolute; right: 12px; bottom: 50%; background: hsl(var(--card) / 0.9); color: hsl(var(--card-foreground)); padding: 2px 8px; border-radius: 8px; font-size: 0.85rem; }
.pc .stick i, .pc #btn-super, .pc #btn-atk { opacity: 0.8; }
.fullbtn[hidden] { display: none; }

.res-title { font-size: clamp(2rem, 7vw, 3.6rem); }
.stats { min-width: min(420px, 90vw); text-align: left; }
.stats table { width: 100%; border-collapse: collapse; }
.stats td { padding: 4px 6px; border-bottom: 1px dashed hsl(var(--border)); }

.offer { max-width: 520px; display: grid; gap: 10px; }
.ladder { list-style: none; display: flex; gap: 6px; justify-content: center; padding: 0; margin: 4px 0; }
.ladder li { background: hsl(var(--primary) / 0.25); padding: 6px 10px; border-radius: 10px; font-weight: 900; }
.ladder li:last-child { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.qpanel { width: min(640px, 100%); display: grid; gap: 12px; }
.qhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.question { font-size: 1.35rem; font-weight: 800; line-height: 1.45; min-height: 2.9em; margin: 0; }
.timebar { height: 8px; background: hsl(var(--muted)); border-radius: 999px; overflow: hidden; }
.timebar i { display: block; height: 100%; width: 100%; background: hsl(var(--secondary)); transform-origin: left; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { min-height: 64px; font: inherit; font-size: 1.15rem; font-weight: 800; border-radius: 12px; border: 3px solid hsl(var(--border)); background: hsl(var(--background)); color: hsl(var(--foreground)); cursor: pointer; padding: 8px; }
.choice.right { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); border-color: hsl(var(--secondary)); }
.choice.wrong { border-color: hsl(var(--destructive)); text-decoration: line-through; }
.feedback { min-height: 2.8em; margin: 0; font-weight: 700; }
.reward { min-width: min(420px, 90vw); display: grid; gap: 6px; }
.big-num { font-size: 2rem; margin: 0; }
.unlock { font-weight: 900; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); padding: 6px 10px; border-radius: 10px; }

.modal { position: fixed; inset: 0; z-index: var(--z-modal); background: hsl(var(--overlay) / 0.55); display: grid; place-items: center; padding: 16px; }
.modal .card { max-width: 420px; text-align: center; display: grid; gap: 10px; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: var(--z-toast); background: hsl(var(--foreground)); color: hsl(var(--background)); padding: 10px 16px; border-radius: 12px; font-weight: 700; max-width: 90vw; }

@media (max-width: 520px) { .choices { grid-template-columns: 1fr; } .hero-char img { width: 90px; height: 120px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.reduce * { animation: none !important; transition: none !important; }

/* 쇼룸(개발용 페이지 showroom.html — D47) */
.showroom { overflow: auto; }
.showroom-bar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 10px 16px; }
.showroom-bar select { min-height: 44px; }
.showroom-bar .ok { color: hsl(var(--primary)); font-weight: 700; }
.showroom-bar .bad { color: hsl(var(--destructive)); font-weight: 700; }
#sr-canvas { display: block; }
.showroom-report { padding: 12px 16px; font-size: 12px; white-space: pre-wrap; }

/* 스티커 말풍선 = 버튼(누르면 그 친구 스티커 숨김, D43) */
.bubble { min-height: 44px; min-width: 44px; border: 0; font: inherit; font-weight: 700; cursor: pointer; pointer-events: auto; }
.bubble:focus-visible { outline: 3px solid hsl(var(--ring)); outline-offset: 2px; }
