:root {
  color-scheme: dark;

  --bg: #0b0f19;
  --bg-elevated: #131a2a;
  --bg-elevated-2: #1a2236;
  --text: #eef1f7;
  --text-dim: #8b93a7;
  --accent: #34d399;
  --accent-dim: #1f5c46;
  --danger: #f87171;
  --track: rgba(255, 255, 255, 0.08);
  --shadow: rgba(0, 0, 0, 0.4);

  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --bg-elevated-2: #eef1f7;
  --text: #101522;
  --text-dim: #5b6474;
  --accent: #059669;
  --accent-dim: #c9f1e0;
  --danger: #dc2626;
  --track: rgba(16, 21, 34, 0.08);
  --shadow: rgba(16, 21, 34, 0.12);
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI",
    "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
  user-select: none;
  transition: background 0.25s ease, color 0.25s ease;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 4px;
}

.app-header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.02em;
}

.icon-btn {
  border: none;
  background: var(--bg-elevated);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--shadow);
}

.icon-btn:active {
  transform: scale(0.92);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 12px 20px 24px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* --- 円形プログレス --- */

.timer-display {
  position: relative;
  width: min(72vw, 280px);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring__track,
.progress-ring__bar {
  fill: none;
  stroke-width: 14;
}

.progress-ring__track {
  stroke: var(--track);
}

.progress-ring__bar {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 590.6;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.2s linear, stroke 0.25s ease;
}

.timer-display.finished .progress-ring__bar {
  stroke: var(--danger);
}

.timer-center {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.time-text {
  font-size: clamp(2.1rem, 9vw, 2.8rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.status-label {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* --- プリセットチップ --- */

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: 100%;
}

.chip {
  border: none;
  background: var(--bg-elevated);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 2px 6px var(--shadow);
}

.chip:active {
  transform: scale(0.94);
}

.chip.active {
  background: var(--accent);
  color: #06281c;
}

/* --- カスタムピッカー --- */

.custom-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.picker-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  box-shadow: 0 2px 8px var(--shadow);
}

.picker-value {
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 2.2ch;
  text-align: center;
}

.picker-label {
  font-size: 0.65rem;
  color: var(--text-dim);
}

.stepper {
  border: none;
  background: var(--bg-elevated-2);
  color: var(--text);
  width: 38px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

.stepper:active {
  transform: scale(0.9);
}

.picker-sep {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-dim);
  padding-bottom: 18px;
}

/* --- 操作ボタン --- */

.controls {
  display: flex;
  gap: 14px;
  width: 100%;
  margin-top: 4px;
}

.btn {
  flex: 1;
  border: none;
  border-radius: var(--radius-lg);
  padding: 18px 0;
  font-size: 1.05rem;
  font-weight: 700;
  box-shadow: 0 4px 14px var(--shadow);
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--accent);
  color: #06281c;
}

.btn-primary.is-running {
  background: var(--danger);
  color: #2a0a0a;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
}

.custom-picker.disabled,
.presets.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* --- インストール導線 --- */

.install-btn {
  border: none;
  background: var(--bg-elevated-2);
  color: var(--accent);
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
}

.ios-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  margin: 0;
  padding: 0 12px;
}

.app-footer {
  text-align: center;
  padding: 0 24px 18px;
}

.app-footer p {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.5;
}

@media (min-width: 600px) {
  .main {
    gap: 28px;
  }
}
