:root {
  --bg-0: #05030f;
  --bg-1: #0d0726;
  --bg-2: #160a36;
  --cyan: #22d3ee;
  --pink: #f472b6;
  --lime: #a3e635;
  --gold: #fbbf24;
  --violet: #a78bfa;
  --ink: #f5f3ff;
  --muted: #a99fce;
  --panel: rgba(18, 10, 42, 0.72);
  --line: rgba(167, 139, 250, 0.28);
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100dvh;
  font-family: "Hiragino Kaku Gothic ProN", "Segoe UI", system-ui, -apple-system,
    sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 50% -10%, #2a1160 0%, transparent 60%),
    radial-gradient(900px 600px at 90% 110%, #3d0d52 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 55%, var(--bg-2));
  background-attachment: fixed;
  overflow-x: hidden;
}

.game-shell {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 16px 14px 40px;
}

.hero {
  text-align: center;
  padding: 6px 0 12px;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.32em;
  font-weight: 800;
  color: var(--cyan);
  text-transform: uppercase;
}

.hero h1 {
  margin: 4px 0 2px;
  font-size: clamp(26px, 8vw, 38px);
  font-weight: 900;
  letter-spacing: 0.02em;
  background: linear-gradient(92deg, #7df9ff, #f472b6 60%, #fbbf24);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 24px rgba(124, 249, 255, 0.18);
}

.hero-copy {
  margin: 6px auto 0;
  max-width: 30em;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.mode-switch {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
}

.mode-button {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: transparent;
  transition: all 0.18s ease;
}

.mode-button[aria-pressed="true"] {
  color: #06121a;
  background: linear-gradient(120deg, var(--cyan), #67e8f9);
  box-shadow: 0 6px 18px rgba(34, 211, 238, 0.35);
}

.mode-button.is-hard[aria-pressed="true"] {
  background: linear-gradient(120deg, var(--pink), #fb7185);
  box-shadow: 0 6px 18px rgba(244, 114, 182, 0.35);
  color: #1a0410;
}

.stage-frame {
  position: relative;
  margin: 16px auto 0;
  width: 100%;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.hud-cell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 6px;
  text-align: center;
  backdrop-filter: blur(6px);
}

.hud-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud-value {
  display: block;
  margin-top: 2px;
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

#hud-time.is-low {
  color: #fb7185;
  animation: pulse 0.6s ease-in-out infinite;
}

#hud-combo {
  color: var(--gold);
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

.canvas-wrap {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 24px 60px rgba(8, 2, 30, 0.7),
    inset 0 0 80px rgba(124, 58, 237, 0.12);
  background: #060216;
  touch-action: none;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 22px;
  text-align: center;
  background: radial-gradient(
    120% 120% at 50% 30%,
    rgba(13, 7, 38, 0.78),
    rgba(5, 3, 15, 0.92)
  );
  backdrop-filter: blur(4px);
  z-index: 5;
}

.overlay.hidden {
  display: none;
}

.overlay h2 {
  margin: 0;
  font-size: clamp(24px, 7vw, 34px);
  font-weight: 900;
  letter-spacing: 0.02em;
}

.overlay .lead {
  margin: 0;
  max-width: 26em;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}

.tips {
  display: grid;
  gap: 6px;
  margin: 2px 0 4px;
  font-size: 12.5px;
  color: var(--muted);
}

.tips span strong {
  color: var(--cyan);
}

.tips span.danger strong {
  color: #fb7185;
}

.tips span.gold strong {
  color: var(--gold);
}

.primary-button {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 14px 34px;
  border-radius: 16px;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #04121a;
  background: linear-gradient(120deg, #7df9ff, #22d3ee 55%, #34d399);
  box-shadow: 0 12px 30px rgba(34, 211, 238, 0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 38px rgba(34, 211, 238, 0.5);
}

.primary-button:active {
  transform: translateY(0);
}

.result-score {
  font-size: clamp(40px, 13vw, 64px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(100deg, #fbbf24, #f472b6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.result-meta {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.result-meta b {
  color: var(--ink);
  font-size: 16px;
}

.result-rank {
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}

.result-rank b {
  color: var(--gold);
  font-size: 17px;
}

.name-row {
  display: flex;
  gap: 8px;
  width: min(100%, 340px);
}

.name-row input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font-size: 15px;
  outline: none;
}

.name-row input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}

.name-row input:disabled {
  opacity: 0.7;
}

.submit-button {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 14px;
  color: #150318;
  background: linear-gradient(120deg, var(--gold), #fb923c);
  box-shadow: 0 8px 20px rgba(251, 191, 36, 0.3);
  white-space: nowrap;
}

.submit-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.feedback {
  min-height: 16px;
  font-size: 12.5px;
  font-weight: 700;
}

.feedback.ok {
  color: var(--lime);
}

.feedback.err {
  color: #fb7185;
}

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

.ghost-button {
  appearance: none;
  cursor: pointer;
  padding: 11px 20px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  transition: background 0.15s ease;
}

.ghost-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Ranking */
.ranking-panel {
  margin: 18px auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  backdrop-filter: blur(6px);
}

.ranking-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.ranking-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.tab-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
}

.tab-button {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
}

.tab-button[aria-pressed="true"] {
  color: #06121a;
  background: var(--cyan);
}

.ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.ranking-entry {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.ranking-entry.is-me {
  border-color: var(--gold);
  background: rgba(251, 191, 36, 0.1);
}

.ranking-pos {
  font-weight: 900;
  font-size: 15px;
  color: var(--muted);
  text-align: center;
}

.ranking-entry:nth-child(1) .ranking-pos {
  color: #fde047;
}
.ranking-entry:nth-child(2) .ranking-pos {
  color: #e2e8f0;
}
.ranking-entry:nth-child(3) .ranking-pos {
  color: #fdba74;
}

.ranking-name {
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-score {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--cyan);
}

.ranking-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 18px 0;
}

.platform-link {
  display: block;
  text-align: center;
  margin-top: 22px;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}

.platform-link:hover {
  color: var(--cyan);
}

@media (max-width: 380px) {
  .hud-value {
    font-size: 17px;
  }
}
