:root {
  --bg-primary: #0D1117;
  --bg-secondary: #161B22;
  --bg-tertiary: #21262D;
  --text-primary: #F0F6FC;
  --text-secondary: #8B949E;
  --text-muted: #484F58;
  --accent: #3B82F6;
  --border: #30363D;
  --btn-bg: #21262D;
  --overlay-bg: rgba(0, 0, 0, 0.85);
  --board-bg: #0A0E14;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F6F8FA;
    --bg-tertiary: #E9ECF0;
    --text-primary: #1B1E28;
    --text-secondary: #57606A;
    --text-muted: #8C959F;
    --accent: #3182F6;
    --border: #D0D7DE;
    --btn-bg: #E9ECF0;
    --overlay-bg: rgba(255, 255, 255, 0.9);
    --board-bg: #F0F2F5;
  }
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  touch-action: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Overlay screens ── */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  background: var(--overlay-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.screen-content {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
}

/* ── Start screen ── */
.game-title {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 50%, #EC4899 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
}

.game-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.6;
}

.best-record {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

.record-value {
  font-weight: 700;
  color: var(--accent);
}

.btn-primary {
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #3B82F6, #8B5CF6);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* ── Game area ── */
#game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 8px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.header-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-best {
  font-size: 12px;
  color: var(--text-muted);
}

.round-indicator {
  display: flex;
  gap: 4px;
}

.round-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s;
}

.round-dot.done {
  background: var(--accent);
}

.round-dot.current {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 4px var(--accent); }
  50% { box-shadow: 0 0 12px var(--accent); }
}

/* ── Play field ── */
.play-field {
  flex: 1;
  position: relative;
  background: var(--board-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.field-message {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  pointer-events: none;
  z-index: 2;
}

.field-message.result {
  font-size: 28px;
  color: var(--accent);
}

/* ── Target circle ── */
.target-circle {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #F87171, #EF4444);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5), inset -3px -3px 6px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 10;
  animation: targetAppear 0.15s ease-out;
  transition: transform 0.08s;
}

.target-circle:active {
  transform: scale(0.9);
}

/* inner ring */
.target-circle::before {
  content: '';
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #FECACA, #FCA5A5);
  top: 15px;
  left: 15px;
}

/* center dot */
.target-circle::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  top: 25px;
  left: 25px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

@keyframes targetAppear {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* hit animation */
.target-circle.hit {
  animation: targetHit 0.3s ease-out forwards;
  pointer-events: none;
}

@keyframes targetHit {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.5; }
  100% { transform: scale(0); opacity: 0; }
}

/* ── Round log ── */
.round-log {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  min-height: 24px;
}

.round-log-item {
  padding: 3px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  animation: fadeIn 0.2s ease;
}

.round-log-item.latest {
  border-color: var(--accent);
  color: var(--accent);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Results screen ── */
.results-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.results-avg-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.results-avg-time {
  font-size: 48px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #8B5CF6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.results-rating {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
}

.new-record-banner {
  padding: 8px 20px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid var(--accent);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  display: none;
}

.new-record-banner.show {
  display: block;
}

.results-cards {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.result-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.result-card.best {
  border-color: var(--accent);
}

.result-card-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.result-card-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.rounds-list-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  align-self: flex-start;
}

.rounds-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.round-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.round-row.best-round {
  border-color: var(--accent);
}

.round-row-label {
  color: var(--text-secondary);
  font-weight: 600;
}

.round-row-time {
  font-weight: 700;
  color: var(--text-primary);
}

.round-row-time .unit {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-retry {
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #3B82F6, #8B5CF6);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-retry:active {
  transform: scale(0.98);
}
