:root {
  --lane-0: #ff5e8f;
  --lane-1: #4fd1ff;
  --lane-2: #ffd84f;
  --lane-3: #6bff8f;
  --bg: #0d0d1f;
  --panel: #171733;
  --line: rgba(255, 255, 255, 0.14);
  --text: #f2f2f9;
  --text-dim: #9797b8;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  margin: 0;
  background: #000;
  color: var(--text);
  font-family: "Pretendard", "Segoe UI", system-ui, -apple-system, sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  justify-content: center;
}

.game-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}

.hud-items {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
}

.lobby-btn {
  flex-shrink: 0;
  margin-right: 14px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.06s ease;
}

.lobby-btn:active {
  transform: scale(0.92);
  filter: brightness(1.3);
}

.hud-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.hud-value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.combo-item .combo-value {
  font-size: 26px;
  color: #ffd84f;
}

.player-bar {
  padding: 6px 20px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  text-align: center;
  z-index: 2;
}

.player-bar .player-level {
  color: #ffd84f;
  font-weight: 700;
}

/* ---------- Lane area ---------- */
.lane-area {
  position: relative;
  flex: 1;
  display: flex;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0) 40%),
    var(--bg);
}

.lane {
  position: relative;
  flex: 1;
  border-right: 1px solid var(--line);
}

.lane:last-child {
  border-right: none;
}

.judge-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 110px;
  height: 2px;
  background: var(--line);
  display: flex;
  z-index: 1;
}

.judge-ring {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.judge-ring::before {
  content: "";
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--line);
  transform: translateY(-50%);
  transition: box-shadow 0.08s ease, border-color 0.08s ease;
}

.judge-ring.hit::before {
  border-color: #fff;
  box-shadow: 0 0 18px 4px currentColor;
}

.judge-ring[data-lane="0"] { color: var(--lane-0); }
.judge-ring[data-lane="1"] { color: var(--lane-1); }
.judge-ring[data-lane="2"] { color: var(--lane-2); }
.judge-ring[data-lane="3"] { color: var(--lane-3); }

/* ---------- Note bubbles ---------- */
.note {
  position: absolute;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  border-radius: 50%;
  will-change: transform;
  box-shadow: 0 0 12px 1px currentColor, inset 0 -6px 10px rgba(0,0,0,0.25), inset 0 4px 8px rgba(255,255,255,0.45);
}

.note::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 9px;
  width: 12px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}

.note.lane-0 { background: var(--lane-0); color: var(--lane-0); }
.note.lane-1 { background: var(--lane-1); color: var(--lane-1); }
.note.lane-2 { background: var(--lane-2); color: var(--lane-2); }
.note.lane-3 { background: var(--lane-3); color: var(--lane-3); }

.note.pop {
  animation: pop 0.18s ease forwards;
}

@keyframes pop {
  to {
    transform: scale(1.8);
    opacity: 0;
  }
}

/* ---------- Judge text ---------- */
.judge-text {
  position: absolute;
  left: 50%;
  bottom: 140px;
  transform: translateX(-50%);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.04em;
  pointer-events: none;
  opacity: 0;
  z-index: 3;
}

.judge-text.show {
  animation: judge-pop 0.5s ease forwards;
}

@keyframes judge-pop {
  0% { opacity: 0; transform: translateX(-50%) translateY(0) scale(0.8); }
  15% { opacity: 1; transform: translateX(-50%) translateY(-6px) scale(1.05); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-28px) scale(1); }
}

.judge-text.perfect { color: #ffd84f; }
.judge-text.good { color: #4fd1ff; }
.judge-text.miss { color: #ff5e8f; }

/* ---------- Button bar ---------- */
.button-bar {
  display: flex;
  gap: 10px;
  padding: 14px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
  z-index: 2;
  touch-action: none;
}

.lane-btn {
  flex: 1;
  height: 68px;
  border-radius: 16px;
  border: none;
  font-size: 22px;
  font-weight: 700;
  color: var(--bg);
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.06s ease;
}

.lane-btn[data-lane="0"] { background: var(--lane-0); }
.lane-btn[data-lane="1"] { background: var(--lane-1); }
.lane-btn[data-lane="2"] { background: var(--lane-2); }
.lane-btn[data-lane="3"] { background: var(--lane-3); }

.lane-btn.active,
.lane-btn:active {
  transform: scale(0.92);
  filter: brightness(1.25);
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 18, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.2s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-card {
  text-align: center;
  padding: 32px;
}

.overlay-card h1 {
  margin: 0 0 12px;
  font-size: 32px;
}

.overlay-card p {
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 24px;
}

.result-line {
  font-size: 16px;
}

.result-line span {
  color: #fff;
  font-weight: 700;
}

.nickname-input {
  display: block;
  width: 100%;
  max-width: 260px;
  margin: 0 auto 20px;
  padding: 12px 16px;
  font-size: 16px;
  text-align: center;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}

.nickname-input:focus {
  border-color: var(--lane-1);
}

.primary-btn {
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--lane-1), var(--lane-0));
  color: #0d0d1f;
  cursor: pointer;
}

.primary-btn:active {
  transform: scale(0.96);
}

.end-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.secondary-btn {
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.secondary-btn:active {
  transform: scale(0.96);
}

/* ---------- 레벨 선택 ---------- */
.level-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-width: 320px;
  margin: 0 auto;
}

.level-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
}

.level-btn:active {
  transform: scale(0.96);
}

.level-btn.is-default {
  border-color: var(--lane-2);
}

.level-tag {
  font-size: 18px;
  font-weight: 800;
}

.level-name {
  font-size: 13px;
  color: var(--text-dim);
}

.level-bpm {
  font-size: 11px;
  color: var(--text-dim);
}

.level-default-badge {
  position: absolute;
  top: -8px;
  right: -6px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--lane-2);
  color: var(--bg);
}
