: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;

  --work-color: #ff5a36;
  --work-color-dim: #7a3222;
  --rest-color: #3aa0ff;
  --rest-color-dim: #234a6b;

  --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);
}

/* ======================================================
   SETTINGS 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: 0.5px;
}

.settings-rows {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

.setting-row {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.setting-label {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.setting-label-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stepper-btn {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.stepper-btn:focus { background: #262a2f; }
.stepper-btn:active { background: #2f343a; }

.setting-value {
  min-width: 96px;
  text-align: center;
  font-size: 23px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.setting-value .unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 3px;
}

.settings-summary {
  flex-shrink: 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  padding: 10px 0 4px;
}

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

/* ======================================================
   TIMER SCREEN
   ====================================================== */
#timer {
  gap: 14px;
}

.timer-tap-zone {
  position: relative;
  flex: 1;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  border-width: 3px;
}
.timer-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 */
}

.round-indicator {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.phase-label {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 2px;
  transition: color 300ms ease;
}

.countdown {
  font-size: 104px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text-primary);
  margin: 4px 0;
}

.phase-progress {
  width: 88%;
  height: 10px;
  border-radius: 6px;
  background: var(--bg-elevated);
  overflow: hidden;
  flex-shrink: 0;
}
.phase-progress-fill {
  height: 100%;
  width: 100%;
  border-radius: 6px;
  background: var(--work-color);
  transition: width 220ms linear, background-color 300ms ease;
}

.tap-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Phase color theming, toggled via class on the tap zone */
.timer-tap-zone.phase-work .phase-label { color: var(--work-color); }
.timer-tap-zone.phase-work .phase-progress-fill { background: var(--work-color); }
.timer-tap-zone.phase-rest .phase-label { color: var(--rest-color); }
.timer-tap-zone.phase-rest .phase-progress-fill { background: var(--rest-color); }

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

/* --- Pause overlay --- */
.pause-overlay {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: rgba(8, 9, 11, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
}
.pause-overlay.hidden { display: none; }
.pause-overlay-text {
  font-size: 34px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 1px;
}
.pause-overlay-hint {
  font-size: 15px;
  color: var(--text-muted);
}

/* ======================================================
   FINISH SCREEN
   ====================================================== */
#finish {
  align-items: stretch;
  justify-content: space-between;
}

.finish-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}

.finish-emoji {
  font-size: 56px;
  line-height: 1;
}

.finish-title {
  font-size: 26px;
  font-weight: 800;
}

.finish-stats {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 18px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.finish-stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.finish-stat-value {
  font-size: 42px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

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

.finish-btn {
  height: 68px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 19px;
  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(--work-color);
  color: #1a0800;
}
.finish-btn.primary:focus { background: #ff7452; }
