:root {
  --ui-text: #1f1f1f;
  --ui-muted: #4b4b4b;
  --ui-panel: rgba(255, 255, 255, 0.82);
  --ui-border: rgba(22, 22, 22, 0.18);
  --accent: #2e7df0;
  --timer-fill: #ffffff;
  --timer-stroke: #101010;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  transition: background-color 300ms ease;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ui-text);
  background: #e8f2e2;
}

.interval-app {
  min-height: 100vh;
  padding: max(0.9rem, env(safe-area-inset-top)) 1.1rem max(1rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.interval-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-link {
  color: var(--ui-muted);
  text-decoration: none;
  font-size: 1rem;
}

.icon-btn {
  border: 1px solid var(--ui-border);
  border-radius: 999px;
  background: var(--ui-panel);
  color: #333;
  padding: 0.35rem 0.65rem;
  font-size: 1.1rem;
  cursor: pointer;
}

.interval-meta {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.primary-btn,
.ghost-btn {
  border-radius: 999px;
  border: 0;
  padding: 0.4rem 0.75rem;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  cursor: pointer;
}

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

.ghost-btn {
  border: 1px solid var(--ui-border);
  background: #fff;
  color: #222;
}

.round-info {
  text-align: right;
}

.round-text {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.8rem);
  color: #3f3f3f;
}

.round-text span {
  font-weight: 700;
}

.divider {
  opacity: 0.5;
  padding: 0 0.1rem;
}

.phase-text {
  margin: 0;
  font-size: clamp(0.9rem, 1.4vw, 1.2rem);
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #333;
}

.timer-zone {
  flex: 1;
  margin-top: 0.3rem;
  border: 0;
  background: transparent;
  width: 100%;
  max-width: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  cursor: pointer;
  overflow: hidden;
}

.timer-value {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  line-height: 0.9;
  font-size: min(66vw, 45vh);
  color: var(--timer-fill);
  -webkit-text-stroke: 3px var(--timer-stroke);
  text-shadow:
    -2px -2px 0 var(--timer-stroke),
    2px -2px 0 var(--timer-stroke),
    -2px 2px 0 var(--timer-stroke),
    2px 2px 0 var(--timer-stroke),
    0 3px 0 rgba(0, 0, 0, 0.16);
}

.timer-hint {
  margin-top: -0.3em;
  font-size: clamp(1.7rem, 4.8vw, 3.3rem);
  font-weight: 700;
  color: rgba(0, 0, 0, 0.58);
}

.timer-zone.running .timer-hint {
  visibility: hidden;
}

.settings-panel {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: min(90vw, 360px);
  border: 1px solid var(--ui-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
  padding: 1rem;
  z-index: 40;
  display: none;
}

.settings-panel.open {
  display: block;
}

.settings-panel h2 {
  margin: 0 0 0.7rem;
}

.settings-panel label {
  display: block;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.93rem;
  color: #3f3f3f;
}

.settings-panel input,
.settings-panel select {
  width: 100%;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-family: "IBM Plex Mono", monospace;
  background: #fff;
}

.settings-note {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: #626262;
}

.settings-actions {
  margin-top: 0.9rem;
  display: flex;
  gap: 0.45rem;
}

.phase-flash {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #111111;
  text-align: center;
  pointer-events: none;
}

.phase-flash.visible {
  display: flex;
  animation: phaseFlashPulse 260ms steps(2, end) infinite;
}

.phase-flash p {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: clamp(2.6rem, 11vw, 8rem);
}

@keyframes phaseFlashPulse {
  0%, 100% {
    background: #ffffff;
    color: #111111;
  }
  50% {
    background: #111111;
    color: #ffffff;
  }
}

@media (max-width: 780px) {
  .timer-value {
    font-size: min(56vw, 26vh);
    -webkit-text-stroke: 1.8px var(--timer-stroke);
    text-shadow:
      -1px -1px 0 var(--timer-stroke),
      1px -1px 0 var(--timer-stroke),
      -1px 1px 0 var(--timer-stroke),
      1px 1px 0 var(--timer-stroke);
    display: inline-block;
    transform: scaleY(0.82);
    transform-origin: center center;
  }

  .timer-hint {
    font-size: clamp(1.2rem, 5.8vw, 1.8rem);
  }
}

@media (max-width: 780px) and (orientation: portrait) {
  .timer-value {
    font-size: min(30vw, 14vh);
    transform: scaleY(0.82);
  }
}
