:root {
  --ink: #eaf7ff;
  --muted: #8fa7b5;
  --cyan: #69e8ff;
  --yellow: #ffd166;
  --red: #ff4d6d;
  --panel: rgba(8, 16, 26, .96);
  --edge: rgba(132, 220, 255, .25);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #060b12; color: var(--ink); }
body { font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif; user-select: none; }
button, input, select { font: inherit; }
button { color: var(--ink); background: rgba(20, 39, 55, .92); border: 1px solid rgba(135, 211, 244, .25); border-radius: 8px; padding: 12px 18px; cursor: pointer; transition: transform .12s ease, border-color .12s ease, background .12s ease; }
button:hover, button:focus-visible { transform: translateY(-1px); border-color: var(--cyan); outline: none; background: rgba(30, 61, 82, .96); }
button:active { transform: translateY(1px) scale(.99); }
button.primary { color: #061019; background: var(--cyan); border-color: #baf5ff; font-weight: 800; box-shadow: 0 0 30px rgba(105, 232, 255, .18); }
button.danger { color: #ffdce3; border-color: rgba(255, 77, 109, .65); background: rgba(78, 18, 34, .75); }
.is-hidden { display: none !important; }

#game-shell { width: 100%; height: 100%; display: grid; place-items: center; position: relative; background: #060b12; }
#game { display: block; width: min(100vw, calc(100vh * 16 / 9)); height: min(100vh, calc(100vw * 9 / 16)); max-width: 100%; max-height: 100%; background: #0a1420; box-shadow: 0 0 80px #000; outline: none; image-rendering: auto; }

.hud-buttons { position: fixed; top: max(14px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); display: flex; gap: 8px; z-index: 12; }
.hud-buttons button { width: 40px; height: 38px; padding: 0; background: rgba(4, 13, 21, .65); backdrop-filter: blur(8px); }

.overlay { position: fixed; inset: 0; z-index: 20; }
.title-screen { display: flex; align-items: center; justify-content: center; flex-direction: column; background: radial-gradient(circle at 50% 40%, #142b3e 0, #08111b 44%, #04070c 100%); text-align: center; }
.title-screen::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .25; background-image: linear-gradient(rgba(104,232,255,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(104,232,255,.07) 1px, transparent 1px); background-size: 64px 64px; mask-image: linear-gradient(to bottom, transparent, #000 22%, #000 68%, transparent); }
.title-mark { width: 126px; height: 88px; position: relative; margin-bottom: 28px; }
.title-mark span { position: absolute; left: 5px; bottom: 0; width: 44px; height: 44px; border-radius: 7px; background: var(--cyan); box-shadow: 0 0 42px rgba(105,232,255,.45); animation: title-hop 1.8s ease-in-out infinite; }
.title-mark i { position: absolute; right: 0; bottom: 1px; width: 44px; height: 72px; border: 4px solid var(--ink); border-bottom: 0; box-shadow: inset 0 0 25px rgba(234,247,255,.09); }
@keyframes title-hop { 0%, 100% { transform: translate(0,0) rotate(0); } 50% { transform: translate(18px,-22px) rotate(7deg); } }
.eyebrow { color: var(--cyan); letter-spacing: .22em; text-transform: uppercase; font-size: 11px; font-weight: 800; }
h1 { margin: 8px 0 8px; font-size: clamp(42px, 6vw, 76px); letter-spacing: -.06em; line-height: 1; }
h2 { margin: 8px 0 14px; font-size: 34px; letter-spacing: -.04em; }
.tagline { color: var(--muted); margin: 0 0 32px; font-size: 15px; }
.menu-stack { display: grid; gap: 9px; width: min(300px, 78vw); }
.start-note { margin-top: 18px; color: #68808e; font-size: 11px; }

.panel-overlay { display: grid; place-items: center; background: rgba(1, 5, 9, .78); backdrop-filter: blur(10px); padding: 18px; }
.panel { width: min(650px, 96vw); max-height: min(720px, 94vh); overflow: auto; background: var(--panel); border: 1px solid var(--edge); border-radius: 18px; padding: 28px; box-shadow: 0 26px 90px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.04); }
.panel.compact { width: min(400px, 92vw); text-align: center; }
.panel.compact .menu-stack { margin: 22px auto 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; position: sticky; top: -28px; background: linear-gradient(var(--panel) 80%, transparent); padding: 28px 0 18px; z-index: 2; }
.panel-heading h2 { margin-bottom: 0; }
.icon-button { width: 42px; height: 42px; padding: 0; font-size: 25px; flex: 0 0 auto; }
.settings-panel label { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; min-height: 52px; border-top: 1px solid rgba(255,255,255,.07); color: #d6e6ef; }
.settings-panel label input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--cyan); }
.settings-panel select { color: var(--ink); background: #132331; border: 1px solid var(--edge); border-radius: 6px; padding: 7px; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--cyan); }
.privacy { color: #7892a1; line-height: 1.55; font-size: 12px; border-top: 1px solid rgba(255,255,255,.07); padding-top: 18px; }
.confirm-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; padding: 12px; border: 1px solid rgba(255,77,109,.35); border-radius: 8px; }
.confirm-row span { flex: 1 0 100%; color: #ffd8df; }

.subtitle { position: fixed; left: 50%; bottom: clamp(24px, 6vh, 60px); transform: translateX(-50%); z-index: 15; width: min(760px, calc(100vw - 32px)); min-height: 90px; padding: 17px 88px 16px 24px; border-left: 3px solid var(--cyan); background: linear-gradient(100deg, rgba(4, 12, 20, .97), rgba(8, 22, 33, .91)); box-shadow: 0 12px 44px rgba(0,0,0,.4); font-size: 18px; line-height: 1.5; pointer-events: none; }
.subtitle .speaker { color: var(--cyan); font-size: 11px; font-weight: 800; letter-spacing: .16em; margin-bottom: 5px; }
.skip-hint { position: absolute; right: 17px; bottom: 12px; color: #64808f; font-size: 10px; }

.toast-layer { position: fixed; top: 62px; right: 18px; z-index: 35; display: grid; gap: 10px; width: min(350px, calc(100vw - 36px)); pointer-events: none; }
.toast { padding: 14px 16px; background: rgba(9, 22, 32, .97); border: 1px solid rgba(255,209,102,.5); border-left: 4px solid var(--yellow); border-radius: 8px; box-shadow: 0 16px 46px rgba(0,0,0,.35); animation: toast-in .25s ease-out, toast-out .35s ease-in 4.4s forwards; }
.toast strong { display: block; color: var(--yellow); margin-bottom: 3px; font-size: 13px; }
.toast span { color: #bdd0da; font-size: 12px; }
@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }

.achievements-panel { width: min(780px, 96vw); }
#achievement-count { color: var(--yellow); font-size: 16px; margin-left: 8px; }
.achievement-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.achievement { min-height: 94px; padding: 14px; border: 1px solid rgba(255,255,255,.08); border-radius: 10px; background: rgba(255,255,255,.025); display: grid; grid-template-columns: 42px 1fr; gap: 12px; }
.achievement.locked { opacity: .48; filter: saturate(.3); }
.achievement .badge { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(255,209,102,.45); color: var(--yellow); border-radius: 50%; font-weight: 900; }
.achievement h3 { margin: 1px 0 5px; font-size: 14px; }
.achievement p { margin: 0; color: #8fa5b1; font-size: 12px; line-height: 1.4; }

.ending-screen { display: grid; place-items: center; text-align: center; background: radial-gradient(circle at center, rgba(25,56,77,.96), #05080d 68%); padding: 20px; }
.ending-copy { width: min(640px, 92vw); }
.ending-copy h2 { font-size: clamp(48px, 8vw, 88px); margin: 12px 0 18px; }
.ending-copy > p { color: #b9ced9; font-size: 17px; line-height: 1.75; white-space: pre-line; }
.ending-copy .menu-stack { margin: 30px auto 0; }
.ending-stats { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 24px 0; }
.ending-stats span { padding: 8px 12px; border: 1px solid rgba(255,255,255,.1); border-radius: 999px; color: #8faab8; font-size: 12px; }

@media (max-width: 640px) {
  .achievement-list { grid-template-columns: 1fr; }
  .panel { padding: 20px; }
  .panel-heading { top: -20px; padding-top: 20px; }
  .subtitle { font-size: 15px; min-height: 82px; padding-right: 18px; }
  .skip-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
