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

  --breath-color: #6fd7ff;
  --breath-color-deep: #05303f;
  --hold-color: #ffd166;
  --hold-color-deep: #3a2a05;

  --focus-ring: #6fd7ff;
  --focus-glow: rgba(111, 215, 255, 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: 20px 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: 8px;
}
.header h1 {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.header-sub {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 1.5px;
}

.title-desc {
  flex-shrink: 0;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  padding: 4px 6px 14px;
}

.option-group {
  flex-shrink: 0;
  margin-bottom: 12px;
}
.option-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
  padding-bottom: 6px;
}
.option-row {
  display: flex;
  gap: 10px;
}
.option-btn {
  flex: 1;
  height: 60px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.option-btn-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-secondary);
}
.option-btn-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.option-btn.selected {
  background: var(--breath-color);
}
.option-btn.selected .option-btn-title,
.option-btn.selected .option-btn-sub {
  color: var(--breath-color-deep);
}
.option-btn:focus .option-btn-title,
.option-btn:focus .option-btn-sub {
  color: var(--text-primary);
}
.option-btn.selected:focus .option-btn-title,
.option-btn.selected:focus .option-btn-sub {
  color: var(--breath-color-deep);
}

.title-footer {
  margin-top: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.start-btn {
  height: 72px;
  border-radius: var(--radius-lg);
  background: var(--breath-color);
  color: var(--breath-color-deep);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.start-btn:focus { background: #9be6ff; }
.start-btn:active { background: #38b7e6; }

/* ======================================================
   SESSION SCREEN
   ====================================================== */
#session {
  gap: 12px;
}

.session-meta {
  flex-shrink: 0;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.session-meta-sep { margin: 0 3px; opacity: 0.6; }
.session-meta-label {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 600;
}

.circle-zone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.breath-circle {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 4px solid var(--breath-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transform: scale(0.55);
  transform-origin: center center;
  transition: transform linear, background-color 400ms ease, border-color 400ms ease;
}
.breath-circle.expanded { transform: scale(1); }
.breath-circle.contracted { transform: scale(0.55); }
.breath-circle.phase-hold {
  background: var(--hold-color);
  border-color: var(--hold-color);
}

.breath-phase {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-secondary);
  transform: scale(1.35); /* counter the circle's own scale so text stays readable */
}
.breath-circle.expanded .breath-phase { transform: scale(1); }
.breath-circle.phase-hold .breath-phase { color: var(--hold-color-deep); }

.breath-countdown {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  transform: scale(1.35);
}
.breath-circle.expanded .breath-countdown { transform: scale(1); }
.breath-circle.phase-hold .breath-countdown { color: var(--hold-color-deep); opacity: 0.75; }

.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: 14px;
}

.result-summary {
  flex-shrink: 0;
  display: flex;
  gap: 14px;
  margin-top: 8px;
}
.result-stat {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  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: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.result-note {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 15px;
  color: var(--text-secondary);
}

.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(--breath-color);
  color: var(--breath-color-deep);
}
.finish-btn.primary:focus { background: #9be6ff; }
