:root {
  --bg: #14161a;
  --fg: #f2f2ef;
  --muted: #8b9099;
  --line: #2a2e35;
  --calm: #3ecf8e;
  --caution: #f5b83d;
  --danger: #ff5a4f;
  --accent: var(--calm);
  color-scheme: dark;
}
body[data-phase="caution"] { --accent: var(--caution); }
body[data-phase="danger"],
body[data-phase="done"] { --accent: var(--danger); }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  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);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  transition: background-color .3s;
}
/* Süre dolunca ekran birkaç kez kırmızı yanıp söner: masadaki herkes görsün. */
body[data-status="done"] { animation: flash .5s ease-in-out 6 alternate; }
@keyframes flash { to { background: #5a1612; } }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
svg { display: block; fill: currentColor; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 0;
}
.bar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.bar-actions { display: flex; gap: 4px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:hover { color: var(--fg); }
#sound .off { display: none; }
#sound[aria-pressed="false"] .on { display: none; }
#sound[aria-pressed="false"] .off { display: inline; }

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 4vh, 40px);
  padding: 12px 18px 24px;
}

.dial {
  position: relative;
  width: min(80vw, 52vh, 440px);
  aspect-ratio: 1;
  border-radius: 50%;
}
.dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.track, .arc { fill: none; stroke-width: 10; }
.track { stroke: var(--line); }
.arc {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 565.49; /* 2πr, r=90 */
  stroke-dashoffset: 0;
  transition: stroke .3s;
}
.readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.time {
  font-size: min(22vw, 14vh, 120px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1;
}
body[data-phase="danger"][data-status="running"] .time { color: var(--danger); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.hint { font-size: 14px; color: var(--muted); min-height: 1.3em; }
body[data-status="done"] .hint { color: var(--danger); font-weight: 600; font-size: 18px; }

.controls { display: flex; align-items: center; gap: 18px; }
.round {
  width: 60px; height: 60px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 2px solid var(--line);
}
.round svg { width: 26px; height: 26px; }
.round.primary {
  width: 80px; height: 80px;
  border: 0;
  background: var(--accent);
  color: #0d0f12;
  transition: background-color .3s;
}
.round.primary svg { width: 36px; height: 36px; }
.i-pause { display: none; }
body[data-status="running"] .i-play { display: none; }
body[data-status="running"] .i-pause { display: inline; }
.step {
  width: 52px; height: 52px;
  border-radius: 50%;
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.step:hover, .round:hover { color: var(--fg); }

.presets { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.presets button {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}
.presets button[aria-pressed="true"] { border-color: var(--accent); color: var(--fg); }
.presets button:disabled { opacity: .35; cursor: default; }

/* Yatay telefon: kadran solda, düğmeler sağda. */
@media (orientation: landscape) and (max-height: 520px) {
  main { flex-direction: row; flex-wrap: wrap; gap: 24px 40px; }
  .dial { width: min(70vh, 340px); }
  .time { font-size: min(16vh, 90px); }
  .controls + .presets { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  body[data-status="done"], body[data-phase="danger"][data-status="running"] .time { animation: none; }
}
