:root {
  --brand-primary: #006269;
  --brand-secondary: #fcf14b;
  --brand-black: #000000;
  --brand-white: #ffffff;
  --idle-bg: var(--brand-primary);
  --prepare-bg: var(--brand-secondary);
  --work-bg: var(--brand-secondary);
  --rest-bg: var(--brand-secondary);
  --paused-bg: var(--brand-white);
  --done-bg: var(--brand-primary);
  --text: var(--brand-white);
  --text-dim: rgb(255 255 255 / 0.72);
  --btn-text: var(--brand-black);
  --surface: var(--brand-white);
  --surface-text: var(--brand-black);
  --radius: 15px;
  --radius-box: var(--radius) 0;
  --ease: 0.45s ease;
  --safe-top: max(1.25rem, env(safe-area-inset-top));
  --chrome-top: max(0.65rem, env(safe-area-inset-top));
  --chrome-size: 2.75rem;
  --bg: var(--brand-primary);
  --font-primary: "General Sans", sans-serif;
  --font-display: "Kaleko 105 Remix", sans-serif;
  --font-title: "Kaleko 105", sans-serif;
}

@font-face {
  font-family: "General Sans";
  src: url("./fonts/GeneralSans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "General Sans";
  src: url("./fonts/GeneralSans-Semibold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Kaleko 105";
  src: url("./fonts/Kaleko-105-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Kaleko 105";
  src: url("./fonts/Kaleko-105-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Kaleko 105 Remix";
  src: url("./fonts/Kaleko-105-Remix-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

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

html {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-primary);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: background-color var(--ease), color var(--ease);
}

body[data-phase="idle"],
body[data-phase="done"] {
  --bg: var(--brand-primary);
}

body[data-phase="prepare"],
body[data-phase="work"],
body[data-phase="rest"] {
  --bg: var(--brand-secondary);
  --text: var(--brand-black);
  --text-dim: rgb(0 0 0 / 0.62);
}

body[data-phase="paused"] {
  --bg: var(--brand-white);
  --text: var(--brand-black);
  --text-dim: rgb(0 0 0 / 0.62);
  --surface: var(--brand-primary);
  --surface-text: var(--brand-white);
}

.app {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  text-align: center;
  touch-action: none;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-primary);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.splash.is-done {
  display: none;
}

.brand-logo {
  display: block;
  width: min(14.25rem, 72vw);
  height: auto;
  pointer-events: none;
  opacity: 0;
  -webkit-filter: invert(1);
  filter: invert(1);
}

.brand-logo.is-held {
  opacity: 1;
}

body[data-screen="idle"] .idle-panel,
body[data-screen="idle"] .controls {
  opacity: 0;
}

body.is-ready[data-screen="idle"] .idle-panel,
body.is-ready[data-screen="idle"] .controls {
  opacity: 1;
  -webkit-transition: opacity 0.7s ease;
  transition: opacity 0.7s ease;
}

.idle-panel,
.done-panel,
.timer {
  display: none;
  width: 100%;
}

.eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 12vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0;
  font-family: var(--font-title);
  font-size: clamp(2.4rem, 10vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.summary {
  margin: 0.75rem 0 0;
  font-size: 1rem;
  color: var(--text-dim);
}

.timer {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
}

.phase-label {
  margin: 0;
  min-height: 1.4em;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.ring-wrap {
  width: min(88%, 28rem);
  margin-inline: auto;
  aspect-ratio: 1;
}

.ring {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ring-track,
.ring-progress {
  fill: none;
  stroke-width: 5.5;
}

.ring-track {
  stroke: var(--text);
  opacity: 0.22;
}

.ring-progress {
  stroke: var(--text);
  stroke-linecap: round;
  stroke-dasharray: 263.89;
  stroke-dashoffset: 0;
  transform: translateZ(0);
}

.countdown {
  transform-box: view-box;
  transform-origin: 50px 50px;
}

.countdown-digit {
  fill: var(--text);
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 400;
}

.countdown.is-pulse {
  animation: pulse 280ms ease-out;
}

.icon-btn {
  display: none;
  position: absolute;
  top: var(--chrome-top);
  right: max(0.75rem, env(safe-area-inset-right));
  z-index: 2;
  width: var(--chrome-size);
  height: var(--chrome-size);
  padding: 0;
  border: 0;
  border-radius: var(--radius-box);
  background: var(--surface);
  color: var(--surface-text);
  cursor: pointer;
  appearance: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--ease), color var(--ease);
}

.icon-btn svg {
  width: 1.15rem;
  height: 1.15rem;
}

.dock {
  display: none;
  position: absolute;
  bottom: 0;
  left: 50%;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: min(100%, 28rem);
  margin: 0;
  padding: 0 1.25rem max(0.75rem, env(safe-area-inset-bottom));
  box-sizing: border-box;
  transform: translateX(-50%);
}

.transport {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
}

#pause-btn,
#resume-btn {
  grid-column: 2;
  grid-row: 1;
}

.status {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  width: 100%;
  margin: 0;
  padding: 1.05rem 0;
}

.status-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.18rem;
  padding: 0 0.4rem;
}

.status-cell + .status-cell {
  border-left: 1px solid rgb(0 0 0 / 0.12);
}

.status-value,
.status-label {
  margin: 0;
}

.status-value {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}

.status-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.done-panel {
  padding-top: 0.5rem;
}

.controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: min(100%, 28rem);
  box-sizing: border-box;
}

.btn {
  display: none;
  width: min(100%, 18rem);
  min-height: 3.5rem;
  border: 0;
  border-radius: var(--radius-box);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn-primary {
  background: var(--brand-secondary);
  color: var(--brand-black);
}

.btn-surface {
  width: 100%;
  background: var(--surface);
  color: var(--surface-text);
  transition: background-color var(--ease), color var(--ease);
}

.btn-surface svg {
  width: 1.45rem;
  height: 1.45rem;
}

#resume-btn svg {
  margin-left: 0.12rem;
}

.btn-ghost {
  background: rgb(255 255 255 / 0.18);
  color: var(--text);
}

.btn:active,
.icon-btn:active {
  opacity: 1;
  transform: none;
}

.install-hint {
  display: none;
  margin: 0;
  max-width: 18rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-dim);
}

body[data-screen="idle"] .idle-panel,
body[data-screen="done"] .done-panel {
  display: block;
}

body[data-screen="idle"] #start-btn,
body[data-screen="running"] #pause-btn,
body[data-screen="running"] #prev-btn,
body[data-screen="running"] #next-btn,
body[data-screen="paused"] #resume-btn,
body[data-screen="paused"] #prev-btn,
body[data-screen="paused"] #next-btn,
body[data-screen="done"] #reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body[data-screen="running"] #stop-btn,
body[data-screen="paused"] #stop-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body[data-screen="idle"] .install-hint {
  display: block;
}

body[data-screen="idle"] .install-hint.is-hidden {
  display: none;
}

body[data-screen="running"] .timer,
body[data-screen="paused"] .timer {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
  align-items: center;
  justify-content: center;
}

body[data-screen="running"] .app,
body[data-screen="paused"] .app {
  justify-content: flex-end;
  padding-top: calc(var(--chrome-top) + var(--chrome-size));
}

body[data-screen="running"] .dock,
body[data-screen="paused"] .dock {
  display: flex;
  position: relative;
  left: auto;
  transform: none;
  flex-shrink: 0;
}

body[data-screen="running"] .ring-wrap,
body[data-screen="paused"] .ring-wrap {
  width: min(88%, 28rem, calc(100% - 2.8rem));
  max-height: calc(100% - 2.8rem);
}

body[data-screen="idle"] .controls,
body[data-screen="done"] .controls {
  display: flex;
  position: absolute;
  right: 0;
  bottom: 0;
  left: 50%;
  margin: 0;
  padding: 0 1.25rem max(0.85rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
}

body[data-screen="idle"] #start-btn,
body[data-screen="done"] #reset-btn {
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  body {
    transition: none;
  }

  .countdown.is-pulse {
    animation: none;
  }
}

@keyframes pulse {
  0% {
    transform: scale(1.08);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes ring-drain {
  to {
    stroke-dashoffset: 263.89;
  }
}
