:root {
  --bg: #12141c;
  --panel: #1b1f2b;
  --panel-line: #2c3244;
  --ink: #eef0f5;
  --muted: #9aa3b8;
  --accent: #ffb347;
  --accent-2: #ff6b5a;
  --ok: #49d39a;
  font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; }

/* 1280×720 논리 무대를 화면에 맞게 통째로 축소/확대 (잘림 없음, 비율 유지) */
#stage {
  position: absolute; left: 50%; top: 50%;
  width: 1280px; height: 720px;
  transform: translate(-50%, -50%) scale(var(--scale, 1));
  display: grid; grid-template-columns: 320px 640px 320px;
  background: var(--bg);
  user-select: none;
}
#game { width: 640px; height: 720px; display: block; background: #222838; }

.panel { padding: 28px 26px; display: flex; flex-direction: column; gap: 18px; background: var(--panel); }
#hud-left { border-right: 2px solid var(--panel-line); }
#hud-right { border-left: 2px solid var(--panel-line); }

.logo { margin: 0; font-size: 34px; letter-spacing: -1px; }
.logo b, .title b { color: var(--accent); }
.clock {
  align-self: flex-start; font-family: Consolas, monospace; font-size: 30px; font-weight: 700;
  color: #ff5d4d; background: #0b0c10; padding: 4px 14px; border-radius: 6px; border: 2px solid #3a2020;
  text-shadow: 0 0 8px rgba(255, 70, 50, .7);
}
.stats { margin: 0; display: grid; gap: 8px; }
.stats div { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 12px; background: #232838; border-radius: 8px; }
.stats dt { color: var(--muted); font-size: 16px; }
.stats dd { margin: 0; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
#hud-falls { color: var(--accent-2); }

.progress { flex: 1; display: grid; grid-template-rows: auto 1fr auto; justify-items: center; min-height: 0; }
.progress-label { font-size: 14px; color: var(--muted); }
.track { position: relative; width: 14px; margin: 16px 0; border-radius: 7px; background: linear-gradient(#ffb347, #3d4560); }
.mark { position: absolute; left: 50%; transform: translate(-50%, 50%); bottom: 0; border-radius: 50%; }
.mark.now { width: 22px; height: 22px; background: #fff; border: 3px solid #2d6cdf; }
.mark.max { width: 34px; height: 4px; border-radius: 2px; background: var(--accent); }

#hud-right h2 { margin: 0; font-size: 18px; color: var(--muted); font-weight: 600; }
.gauge {
  position: relative; height: 240px; width: 70px; align-self: center;
  border: 3px solid #48506a; border-radius: 10px; background: #10131b; overflow: hidden;
}
#gauge-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: linear-gradient(#ff6b5a, #ffb347 55%, #49d39a); }
#gauge-fill.full { animation: pulse .25s infinite alternate; }
.gauge-cap { position: absolute; top: 4px; left: 0; right: 0; text-align: center; font-size: 13px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000; }
#gauge-text { text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: -8px; }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.6); } }

.keys { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 15px; line-height: 1.45; }
.keys li { display: flex; gap: 10px; align-items: center; }
.keys li span { flex: none; }
.keys li.note { color: var(--muted); font-size: 14px; display: block; }
kbd {
  display: inline-block; min-width: 30px; padding: 2px 8px; margin-right: 3px; text-align: center;
  font-family: inherit; font-size: 14px; font-weight: 700; color: #1b1f2b;
  background: #e8ebf2; border-radius: 5px; box-shadow: 0 3px 0 #9aa3b8;
}

.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 12, 18, .78); z-index: 10;
}
.overlay.hidden { display: none; }
.card {
  width: 640px; max-height: 680px; padding: 36px 44px; border-radius: 18px;
  background: #1f2433; border: 2px solid #343b52; box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  text-align: center;
}
.eyebrow { margin: 0 0 6px; color: #ff7a6a; font-weight: 700; letter-spacing: 1px; }
.title { margin: 0 0 12px; font-size: 60px; letter-spacing: -2px; }
.lead { margin: 0 0 20px; font-size: 18px; color: #d3d8e4; line-height: 1.5; }
.howto { display: grid; gap: 10px; margin: 0 auto 18px; width: max-content; text-align: left; font-size: 16px; }
.howto div { display: flex; align-items: center; gap: 6px; }
.howto span { margin-left: 8px; color: #d3d8e4; }
.rules { margin: 0 0 24px; padding: 14px 18px 14px 34px; text-align: left; font-size: 15px; line-height: 1.6; color: var(--muted); background: #191d29; border-radius: 10px; }
.rules b { color: var(--accent-2); }
.btn {
  font: inherit; font-size: 22px; font-weight: 700; color: #1b1f2b; cursor: pointer;
  padding: 14px 40px; border: 0; border-radius: 12px; background: var(--accent);
  box-shadow: 0 5px 0 #b86f1a; transition: transform .08s;
}
.btn small { font-size: 13px; opacity: .65; margin-left: 6px; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #b86f1a; }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.result-stats { margin: 0 0 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result-stats div { padding: 12px; background: #191d29; border-radius: 10px; }
.result-stats dt { color: var(--muted); font-size: 15px; }
.result-stats dd { margin: 4px 0 0; font-size: 28px; font-weight: 700; }
