:root {
  --bg: #0c0618;
  --panel: rgba(22, 10, 42, 0.86);
  --text: #f7f3ff;
  --muted: #b9a8d8;
  --accent: #7cf0c2;
  --danger: #ff5d8f;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Apple SD Gothic Neo", sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#hud {
  position: absolute;
  inset: 12px 16px auto;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 2;
}

#hud[hidden],
#judgment[hidden] {
  display: none !important;
}

.combo {
  font-size: clamp(28px, 6vw, 48px);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
}

.combo-label {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.lives {
  display: flex;
  gap: 5px;
  margin-top: 8px;
}

.lives span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #7cf0c2;
  box-shadow: 0 0 8px rgba(124, 240, 194, 0.7);
}

.lives span.gone {
  background: #3a2748;
  box-shadow: none;
}

.score,
.accuracy {
  text-align: right;
}

.score {
  font-size: clamp(18px, 4vw, 28px);
  font-variant-numeric: tabular-nums;
}

.accuracy {
  color: var(--muted);
  font-size: 13px;
}

.judgment {
  position: absolute;
  left: 50%;
  top: 62%;
  transform: translate(-50%, -50%);
  font-size: clamp(22px, 5vw, 36px);
  font-weight: 800;
  letter-spacing: 0.12em;
  pointer-events: none;
  z-index: 3;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: pop 0.28s ease-out;
}

.judgment.perfect {
  color: #7cf0c2;
}

.judgment.great {
  color: #7ad4ff;
}

.judgment.good {
  color: #8ec8ff;
}

.judgment.normal {
  color: #ffd166;
}

.judgment.miss {
  color: var(--danger);
}

.judgment.hold {
  color: #ffb86b;
}

#overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 4, 22, 0.62);
  z-index: 4;
  padding: 24px;
}

#overlay.hidden {
  display: none;
}

.panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid rgba(255, 160, 230, 0.22);
  border-radius: 20px;
  padding: 28px 24px 22px;
  text-align: center;
  backdrop-filter: blur(16px);
  box-shadow: 0 20px 60px rgba(80, 20, 120, 0.35);
}

.mode-pill {
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(124, 240, 194, 0.12);
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.08em;
}

h1 {
  font-size: clamp(22px, 5.5vw, 42px);
  letter-spacing: 0.12em;
  font-weight: 800;
}

.subtitle {
  margin-top: 2px;
  color: var(--muted);
  letter-spacing: 0.28em;
  font-size: 13px;
}

.credit {
  margin: 18px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.credit a {
  color: var(--accent);
}

.status {
  min-height: 1.4em;
  margin-bottom: 14px;
  font-size: 13px;
}

.status.error {
  color: var(--danger);
}

.status.ok {
  color: var(--accent);
}

.song-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 12px;
}

.song-btn,
.diff-btn {
  padding: 10px 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 13px;
}

.song-btn.active,
.diff-btn.active {
  background: var(--accent);
  color: #062016;
}

.diff-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.diff-btn {
  flex: 1 1 30%;
  min-width: 88px;
  font-size: 12px;
}

.offset {
  display: grid;
  gap: 8px;
  margin: 8px 0 16px;
  font-size: 13px;
  color: var(--muted);
}

.offset input {
  width: 100%;
  accent-color: var(--accent);
}

.keys-hint {
  min-height: 1.4em;
  margin-bottom: 16px;
  font-family: ui-monospace, Consolas, sans-serif;
  letter-spacing: 0.35em;
  color: var(--text);
}

body.mode-mobile .keys-hint {
  font-family: inherit;
  letter-spacing: 0.02em;
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 22px;
  background: var(--accent);
  color: #062016;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button[hidden] {
  display: none !important;
}

#resume-btn,
#restart-btn {
  background: #f3e8ff;
}

.help {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

@keyframes pop {
  from {
    transform: translate(-50%, -40%) scale(0.86);
    opacity: 0.2;
  }
  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}
