:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #65717f;
  --line: #d8dee6;
  --panel: #ffffff;
  --bg: #eef3f6;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-2: #b45309;
  --danger: #b91c1c;
  --shadow: 0 18px 44px rgba(23, 32, 42, .08);
  --shadow-strong: 0 24px 70px rgba(15, 23, 42, .16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(15, 118, 110, .13), transparent 28rem),
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::selection {
  background: rgba(15, 118, 110, .18);
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 48px;
  padding: 0 16px;
  touch-action: manipulation;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background-color .18s ease, color .18s ease;
  -webkit-tap-highlight-color: transparent;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(15, 118, 110, .12);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, .22);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 0 max(22px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 12px 0;
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
}

h2 {
  font-size: 24px;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
  font-weight: 700;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 8px;
}

.metric-strip div,
.unit-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .78);
  padding: 12px;
  backdrop-filter: blur(18px);
}

.metric-strip span {
  display: block;
  font-size: 22px;
  font-weight: 800;
}

.metric-strip small,
.unit-card span {
  color: var(--muted);
  display: block;
}

.panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .88);
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  animation: panel-in .32s ease both;
}

.mode-grid,
.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.options button {
  min-height: 76px;
  text-align: left;
  background: #fdfefe;
}

.game-head {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.game-head span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
}

#timer {
  background: var(--accent-2);
  color: #fff;
  font-weight: 800;
  min-width: 64px;
  text-align: center;
  box-shadow: 0 10px 24px rgba(180, 83, 9, .2);
}

#streak-live {
  text-align: right;
}

.hidden {
  display: none;
}

.install-button {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  min-width: 92px;
}

.install-button:hover:not(:disabled) {
  background: var(--accent-dark);
  color: #fff;
}

.offline-panel {
  margin-top: 12vh;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 760px) {
  body {
    background:
      radial-gradient(circle at 50% -12%, rgba(15, 118, 110, .16), transparent 22rem),
      linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
  }

  .app-shell {
    width: min(100% - 24px, 520px);
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .topbar,
  .panel {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar {
    align-items: stretch;
    gap: 12px;
  }

  h1 {
    font-size: 30px;
    line-height: 1.05;
  }

  h2 {
    font-size: 22px;
  }

  .metric-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-strip div {
    min-width: 0;
  }

  .metric-strip span {
    font-size: 20px;
  }

  .panel {
    gap: 18px;
    padding: 18px;
    box-shadow: var(--shadow-strong);
  }

  .mode-grid,
  .options {
    grid-template-columns: 1fr;
  }

  .game-head {
    grid-template-columns: 1fr 72px 1fr;
    gap: 8px;
  }

  .game-head span {
    min-height: 44px;
    padding: 9px 10px;
  }

  .options button {
    min-height: 64px;
  }
}
