:root {
  /* additive-display surfaces: pure black = transparent, UI needs dark-gray surfaces to stay visible */
  --bg-primary: #000000;
  --bg-surface: #0a0a0f;
  --bg-card: #15171b;
  --bg-elevated: #1c1e21;

  --text-primary: #ffffff;
  --text-secondary: #e4e6eb;
  --text-muted: #b0b3b8;

  --wait-color: #ffb347;
  --go-color: #37ef7a;
  --go-color-deep: #0d3a1f;
  --early-color: #ff5252;
  --early-color-deep: #3a0d0d;

  --focus-ring: #ffd166;
  --focus-glow: rgba(255, 209, 102, 0.45);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 600px;
  height: 600px;
  overflow: hidden;
  background: var(--bg-primary); /* transparent on additive display */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  color: var(--text-primary);
}

#app {
  width: 600px;
  height: 600px;
  position: relative;
}

/* --- Screens --- */
.screen {
  width: 600px;
  height: 600px;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  padding: 22px 26px;
  box-sizing: border-box;
}
.screen.hidden { display: none; }

/* --- Focus states (D-pad / EMG tap target) --- */
.focusable {
  border: 2px solid transparent;
  transition:
    transform 475ms cubic-bezier(0.6, 0, 0.4, 1),
    border-color 300ms cubic-bezier(0.4, 0.04, 0.5, 1),
    box-shadow 300ms cubic-bezier(0.4, 0.04, 0.5, 1),
    background-color 300ms cubic-bezier(0.4, 0.04, 0.5, 1);
  cursor: pointer;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 18px var(--focus-glow);
  transform: scale(0.97);
}

/* ======================================================
   TITLE SCREEN
   ====================================================== */
.header {
  flex-shrink: 0;
  text-align: center;
  padding-bottom: 14px;
}
.header h1 {
  font-size: 27px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.header-sub {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 1.5px;
}

.title-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  text-align: center;
}
.title-desc {
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 480px;
}
.best-badge {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px 26px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.start-btn {
  flex-shrink: 0;
  height: 76px;
  border-radius: var(--radius-lg);
  background: var(--go-color);
  color: var(--go-color-deep);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.start-btn:focus { background: #5cf797; }
.start-btn:active { background: #1fd664; }

/* ======================================================
   ROUND SCREEN
   ====================================================== */
#round {
  gap: 14px;
}

.round-meta {
  flex-shrink: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.round-meta-sep { margin: 0 3px; opacity: 0.6; }
.best-mini {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.tap-zone {
  position: relative;
  flex: 1;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-width: 3px;
  transition:
    background-color 120ms cubic-bezier(0.4, 0.04, 0.5, 1),
    border-color 300ms cubic-bezier(0.4, 0.04, 0.5, 1),
    box-shadow 300ms cubic-bezier(0.4, 0.04, 0.5, 1);
}
.tap-zone:focus {
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 26px rgba(255, 255, 255, 0.12);
  transform: none; /* full-screen zone: skip the scale-press to avoid a jarring jump */
}

.tap-zone-text {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-secondary);
  text-align: center;
}

/* Phase theming, toggled via class on the tap zone */
.tap-zone.phase-go {
  background: var(--go-color);
  border-color: var(--go-color);
}
.tap-zone.phase-go .tap-zone-text { color: var(--go-color-deep); font-size: 58px; }

.tap-zone.phase-early {
  background: var(--early-color);
  border-color: var(--early-color);
}
.tap-zone.phase-early .tap-zone-text { color: var(--early-color-deep); font-size: 46px; }

.tap-zone.phase-caught .tap-zone-text {
  font-size: 72px;
  font-variant-numeric: tabular-nums;
}

.quit-btn {
  flex-shrink: 0;
  height: 50px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.quit-btn:focus { background: var(--bg-elevated); color: var(--text-primary); }

/* ======================================================
   RESULT SCREEN
   ====================================================== */
#result {
  gap: 12px;
}

.result-summary {
  flex-shrink: 0;
  display: flex;
  gap: 14px;
}
.result-stat {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.result-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.result-stat-value {
  font-size: 32px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.result-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
}
.result-list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 14px;
  color: var(--text-secondary);
}
.result-list-row .val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.new-best-badge {
  flex-shrink: 0;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--go-color);
}
.new-best-badge.hidden { display: none; }

.result-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.finish-btn {
  height: 62px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.finish-btn:focus { background: var(--bg-elevated); color: var(--text-primary); }
.finish-btn.primary {
  background: var(--go-color);
  color: var(--go-color-deep);
}
.finish-btn.primary:focus { background: #5cf797; }
