:root {
  --bg: #9fd3ff;
  --ink: #ffffff;
  --panel: rgba(20, 24, 32, 0.78);
  --accent: #ff6a3d;
  --muted: rgba(255, 255, 255, 0.55);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  touch-action: none; overscroll-behavior: none;
  margin: 0; height: 100%; overflow: hidden; background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  color: var(--ink); user-select: none; -webkit-user-select: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
:where(#ui) > * { pointer-events: auto; } /* :where로 우선순위 0: .hud 같은 반투명 띠가 pointer-events:none을 지킬 수 있게 */

/* 도구 바 */
.toolbar {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(10, 14, 22, 0.85), rgba(10, 14, 22, 0.55));
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.tool {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; border-radius: 12px; border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.08); color: var(--ink);
  font: inherit; cursor: pointer; touch-action: manipulation;
}
.tool.selected { border-color: var(--accent); background: rgba(255, 106, 61, 0.22); }
.tool.disabled { opacity: 0.35; filter: grayscale(1); }
.tool-icon { font-size: 24px; line-height: 1.1; }
.tool-label { font-size: 11px; font-weight: 700; white-space: nowrap; }
.tool-cost { font-size: 10px; color: #ffd36b; font-weight: 700; }
.tool-cd {
  position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55);
  transform-origin: bottom; transform: scaleY(0); pointer-events: none;
}

.flash {
  position: absolute; inset: 0; background: #fffdf2; pointer-events: none;
  animation: flash-fade 0.75s ease-out forwards;
}
@keyframes flash-fade { from { opacity: 1; } to { opacity: 0; } }
/* 원자로 폭주 경고 */
.meltdown {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%); pointer-events: none;
  padding: 12px 18px; border-radius: 14px; background: rgba(200, 20, 20, 0.88); color: #fff;
  font-size: 20px; font-weight: 900; white-space: nowrap; box-shadow: 0 0 0 4px rgba(255, 220, 0, 0.8);
  animation: meltdown-blink 0.35s steps(2, jump-none) infinite alternate;
}
@keyframes meltdown-blink { to { background: rgba(255, 200, 0, 0.92); color: #300; } }

/* 공통 */
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 16px; padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.card {
  width: 100%; max-width: 420px; border-radius: 22px; padding: 22px 20px;
  background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); text-align: center;
}
.btn {
  font: inherit; font-weight: 800; color: var(--ink); cursor: pointer; touch-action: manipulation;
  border: 2px solid rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.1);
  border-radius: 14px; padding: 12px 16px; font-size: 15px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); box-shadow: 0 6px 0 #b8401d; }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #b8401d; }
.btn.big { width: 100%; display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; font-size: 19px; }
.btn.big small { font-size: 12px; font-weight: 600; opacity: 0.85; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--panel); color: var(--ink); font-size: 20px; font-weight: 800;
}
.row { display: flex; gap: 10px; margin-top: 10px; }
.row .btn { flex: 1; }
.notice p { margin: 0 0 16px; font-size: 16px; line-height: 1.5; font-weight: 600; }

/* 시작 화면 */
.start { flex-direction: column; justify-content: space-between; background: linear-gradient(to bottom, rgba(10, 14, 22, 0.15), rgba(10, 14, 22, 0.75)); }
.start-top { width: 100%; max-width: 480px; display: flex; justify-content: flex-end; }
.start-body { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.logo { text-align: left; text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); }
.logo-kicker { font-size: 13px; letter-spacing: 0.4em; font-weight: 900; color: #ffd36b; }
.logo h1 { margin: 2px 0 0; font-size: 58px; line-height: 0.98; font-weight: 900; letter-spacing: -0.03em; }
.campus-list { display: flex; gap: 8px; flex-wrap: wrap; }
.campus {
  font: inherit; font-weight: 800; font-size: 14px; color: var(--ink); cursor: pointer;
  padding: 8px 14px; border-radius: 999px; border: 2px solid rgba(255, 255, 255, 0.3); background: rgba(0, 0, 0, 0.35);
}
.campus.active { border-color: #ffd36b; background: rgba(255, 211, 107, 0.2); }
.campus:disabled { opacity: 0.5; cursor: default; }
.campus small { margin-left: 6px; font-size: 11px; opacity: 0.8; }
.mode-buttons { display: flex; flex-direction: column; gap: 10px; }
.best { margin: 0; text-align: center; font-size: 13px; font-weight: 700; opacity: 0.85; }

/* HUD */
.hud {
  position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.stat {
  background: var(--panel); border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 700;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); white-space: nowrap;
}
.stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.stat.urgent { background: #d6342a; animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.06); } }
.hud-actions { display: flex; gap: 6px; }
.countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none;
  font-size: 140px; font-weight: 900; color: #fff; text-shadow: 0 8px 0 rgba(0, 0, 0, 0.35);
}

/* 결과 */
.result { background: rgba(10, 14, 22, 0.45); }
.result-card p { margin: 0; }
.result-campus { font-size: 15px; font-weight: 700; opacity: 0.85; }
.result-pct { font-size: 24px; font-weight: 800; }
.result-pct b { font-size: 64px; font-weight: 900; color: #ffd36b; letter-spacing: -0.03em; }
.result-title { font-size: 20px; font-weight: 900; margin-top: 2px !important; }
.result-score { font-size: 15px; font-weight: 700; opacity: 0.9; margin: 6px 0 !important; }
.result-collapsed { font-size: 13px; line-height: 1.45; opacity: 0.85; margin: 8px 0 !important; }
.result-best { font-size: 14px; font-weight: 800; color: #ffd36b; min-height: 20px; margin-bottom: 12px !important; }
.result-card .share-image { width: 100%; margin-top: 8px; }
.share-extra { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.share-extra input { font: inherit; padding: 10px; border-radius: 10px; border: none; width: 100%; }

/* 카메라 버튼 */
.cam-buttons {
  position: absolute; right: calc(10px + env(safe-area-inset-right)); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 8px;
}
.cam-buttons .icon-btn { width: 44px; height: 44px; font-size: 22px; touch-action: none; opacity: 0.88; }
.cam-buttons .icon-btn:active { background: var(--accent); }

/* 비공식 패러디 안내 */
.disclaimer-link {
  font: inherit; font-size: 11px; font-weight: 600; color: rgba(255, 255, 255, 0.78); background: none; border: none;
  padding: 4px 0; cursor: pointer; text-align: center; word-break: keep-all; line-height: 1.4;
}
.disclaimer { background: rgba(10, 14, 22, 0.6); z-index: 20; }
.disclaimer-card { text-align: left; max-height: 100%; overflow-y: auto; }
.disclaimer-card h2 { margin: 0 0 12px; font-size: 20px; }
.disclaimer-card p { margin: 0 0 12px; font-size: 14px; line-height: 1.6; opacity: 0.92; word-break: keep-all; }
.disclaimer-card .close { width: 100%; margin-top: 4px; }

/* 지도 자료 출처 */
.attribution {
  position: absolute; right: calc(8px + env(safe-area-inset-right)); bottom: calc(76px + env(safe-area-inset-bottom));
  font-size: 10px; color: rgba(255, 255, 255, 0.85); text-decoration: none; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* 건물 붕괴 멘트 */
.quip {
  position: absolute; left: 50%; top: calc(70px + env(safe-area-inset-top)); transform: translateX(-50%); pointer-events: none;
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 14px; background: rgba(18, 12, 14, 0.88); color: #ff3b3b;
  border: 2px solid #ff3b3b; font-size: 18px; font-weight: 900; text-align: left;
  width: max-content; word-break: keep-all; line-height: 1.35;
  text-shadow: 0 0 8px rgba(255, 40, 40, 0.55); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  animation: quip-pop 0.35s cubic-bezier(.2, 1.6, .4, 1);
}
.quip.blue { color: #4aa8ff; border-color: #4aa8ff; text-shadow: 0 0 8px rgba(60, 150, 255, 0.55); }
.quip-avatar { width: 60px; height: 84px; flex: none; image-rendering: pixelated; border-radius: 6px; background: rgba(255, 59, 59, 0.22); }
@keyframes quip-pop { from { transform: translateX(-50%) scale(0.6); opacity: 0; } }
