/* 별똥별 수비대 — DOM 오버레이 UI. 인라인 스타일 0(CSP), 외부 폰트 0(아동 IP 제3자 전송 금지). */
:root {
  --ink: #21243d;
  --ink-soft: #4a4f70;
  --paper: #ffffff;
  --paper-2: #f2f7ff;
  --sky: #7ec8f0;
  --sky-deep: #2f6fa8;
  --sun: #ffc93c;
  --good: #2f6fe0;
  --bad: #d2600a;
  --ok: #1f8a4c;
  --danger: #d33b3b;
  --shadow: 0 6px 0 rgba(33, 36, 61, .18), 0 10px 22px rgba(33, 36, 61, .16);
  --r: 18px;
  --tap: 48px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cfe9ff; color: var(--ink); }
body { -webkit-tap-highlight-color: transparent; touch-action: none; user-select: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#flash { position: fixed; inset: 0; pointer-events: none; background: #fff; opacity: 0; z-index: 50; }
body.calm #flash { display: none; }
@media (prefers-reduced-motion: reduce) { #flash { display: none; } }
#ui > * { pointer-events: auto; }
/* 🔴 «화면을 덮는» 오버레이는 터치를 먹으면 안 된다.
   `.hud`(inset:0)·`.countdown`(inset:0) 안에 pointer-events:none 이 적혀 있어도
   위의 `#ui > *`(특이도 1,0,0)가 클래스 선택자(0,1,0)를 이겨 auto 로 덮어썼다.
   결과: 모바일에서 좌우 조작이 «전 화면에서» 죽었다(2026-09-09 실기 제보).
   데스크톱은 pointermove 를 window 에서 받아(마우스 전용 분기) 살아 있었고,
   검사도 전부 마우스라 아무도 못 잡았다 — DoD 37 에서 터치로 직접 민다. */
#ui > .hud, #ui > .countdown, #ui > .bubble { pointer-events: none; }
.hud > * { pointer-events: none; }
.hud button { pointer-events: auto; }

button.btn {
  font: inherit; font-size: 20px; font-weight: 800; color: var(--ink);
  min-height: var(--tap); min-width: var(--tap); padding: 12px 20px;
  border: 3px solid var(--ink); border-radius: var(--r); background: var(--paper);
  box-shadow: var(--shadow); cursor: pointer; line-height: 1.2;
}
button.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(33,36,61,.2); }
button.btn:disabled { opacity: .45; cursor: default; }
button.btn.primary { background: var(--sun); }
button.btn.big { font-size: 24px; padding: 16px 28px; }
button.btn.icon { padding: 8px 12px; font-size: 22px; }
button.btn:focus-visible { outline: 4px solid #1b6ef3; outline-offset: 3px; }
h1 { font-size: 40px; margin: 0 0 6px; letter-spacing: -.5px; }
h2 { font-size: 26px; margin: 0; }
h3 { font-size: 20px; margin: 0; }
p { font-size: 18px; line-height: 1.5; margin: 6px 0; color: var(--ink); }
p.hint { font-size: 16px; color: var(--ink-soft); }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }

.screen {
  position: absolute; inset: 0; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(210,236,255,.94), rgba(255,255,255,.96));
  overflow-y: auto; overscroll-behavior: contain;
}
.screen[hidden] { display: none; }
.screen .col { width: min(420px, 100%); }
.screen-title .logo { text-align: center; }
.screen-title .title-art {
  width: min(420px, 92vw); height: 190px; border-radius: var(--r); border: 4px solid var(--ink);
  background: url('../assets/tex/title_art.webp') center/cover, linear-gradient(160deg, #ffe9a8, #9fd8ff);
  box-shadow: var(--shadow);
}
.screen .sub { font-size: 18px; color: var(--ink-soft); }
.grades { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; width: min(420px, 100%); }
.grade-btn { font-size: 24px; padding: 18px 10px; }

.screen-map, .screen-upgrade, .screen-album, .screen-settings { justify-content: flex-start; }
.head { width: min(560px, 100%); justify-content: space-between; }
.candy { font-size: 20px; font-weight: 800; }
.map-body { width: min(560px, 100%); display: flex; flex-direction: column; gap: 12px; }
.chapter { border: 3px solid var(--ink); border-radius: var(--r); padding: 12px; background: var(--paper); box-shadow: var(--shadow); }
.chapter .row { justify-content: space-between; }
.chapter.locked { opacity: .6; }
.chapter-stars { font-size: 16px; font-weight: 700; color: var(--ink-soft); }
.stages { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 10px; }
button.stage { padding: 6px 2px; min-width: 0; font-size: 16px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
button.stage .n { font-size: 18px; }
button.stage .st { font-size: 12px; color: #b07d00; letter-spacing: -1px; }
button.stage.boss { background: #ffe0f0; }
.mission { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; font-size: 17px; border-top: 1px dashed #ccd6e6; }
.mission:first-of-type { border-top: 0; }
.mprog { color: var(--ink-soft); white-space: nowrap; }
.theme-meadow { background: #f2fff2; } .theme-forest { background: #eefaf3; }
.theme-sea { background: #eef8ff; } .theme-cloud { background: #f6f9ff; }
.theme-desert { background: #fff7e8; } .theme-ice { background: #f0f8ff; }
.theme-volcano { background: #fff1ec; } .theme-space { background: #f3f1ff; }

.hud { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.hud[hidden] { display: none; }
.hud > * { pointer-events: auto; }
.hud-top { padding: calc(8px + var(--safe-t)) 12px 0; display: flex; flex-direction: column; gap: 6px; }
.bar { position: relative; height: 14px; border: 3px solid var(--ink); border-radius: 999px; background: var(--paper); }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, #8fd6ff, #2f6fe0); border-radius: 999px; transition: width .12s linear; }
.bar-boss { position: absolute; right: -6px; top: -12px; font-size: 20px; }
.stats { justify-content: space-between; }
.hud .squad {
  font-size: 34px; font-weight: 900; color: var(--ink); background: rgba(255,255,255,.92);
  border: 3px solid var(--ink); border-radius: 14px; padding: 2px 14px; min-width: 74px; text-align: center;
}
.hud .squad.danger { color: #fff; background: var(--danger); }
.hud .stat { font-size: 20px; font-weight: 800; background: rgba(255,255,255,.92); border-radius: 12px; padding: 6px 10px; }
.boss-bar { position: relative; height: 26px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.boss-bar[hidden] { display: none; }
.boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff9d8a, #d33b3b); transition: width .1s linear; }
.boss-name { position: absolute; left: 10px; top: 0; bottom: 0; display: flex; align-items: center; font-size: 18px; font-weight: 800; z-index: 1; }  /* 18px = DoD 23 HUD 최소 글자 */
.hud-bottom { display: flex; justify-content: space-between; align-items: flex-end; padding: 0 12px calc(14px + var(--safe-b)); }
button.storm { position: relative; overflow: hidden; background: #e8f4ff; font-size: 18px; min-width: 108px; min-height: 60px; }
button.storm.ready { background: var(--sun); animation: pulse 1.1s infinite; }
.energy { position: absolute; left: 0; bottom: 0; width: 100%; background: rgba(47,111,224,.28); height: 0; pointer-events: none; }
@keyframes pulse { 50% { transform: scale(1.05); } }

.bubble {
  position: absolute; left: 50%; top: calc(84px + var(--safe-t)); transform: translateX(-50%);
  width: min(420px, 92vw); background: var(--paper); border: 4px solid var(--ink); border-radius: var(--r);
  padding: 12px 16px; box-shadow: var(--shadow); text-align: center;
}
.bubble[hidden] { display: none; }
.bubble-sub { font-size: 15px; font-weight: 800; color: var(--sky-deep); }
.bubble-q { font-size: 24px; font-weight: 800; line-height: 1.35; }

.countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 84px; font-weight: 900; color: #fff; text-shadow: 0 6px 0 rgba(33,36,61,.45); pointer-events: none;
}
.countdown[hidden] { display: none; }
.countdown.pop { animation: pop .3s ease-out; }
@keyframes pop { from { transform: scale(.6); opacity: .2; } to { transform: scale(1); opacity: 1; } }

.stars-big { font-size: 54px; color: #e8a600; letter-spacing: 6px; text-shadow: 0 3px 0 rgba(33,36,61,.25); }
.result-body { width: min(420px, 100%); background: var(--paper); border: 3px solid var(--ink); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.kv { display: flex; justify-content: space-between; font-size: 18px; padding: 5px 0; border-top: 1px dashed #ccd6e6; }
.kv:first-child { border-top: 0; }
.near { font-size: 22px; font-weight: 800; color: var(--sky-deep); text-align: center; }
.cheer { color: var(--ok); font-weight: 700; text-align: center; }
.wrong-card { margin-top: 10px; padding: 10px; border-radius: 12px; background: var(--paper-2); border: 2px dashed var(--sky-deep); }
.wrong-card .ok { color: var(--ok); font-weight: 800; }

.list { width: min(560px, 100%); display: flex; flex-direction: column; gap: 10px; }
.up-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--paper); border: 3px solid var(--ink); border-radius: var(--r); padding: 12px; box-shadow: var(--shadow); }
.up-info { display: flex; flex-direction: column; }
.up-info b { font-size: 19px; }
.sub-list { background: var(--paper); border: 3px solid var(--ink); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.kv-line { font-size: 17px; }
.album { width: min(560px, 100%); display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
button.costume { min-height: 72px; padding: 6px 2px; display: flex; flex-direction: column; gap: 2px; }
button.costume.on { background: var(--sun); }
.c-icon { font-size: 24px; } .c-n { font-size: 13px; color: var(--ink-soft); }
textarea.code, input.code-input { font: inherit; font-size: 16px; padding: 10px; border: 3px solid var(--ink); border-radius: 12px; width: 100%; min-height: var(--tap); }

.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(21,24,45,.55); padding: 16px; }
.overlay[hidden] { display: none; }
.panel { width: min(420px, 100%); background: var(--paper); border: 4px solid var(--ink); border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); font-size: 20px; text-align: center; }
.credit-line { font-size: 15px; color: var(--ink-soft); margin: 0; }
#perf { position: fixed; left: 8px; top: calc(8px + var(--safe-t)); z-index: 99; background: rgba(0,0,0,.8); color: #fff; font: 700 13px/1.4 ui-monospace, monospace; padding: 6px 10px; border-radius: 8px; }

body.tension #ui::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 90px 30px rgba(211,59,59,.45); animation: vign 1.1s ease-in-out infinite;
}
@keyframes vign { 50% { box-shadow: inset 0 0 120px 40px rgba(211,59,59,.6); } }
body.calm #ui::after { display: none; }
body.calm .countdown.pop, body.calm button.storm.ready { animation: none; }
@media (prefers-reduced-motion: reduce) {
  #ui::after, .countdown.pop, button.storm.ready { animation: none !important; }
  .bar-fill, .boss-fill { transition: none; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .screen { padding-top: 10px; padding-bottom: 10px; }
  h1 { font-size: 30px; }
  .screen-title .title-art { height: 110px; }
  .hud .squad { font-size: 26px; }
  .stages { grid-template-columns: repeat(12, 1fr); }
  .map-body, .head, .list { width: min(760px, 100%); }
}

/* js/frac.js(@gb-frac) 가 inline <style> 로 넣으려는 규칙 — CSP(style-src 'self') 때문에 여기 외부 시트로 옮겼다.
   index.html 의 <link id="gb-frac-css"> 가 injectFracCSS 의 inline 삽입을 막는다. frac.js 는 수정하지 않는다. */
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.05; margin: 0 .12em; font-size: .9em; font-variant-numeric: tabular-nums; }
.frac-n { padding: 0 .18em .06em; border-bottom: .09em solid currentColor; }
.frac-d { padding: .06em .18em 0; }
.frac-mixed { white-space: nowrap; }
.frac-mixed > .frac { margin-left: .06em; }

/* @gb-juice-css v1 — kit/juice/juice.css. 게임 스타일시트 끝에 그대로 붙인다(CSP style-src 'self' 라 JS 가 <style> 을 넣지 않는다). */
.gbj-layer{position:fixed;inset:0;pointer-events:none;z-index:40;overflow:hidden}
.gbj-pop{position:absolute;transform:translate(-50%,-50%) scale(var(--s));font:900 22px/1 system-ui,sans-serif;text-shadow:0 2px 0 #0008,0 0 12px currentColor;white-space:nowrap;animation:gbjPop .9s cubic-bezier(.2,1.6,.4,1) forwards}
@keyframes gbjPop{0%{opacity:0;transform:translate(-50%,-50%) scale(calc(var(--s)*.3))}15%{opacity:1;transform:translate(-50%,-80%) scale(calc(var(--s)*1.35))}35%{transform:translate(calc(-50% + var(--dx)),-120%) scale(var(--s))}100%{opacity:0;transform:translate(calc(-50% + var(--dx)),-260%) scale(calc(var(--s)*.9))}}
.gbj-punch{animation:gbjPunch .32s cubic-bezier(.2,2,.4,1)}
@keyframes gbjPunch{0%{transform:scale(1)}30%{transform:scale(var(--gbj-p))}100%{transform:scale(1)}}
.gbj-flash{position:absolute;inset:0;opacity:0}
.gbj-flash.gbj-go{animation:gbjFlash .35s ease-out forwards}
@keyframes gbjFlash{to{opacity:0}}
/* 가운데 큰 글자 — 자리는 게임이 --gbj-banner-top 으로 옮긴다(HUD 배너·선택 카드와 겹치지 않게 · 2026-10-12 끝까지 진화 실측). 좁은 화면에서 넘치지 않게 vw 로 줄인다 */
.gbj-banner{position:absolute;left:50%;top:var(--gbj-banner-top,40%);transform:translate(-50%,-50%);font:900 clamp(22px,8vw,44px)/1.1 system-ui,sans-serif;text-align:center;opacity:0;text-shadow:0 3px 0 #000a,0 0 24px currentColor;max-width:92vw;width:max-content}
.gbj-banner.gbj-go{animation:gbjBan var(--d,1.4s) cubic-bezier(.2,1.5,.4,1) forwards}
@keyframes gbjBan{0%{opacity:0;transform:translate(-50%,-50%) scale(.2) rotate(-8deg)}15%{opacity:1;transform:translate(-50%,-50%) scale(1.25) rotate(2deg)}30%{transform:translate(-50%,-50%) scale(1)}80%{opacity:1}100%{opacity:0;transform:translate(-50%,-70%) scale(1.05)}}
@media (prefers-reduced-motion:reduce){.gbj-pop,.gbj-banner.gbj-go,.gbj-punch{animation-duration:.01s}}

/* ── 모드·기본틀(학교 순위 카드는 gb-ui.css) ── */
.screen-title .gb-home-top { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 8px; }
.screen-title .gb-brand { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.screen-title .gb-tools { display: flex; gap: 6px; }
.school-rank { width: 100%; }
.mode-head { margin: 10px 0 4px; font-size: 16px; opacity: 0.85; }
.mode-grid { width: 100%; }
.gb-sub { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.gb-sub .btn { min-height: 44px; }
.mode-badge { font-size: 14px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(12, 18, 40, 0.55); color: #fff; }
.mode-badge.urgent { background: #c22; animation: badgePulse 0.7s infinite alternate; }
@keyframes badgePulse { from { opacity: 0.75; } to { opacity: 1; } }
/* 🔴 무기 띠 — 무엇을 들었고 얼마나 남았는지. 없으면 «먹은 티»가 날 수 없다(2026-10-24 사용자) */
.weapon-badge { position: relative; overflow: hidden; font-size: 14px; font-weight: 700; padding: 4px 10px;
  border-radius: 999px; background: rgba(12, 40, 24, 0.72); color: #baf7d0; box-shadow: 0 0 0 2px rgba(53, 196, 106, 0.5); }
.weapon-badge .wb-left { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(53, 196, 106, 0.35); }
.weapon-badge .wb-text { position: relative; }
.gb-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: rgba(12, 18, 40, 0.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px;
  transition: opacity 0.2s, transform 0.2s; pointer-events: none; z-index: 60; }
.gb-toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.gb-ic { width: 1.1em; height: 1.1em; vertical-align: -0.15em; }

/* 🔴 터치 타깃 48px — 키트 기본값은 44px 이고 키트 파일은 고치지 않는다(정본 해시 게이트). 여기서 덮는다(DoD 22). */
.gb-icon, .gb-rank button, .gb-modes .gb-mode, .gb-sheet button, .gb-quiz button { min-width: 48px; min-height: 48px; }
/* 전체화면 단추가 랜드스케이프에서 다른 층에 덮여 중심점 히트테스트가 실패했다(DoD 22) — 머리줄을 위로 올린다. */
.screen-title .gb-home-top { position: relative; z-index: 6; }
/* 🔴 첫 화면이 길어졌다(학교 순위 + 모드 카드) — 가운데 정렬이면 랜드스케이프에서 머리줄이 화면 위로 밀려
   전체화면 단추를 누를 수 없었다(DoD 22 히트테스트 실패, 버튼 y = −133px). 위에서부터 쌓고 스크롤한다. */
.screen-title { justify-content: flex-start; }
.screen-title .title-art { height: 120px; }
.screen-title .gb-home-top { position: sticky; top: 0; z-index: 6; }

/* 🔴 키트 UI 는 어두운 바탕 전제(--gb-text #eaf1ff · --gb-panel 흰색 5%)인데 우리 첫 화면은 «밝은» 바탕이다 —
   흰 글씨가 흰 바탕에 얹혀 학교 순위·모드 설명이 안 보였다(2026-10-17 사용자 제보 «글씨 안보임», 실측 대비 1.1:1).
   키트 파일은 고치지 않는다 — 첫 화면에서만 토큰을 밝은 테마로 덮는다. 덮개(#gb-layer)는 --gb-bg 어두운 창이라 그대로 둔다.
   🔒 tools/live-audit.mjs 의 «첫 화면 글자 대비» 검사(WCAG 4.5:1). */
.screen-title {
  --gb-text: #16233d;
  --gb-dim: #4e5c78;
  --gb-panel: rgba(255, 255, 255, 0.86);
  --gb-panel-2: rgba(255, 255, 255, 0.96);
  --gb-line: rgba(22, 35, 61, 0.22);
  --gb-accent: #0c7f5e;
  --gb-accent-ink: #ffffff;
  --gb-gold: #8a5d00;
}

/* 🔴 우리 전역 `p { color: var(--ink) }`(짙은 남색)가 키트 덮개의 문제 글자(.gb-qtext = <p>)를 덮어
   어두운 창에 짙은 남색 글자가 됐다 — 요소 선택자가 «상속»을 이기기 때문이다(2026-10-17 사용자 «문제도 잘안보임»).
   키트 파일은 고치지 않는다 — 덮개 안에서는 키트 토큰으로 되돌린다. */
#gb-layer p { color: var(--gb-text); font-size: inherit; line-height: inherit; }
#gb-layer p.gb-hint { color: var(--gb-dim); }
