:root {
  --ink: #1b2430;
  --ink-soft: #516074;
  --paper: #f7f3ea;
  --paper-2: #fffdf8;
  --line: rgba(27, 36, 48, 0.12);
  --coral: #e24b32;
  --sky: #6eb4ee;
  --good: #1e8a46;
  --shadow: 0 18px 50px rgba(22, 42, 72, 0.18);
  --sheet-w: 440px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--sky);
}

body {
  min-height: 100dvh;
  overflow: hidden;
  font-family: "Outfit", "Trebuchet MS", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, input { font-family: inherit; }

.world {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

#sky {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.topbar {
  position: fixed;
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: max(14px, env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
}

.topbar > * { pointer-events: auto; }

.chip {
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
  place-content: center;
  cursor: pointer;
}

.icon-btn i {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}

.icon-btn:focus-visible,
.btn:focus-visible,
.text-btn:focus-visible,
.close-btn:focus-visible,
.field input:focus-visible {
  outline: 3px solid #1b2430;
  outline-offset: 3px;
}

.hero {
  position: fixed;
  z-index: 2;
  top: clamp(72px, 12vh, 120px);
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

body:not(.is-home) .hero {
  opacity: 0;
}

.tag {
  margin: 0 0 8px;
  color: #f5fbff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: lowercase;
  text-shadow: 0 2px 0 rgba(24, 68, 120, 0.28);
}

.hero h1 {
  margin: 0;
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: clamp(52px, 13vw, 104px);
  font-weight: 700;
  line-height: 0.82;
  letter-spacing: -0.03em;
  color: #fffdf8;
  text-shadow: 4px 5px 0 #1d568f;
}

.hud[hidden],
.scrim[hidden],
.drawer[hidden] { display: none !important; }

.hud {
  position: fixed;
  z-index: 3;
  top: 64px;
  left: 16px;
  right: 16px;
  text-align: center;
  color: #fffdf8;
  text-shadow: 3px 3px 0 #1d568f;
  pointer-events: none;
}

.hud-kicker {
  margin: 0;
  font-family: "Pixelify Sans", "Courier New", monospace;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  font-size: 16px;
}

.hud-num {
  margin: 4px 0 0;
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: clamp(40px, 8vw, 64px);
  line-height: 0.9;
  font-weight: 700;
}

.hud-num small {
  margin-left: 6px;
  font-size: 0.38em;
}

.hud .text-btn {
  pointer-events: auto;
  margin-top: 8px;
  color: #fffdf8;
  text-shadow: 2px 2px 0 #1d568f;
}

.sheet {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(var(--sheet-w), calc(100% - 24px));
  max-height: min(460px, 48dvh);
  overflow: auto;
  scrollbar-width: thin;
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 22px 22px 18px;
  transition: transform 0.45s cubic-bezier(.2, .8, .2, 1), opacity 0.3s ease;
}

body.is-flying .sheet {
  transform: translate(-50%, 130%);
  opacity: 0;
  pointer-events: none;
}

.sheet.shake {
  animation: shake 0.36s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(-50%); }
  30% { transform: translateX(calc(-50% - 7px)); }
  65% { transform: translateX(calc(-50% + 6px)); }
}

.kicker {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.dots {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.dots i {
  width: 9px;
  height: 9px;
  background: #e6dece;
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.dots i.on { background: var(--ink); }
.dots i.now { background: var(--coral); }

.lede, .fine, .note, .said {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.45;
}

.lede + .lede { margin-top: 8px; }

.sheet h2.prompt {
  margin: 0 0 16px;
  font-size: clamp(22px, 4.6vw, 28px);
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.field {
  position: relative;
  display: block;
}

.field input {
  width: 100%;
  height: 58px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  font-weight: 650;
  padding: 0 118px 0 14px;
  font-variant-numeric: tabular-nums;
}

.field input::placeholder { color: #b7c0cb; font-weight: 500; }

.unit {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  max-width: 104px;
  text-align: right;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  pointer-events: none;
}

.err {
  min-height: 22px;
  margin: 6px 0 8px;
  color: var(--coral);
  font-size: 14px;
  font-weight: 600;
}

.btn {
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.btn svg { display: block; }

.btn:hover { background: #111821; }

.btn.secondary {
  margin-top: 8px;
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--ink);
}

.btn.secondary:hover { background: rgba(27, 36, 48, 0.05); }

.btn-row {
  display: grid;
  gap: 8px;
}

.fine { margin-top: 12px; font-size: 13px; }

.flew {
  margin: 4px 0 0;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.35;
}

.flew .big {
  display: block;
  margin: 2px 0 0;
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: clamp(52px, 12vw, 72px);
  line-height: 0.9;
  font-weight: 700;
  color: var(--coral);
  letter-spacing: -0.03em;
}

.band {
  margin: 10px 0 0;
  font-weight: 700;
}

.track {
  margin: 14px 0 4px;
  height: 10px;
  background: #efe7d8;
  border-radius: 0;
  box-shadow: inset 0 0 0 1.5px var(--ink);
  overflow: hidden;
}

.track span {
  display: block;
  height: 100%;
  background: var(--coral);
  width: 0%;
}

.scale {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.said { margin-top: 12px; }
.said strong { color: var(--ink); font-weight: 700; }
.note { margin-top: 8px; font-size: 14px; }

.total {
  margin: 0;
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: clamp(44px, 10vw, 60px);
  line-height: 0.9;
  color: var(--coral);
}

.total small {
  margin-left: 4px;
  font-size: 0.4em;
  color: var(--ink);
}

.throws {
  list-style: none;
  margin: 10px 0;
  padding: 0;
}

.throws li {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.throws li:first-child { border-top: 0; }

.row-cat { font-weight: 700; }

.row-bar {
  height: 8px;
  background: #efe7d8;
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.row-bar span {
  display: block;
  height: 100%;
  background: #1b2430;
}

.row-m { font-weight: 700; }

.practice-flag {
  display: inline-block;
  margin: 0 0 8px;
  padding: 3px 8px;
  background: #ffe7a3;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.text-btn, .close-btn {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.close-btn {
  width: 36px;
  height: 36px;
  font-size: 28px;
  line-height: 1;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: rgba(18, 32, 52, 0.38);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.scrim.show { opacity: 1; }

.drawer {
  position: fixed;
  z-index: 6;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(400px, 100%);
  background: var(--paper);
  border-left: 3px solid var(--ink);
  transform: translateX(104%);
  transition: transform 0.35s cubic-bezier(.2, .8, .2, 1);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}

.drawer.show { transform: none; }

.drawer-head {
  display: grid;
  grid-template-columns: 72px 1fr 36px;
  align-items: center;
  padding: 16px 16px 8px;
}

#drawer-back[hidden] {
  display: inline-flex !important;
  visibility: hidden;
}

.drawer-head h2 {
  margin: 0;
  text-align: center;
  font-size: 18px;
}

.drawer-body {
  padding: 8px 22px 28px;
  overflow: auto;
}

.menu-list { display: grid; gap: 8px; }

.menu-list button {
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  font-size: 18px;
  font-weight: 650;
  cursor: pointer;
  color: var(--ink);
}

.prose p { margin: 0 0 12px; line-height: 1.5; color: var(--ink); }
.prose .fine { color: var(--ink-soft); }

.log-day {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  cursor: pointer;
  color: inherit;
}

.log-day strong { display: block; font-size: 16px; }
.log-day span { color: var(--ink-soft); font-size: 13px; }

.log-detail {
  padding: 4px 0 12px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.45;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.noscript {
  position: fixed;
  z-index: 8;
  left: 16px;
  right: 16px;
  bottom: 16px;
  background: var(--paper);
  padding: 16px;
  border-radius: 16px;
}

@media (max-height: 640px) {
  .hero { top: 58px; }
  .hero h1 { font-size: 54px; }
  .tag { display: none; }
  .sheet { max-height: 58dvh; padding: 16px; }
  .hud { top: 64px; }
  .hud-num { font-size: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .hero, .scrim, .drawer { transition: none; }
  .sheet.shake { animation: none; }
}
