:root {
  --bg: #14110f;
  --bg-2: #1e1a17;
  --card: #26211d;
  --line: #3a322c;
  --ink: #f6efe6;
  --muted: #a89b8d;
  --accent: #ffb347;
  --hot: #ff3b2f;
  --hot-2: #ff7a1a;
  --ok: #7fd6a3;
  --radius: 22px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(120% 60% at 50% -10%, #3a2616 0%, transparent 60%),
    var(--bg);
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

.app {
  max-width: 440px;
  min-height: 100%;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
}

/* header */
.top { text-align: center; }
.brand {
  margin: 4px 0 2px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand-face { display: inline-block; transition: transform .3s cubic-bezier(.3,1.6,.5,1); }
.tag { margin: 0; color: var(--muted); font-size: 14px; }

/* dial */
.dial-wrap {
  position: relative;
  width: min(78vw, 290px);
  aspect-ratio: 1;
  margin: 4px auto 0;
}
.dial { width: 100%; height: 100%; transform: rotate(-90deg); }
.dial-track { fill: none; stroke: var(--bg-2); stroke-width: 12; }
.dial-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 552.92;
  stroke-dashoffset: 0;
  transition: stroke .4s ease;
  filter: drop-shadow(0 0 10px rgba(255,179,71,.35));
}
.readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.time {
  font-family: var(--mono);
  font-size: clamp(52px, 17vw, 68px);
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.sub { color: var(--muted); font-size: 14px; }

.scream-text {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(.4) rotate(-8deg);
  font-size: 54px;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: #fff;
  text-shadow: 0 0 24px var(--hot), 4px 4px 0 var(--hot);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

/* setter */
.setter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stepper {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
}
.step {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--bg-2);
  font-size: 22px;
  font-weight: 600;
  transition: transform .12s ease, background .2s;
}
.step:active { transform: scale(.9); background: var(--line); }
.step-label { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.step-label strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.step-label span { font-size: 12px; color: var(--muted); }

/* presets */
.presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.presets button {
  padding: 10px 0;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  transition: all .15s ease;
}
.presets button:active { transform: scale(.94); }
.presets button.on { color: var(--bg); background: var(--accent); border-color: var(--accent); }

/* voices */
.voices {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.voices-title {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  text-align: center;
}
.voice-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.voice-row button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  border-radius: 14px;
  background: var(--bg-2);
  border: 1.5px solid transparent;
  font-size: 14px;
  font-weight: 600;
  transition: all .15s ease;
}
.voice-row button span { font-size: 24px; transition: transform .25s cubic-bezier(.3,1.6,.5,1); }
.voice-row button.on { border-color: var(--hot-2); background: #33211a; }
.voice-row button.on span { transform: scale(1.18) rotate(-6deg); }
.preview {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* controls */
.controls {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
  margin-top: auto;
}
.btn {
  height: 58px;
  border-radius: 18px;
  font-size: 18px;
  font-weight: 700;
  transition: transform .12s ease, background .2s, opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn.primary {
  background: linear-gradient(180deg, var(--accent), var(--hot-2));
  color: #1b0f05;
  box-shadow: 0 10px 30px -10px rgba(255,122,26,.6);
}
.btn.ghost { background: var(--card); border: 1px solid var(--line); color: var(--muted); }

/* shut up button (only when screaming) */
.shutup {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translate(-50%, 140%);
  width: min(90vw, 400px);
  height: 76px;
  border-radius: 24px;
  background: #fff;
  color: var(--hot);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: .02em;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,.6);
  transition: transform .35s cubic-bezier(.3,1.4,.5,1);
  z-index: 10;
}
.shutup:active { transform: translate(-50%, 0) scale(.96); }

/* states */
.app[data-state="running"] .setter,
.app[data-state="running"] .presets,
.app[data-state="running"] .voices {
  opacity: .35;
  pointer-events: none;
  filter: saturate(.4);
}
.setter, .presets, .voices { transition: opacity .3s, filter .3s; }

.app[data-state="running"] .dial-fill { stroke: var(--accent); }
.app.urgent .dial-fill { stroke: var(--hot-2); filter: drop-shadow(0 0 14px rgba(255,122,26,.6)); }
.app.urgent .time { animation: pulse 1s ease-in-out infinite; }

body.screaming {
  animation: flash .18s steps(2) infinite;
}
body.screaming .app { animation: shake .09s linear infinite; }
body.screaming .setter,
body.screaming .presets,
body.screaming .voices,
body.screaming .controls { opacity: 0; pointer-events: none; }
body.screaming .readout { opacity: 0; }
body.screaming .dial-fill { stroke: #fff; }
body.screaming .scream-text { animation: yell .5s ease-in-out infinite alternate; opacity: 1; }
body.screaming .shutup { transform: translate(-50%, 0); }
body.screaming .tag { color: #fff; }

@keyframes flash {
  0% { background: var(--hot); }
  100% { background: #1a0000; }
}
@keyframes shake {
  0% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(-4px, 3px) rotate(-.6deg); }
  50% { transform: translate(3px, -3px) rotate(.5deg); }
  75% { transform: translate(-3px, -2px) rotate(-.3deg); }
  100% { transform: translate(0, 0) rotate(0); }
}
@keyframes yell {
  from { transform: translate(-50%, -50%) scale(.9) rotate(-8deg); }
  to { transform: translate(-50%, -50%) scale(1.15) rotate(6deg); }
}
@keyframes pulse {
  50% { color: var(--hot-2); transform: scale(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  body.screaming, body.screaming .app { animation: none; background: var(--hot); }
  body.screaming .scream-text { animation: none; transform: translate(-50%, -50%) rotate(-6deg); }
}

@media (min-height: 820px) {
  .app { gap: 22px; padding-top: 36px; }
}
