:root {
  --page: #11131a;
  --panel: #1a1d25;
  --panel-soft: #222733;
  --text: #f6f1e6;
  --muted: #b9b3a6;
  --line: rgba(246, 241, 230, 0.15);
  --gold: #f0b848;
  --gold-strong: #ffd36b;
  --red: #d94a3a;
  --green: #2fb374;
  --steel: #7fa7bf;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(217, 74, 58, 0.16), transparent 32%),
    linear-gradient(315deg, rgba(47, 179, 116, 0.14), transparent 30%),
    linear-gradient(180deg, #15171d 0%, #101218 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

button {
  font: inherit;
}

.timer-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  display: grid;
  align-items: center;
}

.timer-panel {
  width: 100%;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(26, 29, 37, 0.96), rgba(17, 19, 26, 0.98));
  box-shadow: var(--shadow);
}

.timer-topline {
  display: block;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 6vw, 38px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: 0;
}

.sound-state {
  min-height: 22px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.sound-state.ready {
  color: #b9e8cf;
}

.stage-strip {
  margin-top: 22px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stage-name {
  color: var(--gold-strong);
  font-size: clamp(22px, 5.5vw, 34px);
  font-weight: 800;
}

.stage-meta {
  color: var(--muted);
  font-size: 15px;
  text-align: right;
}

.time-display {
  margin: 18px 0 14px;
  min-height: 162px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  font-variant-numeric: tabular-nums;
}

#timerValue {
  color: var(--text);
  font-size: clamp(108px, 30vw, 190px);
  line-height: 0.9;
  font-weight: 900;
  letter-spacing: 0;
}

.time-display.warning #timerValue {
  color: #ff796c;
}

.time-unit {
  color: var(--muted);
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 700;
}

.progress-track {
  height: 16px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(246, 241, 230, 0.11);
}

.progress-bar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--red));
  transition: width 120ms linear;
}

.pick-track {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 7px;
}

.pick-dot {
  height: 10px;
  border-radius: 8px;
  background: rgba(246, 241, 230, 0.14);
}

.pick-dot.done {
  background: var(--green);
}

.pick-dot.current {
  background: var(--gold-strong);
}

.controls {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.control-button {
  min-height: 54px;
  padding: 12px 14px;
  border: 1px solid rgba(246, 241, 230, 0.18);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-soft);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.control-button.primary {
  color: #15110a;
  border-color: transparent;
  background: var(--gold);
}

.control-button.danger {
  color: #fff7f2;
  border-color: transparent;
  background: var(--red);
}

.control-button:active {
  transform: translateY(1px);
}

.control-button:disabled {
  cursor: default;
  opacity: 0.45;
  transform: none;
}

.rules {
  margin: 20px 0 0;
  display: grid;
  gap: 10px;
}

.rules div {
  padding: 12px 0 0;
  border-top: 1px solid rgba(246, 241, 230, 0.12);
}

.rules dt {
  color: var(--steel);
  font-size: 14px;
  font-weight: 800;
}

.rules dd {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

@media (max-width: 520px) {
  .timer-shell {
    align-items: stretch;
  }

  .timer-panel {
    padding: 16px;
  }

  .timer-topline {
    display: block;
  }

  .stage-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .stage-meta {
    text-align: left;
  }

  .time-display {
    min-height: 132px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .control-button {
    min-height: 52px;
  }
}
