:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #111111;
  --ink-soft: rgba(17, 17, 17, 0.74);
  --ink-muted: #6f6f6f;
  --signal: #de2c23;
  --signal-dark: #b71f17;
  --accept: #199a4a;
  --accept-dark: #12773a;
  --reroll: #f18a12;
  --reroll-dark: #d96e00;
  --timer-track: rgba(17, 17, 17, 0.14);
  --timer-core-ring: rgba(17, 17, 17, 0.08);
  --display-font-family: "Climate Crisis", "Arial Black", sans-serif;
  --display-font-weight: 400;
  --shadow: 0 18px 36px rgba(17, 17, 17, 0.18);
  --content-inset: 6px;
  --title-pad-top: 4px;
  --title-pad-bottom: 0px;
  --header-gap: 6px;
  --header-action-size: 32px;
  --header-action-shadow: 0 8px 14px rgba(183, 31, 23, 0.18);
  --title-band-height: 40px;
  --score-height: 78px;
  --score-gap: 4px;
  --controls-clearance: 0px;
  --quest-fab-clearance: 0px;
  --location-footer-clearance: 0px;
  --draft-keyboard-clearance: 0px;
  --controls-keyboard-offset: 0px;
  --timeline-content-offset: 0px;
  --desktop-max-width: 800px;
  --stack-header-height:
    calc(
      env(safe-area-inset-top) + var(--title-pad-top) + var(--title-band-height) +
        var(--title-pad-bottom)
    );
  --score-top: calc(var(--stack-header-height) + var(--score-gap));
  --stack-scroll-margin: calc(var(--score-top) + var(--score-height) + 24px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #000000;
  --ink: #fff8f4;
  --ink-soft: rgba(255, 248, 244, 0.72);
  --ink-muted: rgba(255, 248, 244, 0.42);
  --signal: #ff584c;
  --signal-dark: #d02d25;
  --accept: #29c564;
  --accept-dark: #14934a;
  --reroll: #ff9d2e;
  --reroll-dark: #dd7708;
  --timer-track: rgba(255, 248, 244, 0.2);
  --timer-core-ring: rgba(255, 248, 244, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow-x: hidden;
  overflow-y: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  font-family: var(--display-font-family);
  font-weight: var(--display-font-weight);
  color: var(--ink);
  background: var(--paper);
}

button {
  font: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.fit-text {
  display: block;
  width: 100%;
}

.fit-text-inner {
  display: inline-block;
  white-space: nowrap;
}

.fit-text[data-fit-ready="true"] {
  position: relative;
  overflow: hidden;
}

.fit-text[data-fit-ready="true"] .fit-text-inner {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: left top;
}

.stack-copy {
  margin: 0;
  font-weight: var(--display-font-weight);
  line-height: 0.9;
  letter-spacing: 0;
  text-transform: uppercase;
}

.stack-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 40;
  padding:
    calc(env(safe-area-inset-top) + var(--title-pad-top))
    var(--content-inset)
    var(--title-pad-bottom);
  background: var(--paper);
  pointer-events: none;
}

.stack-title {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--title-band-height);
  padding-left: 0;
  padding-right: calc(var(--header-action-size) + var(--header-gap));
  min-width: 0;
  text-align: center;
}

.stack-copy-title {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--signal);
  line-height: 1;
  letter-spacing: -0.04em;
  text-align: center;
}

.header-action {
  pointer-events: auto;
  position: absolute;
  top: calc(
    env(safe-area-inset-top) + var(--title-pad-top) +
      (var(--title-band-height) - var(--header-action-size)) / 2
  );
  right: var(--content-inset);
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--header-action-size);
  height: var(--header-action-size);
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  color: #fffaf7;
  background: linear-gradient(180deg, var(--signal) 0%, var(--signal-dark) 100%);
  box-shadow: var(--header-action-shadow);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.header-action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Avenir Next", "Segoe UI Symbol", "Helvetica Neue", sans-serif;
  font-size: calc(var(--header-action-size) * 0.54);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.header-action-icon svg {
  display: block;
  width: calc(var(--header-action-size) * 0.5);
  height: calc(var(--header-action-size) * 0.5);
}

.header-action:disabled {
  opacity: 0.34;
  box-shadow: none;
}

.header-action:not(:disabled):active {
  transform: scale(0.96);
}

.is-library-view .header-action {
  left: var(--content-inset);
  right: auto;
}

.is-library-view .stack-title {
  padding-left: calc(var(--header-action-size) + var(--header-gap));
  padding-right: 0;
}

.score-wrap {
  position: fixed;
  top: var(--score-top);
  left: 50%;
  z-index: 55;
  width: min(176px, calc(100vw - 132px));
  transform: translateX(-50%);
}

.score-wrap.is-hidden,
.is-library-view .score-wrap {
  display: none;
}

.score-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--score-height);
  padding: 12px 18px 10px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 10px;
  color: #fff8f4;
  background: linear-gradient(180deg, var(--signal) 0%, var(--signal-dark) 100%);
  box-shadow: 0 14px 28px rgba(183, 31, 23, 0.28);
}

.stack-copy-score {
  line-height: 0.92;
  text-align: center;
}

.timeline-view {
  height: 100%;
  padding:
    var(--stack-header-height)
    var(--content-inset)
    calc(
      var(--controls-clearance) + var(--quest-fab-clearance) +
        var(--location-footer-clearance) + env(safe-area-inset-bottom) +
        var(--draft-keyboard-clearance)
    )
    var(--content-inset);
  overflow-x: hidden;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.quest-stack {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding-top: var(--timeline-content-offset);
}

.stack-row {
  position: relative;
  width: 100%;
  scroll-margin-top: var(--stack-scroll-margin);
}

.stack-row-date {
  margin-top: 0;
  padding: 10px 0;
}

.stack-row-event {
  padding: 0;
}

.stack-row-event + .stack-row-event {
  margin-top: 1px;
}

.timeline-welcome {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  padding-top: 10px;
}

.timeline-welcome-line {
  width: 100%;
  color: var(--ink);
}

.timeline-welcome-line-prompt {
  margin-top: 8px;
}

.timeline-welcome-cta {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  margin-top: 8px;
}

.timeline-welcome-cta-library {
  margin-top: 12px;
}

.timeline-welcome-cta-copy {
  flex: 1 1 0;
  min-width: 0;
}

.timeline-welcome-cta-copy-start {
  flex-grow: 5;
}

.timeline-welcome-cta-copy-end {
  flex-grow: 12;
}

.timeline-welcome .timeline-welcome-button {
  position: static;
  left: auto;
  top: auto;
  right: auto;
  bottom: auto;
  z-index: auto;
  flex: 0 0 auto;
  align-self: center;
  width: 64px;
  height: 64px;
  margin: 0;
  transform: none;
}

.timeline-welcome .timeline-welcome-button:active {
  transform: scale(0.96);
}

.timeline-welcome .timeline-welcome-button .quest-action-icon svg {
  width: 1.75rem;
  height: 1.75rem;
}

.timeline-welcome .timeline-welcome-menu-button {
  position: static;
  left: auto;
  top: auto;
  right: auto;
  bottom: auto;
  z-index: auto;
  flex: 0 0 auto;
  align-self: center;
  width: 52px;
  height: 52px;
  min-width: 52px;
  min-height: 52px;
  margin: 0;
  transform: none;
}

.timeline-welcome .timeline-welcome-menu-button:active {
  transform: scale(0.96);
}

.timeline-welcome .timeline-welcome-menu-button .header-action-icon svg {
  width: 1.3rem;
  height: 1.3rem;
}

.stack-row-pending {
  padding: 0;
  scroll-margin-bottom: var(--controls-clearance);
}

.stack-row-library {
  cursor: pointer;
}

.stack-copy-date {
  color: var(--signal);
  opacity: 1;
}

.stack-copy-event {
  color: var(--ink);
}

.stack-row-pending .stack-copy-event {
  color: var(--accept);
}

body[data-view="timer"] .stack-header,
body[data-view="timer"] .score-wrap {
  display: none;
}

body[data-view="timer"] .timeline-view {
  padding: 0;
  overflow: hidden;
}

body[data-view="timer"] .quest-stack {
  height: 100%;
  min-height: 100%;
  padding-top: 0;
}

.timer-screen {
  position: relative;
  display: grid;
  flex: 1 1 auto;
  place-items: center;
  height: 100%;
  min-height: 100%;
  padding:
    calc(env(safe-area-inset-top) + 18px)
    var(--content-inset)
    calc(env(safe-area-inset-bottom) + 18px);
}

.timer-circle {
  --timer-progress: 0deg;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(78vmin, 420px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: conic-gradient(var(--accept) var(--timer-progress), var(--timer-track) 0deg);
  box-shadow: var(--shadow);
  cursor: pointer;
  overflow: hidden;
}

.timer-circle::before {
  content: "";
  position: absolute;
  inset: 24px;
  border-radius: inherit;
  background: var(--paper);
  box-shadow: inset 0 0 0 2px var(--timer-core-ring);
}

.timer-circle[aria-disabled="true"] {
  cursor: default;
}

.timer-circle:active {
  transform: scale(0.985);
}

.timer-circle[aria-disabled="true"]:active {
  transform: none;
}

.timer-circle-label {
  position: relative;
  z-index: 1;
  display: block;
  max-width: calc(100% - 72px);
  color: var(--signal);
  font-family: var(--display-font-family);
  font-size: 2.9rem;
  font-weight: var(--display-font-weight);
  line-height: 0.9;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.timer-circle[data-timer-phase="countdown"] .timer-circle-label {
  font-size: 5.5rem;
}

.timer-circle[data-timer-phase="running"] .timer-circle-label {
  color: var(--ink);
  font-size: 4.9rem;
}

.timer-circle[data-timer-phase="done"] .timer-circle-label {
  color: var(--accept);
}

.timer-wake-lock-button {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  transform: translateX(-50%);
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  color: var(--signal);
  background: transparent;
  font-family: var(--display-font-family);
  font-size: 0.78rem;
  font-weight: var(--display-font-weight);
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}

.timer-wake-lock-button.is-hidden {
  display: none;
}

.timer-wake-lock-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.timer-wake-lock-button:not(:disabled):active {
  transform: translateX(-50%) scale(0.96);
}

.stack-row-event.is-bonus .stack-copy-event {
  color: var(--ink-soft);
}

.stack-row-event.is-reroll .stack-copy-event {
  color: var(--reroll-dark);
}

.stack-row-event.is-reject .stack-copy-event {
  color: var(--signal-dark);
}

.stack-row-library.is-selected .stack-copy-event {
  color: var(--accept);
}

.stack-row-library.is-inactive:not(.is-selected) .stack-copy-event {
  color: var(--ink-muted);
}

.stack-row-settings {
  cursor: pointer;
}

.stack-row-settings.is-selected .stack-copy-event {
  color: var(--accept);
}

.settings-row-button {
  display: block;
  width: 100%;
  padding: 6px 0 2px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease;
}

.settings-row-button:active {
  transform: scale(0.985);
}

.stack-row-font-option .stack-copy {
  text-transform: none;
  letter-spacing: -0.02em;
}

.fresh-entry .stack-copy-event {
  animation: stack-pulse 720ms ease;
}

@keyframes stack-pulse {
  0% {
    color: var(--signal-dark);
    opacity: 0.28;
  }
  45% {
    color: var(--signal);
    opacity: 1;
  }
  100% {
    color: var(--ink);
    opacity: 1;
  }
}

.quest-fab {
  position: fixed;
  left: 50%;
  bottom: calc(40px + env(safe-area-inset-bottom) + var(--controls-keyboard-offset));
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  color: #fffaf7;
  background: linear-gradient(180deg, var(--signal) 0%, var(--signal-dark) 100%);
  transform: translateX(-50%);
  box-shadow: 0 18px 30px rgba(183, 31, 23, 0.3);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.quest-fab span {
  display: block;
  font-size: 2.65rem;
  line-height: 1;
  transform: translateY(-2px);
}

.quest-fab:active {
  transform: translateX(-50%) scale(0.96);
}

.quest-fab.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) scale(0.72);
}

.quest-controls {
  position: fixed;
  left: 50%;
  bottom: calc(34px + env(safe-area-inset-bottom) + var(--controls-keyboard-offset));
  z-index: 70;
  display: flex;
  justify-content: center;
  gap: 8px;
  transform: translateX(-50%) translateY(12px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.quest-controls.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0) scale(1);
}

.quest-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 70px;
  height: 70px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.96);
  border-radius: 999px;
  color: #fffdfa;
  box-shadow: 0 18px 28px rgba(17, 17, 17, 0.16);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.quest-action span {
  display: block;
  font-family: "Avenir Next", "Segoe UI Symbol", "Helvetica Neue", sans-serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.quest-action-accept {
  background: linear-gradient(180deg, var(--accept) 0%, var(--accept-dark) 100%);
}

.quest-action-reroll {
  background: linear-gradient(180deg, var(--reroll) 0%, var(--reroll-dark) 100%);
}

.quest-action-edit {
  background: linear-gradient(180deg, var(--reroll) 0%, var(--reroll-dark) 100%);
}

.quest-action-toggle {
  background: linear-gradient(180deg, var(--accept) 0%, var(--accept-dark) 100%);
}

.quest-action-toggle.is-inactive {
  background: linear-gradient(180deg, #2c2c2c 0%, #111111 100%);
}

.quest-action-toggle span {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.quest-action-delete {
  background: linear-gradient(180deg, #2c2c2c 0%, #111111 100%);
}

.quest-action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.quest-action-icon svg {
  display: block;
  width: 1.6rem;
  height: 1.6rem;
  overflow: visible;
}

.quest-action-reject {
  background: linear-gradient(180deg, var(--signal) 0%, var(--signal-dark) 100%);
}

.quest-action:disabled {
  opacity: 0.42;
  box-shadow: none;
}

.quest-action.is-hidden {
  display: none;
}

.quest-action:not(:disabled):active {
  transform: scale(0.96);
}

.quest-reel {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.quest-reel-track {
  display: inline-flex;
  align-items: center;
  height: 100%;
  gap: 28px;
  will-change: transform;
}

.quest-reel-item {
  display: flex;
  align-items: center;
  height: 100%;
  flex: 0 0 auto;
  font-size: var(--reel-font-size, clamp(3rem, 14vw, 7rem));
  line-height: 0.88;
  color: var(--accept);
  text-transform: uppercase;
  white-space: nowrap;
}

.quest-editor-shell {
  display: block;
  width: 100%;
}

.editor-form {
  display: block;
  width: 100%;
  padding-top: 10px;
}

.stack-row-editor {
  padding: 8px 0 4px;
}

.editor-label {
  margin-bottom: 2px;
  color: var(--signal);
}

.editor-section-label {
  margin: 14px 0 8px;
}

.editor-help {
  margin: 14px 0 8px;
  color: var(--ink-muted);
}

.stack-row-equipment {
  cursor: pointer;
}

.equipment-picker {
  display: block;
  width: 100%;
}

.equipment-suggestions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  max-height: 0;
  margin-top: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.equipment-picker:focus-within .equipment-suggestions {
  max-height: min(42vh, 320px);
  margin-top: 10px;
  opacity: 1;
  pointer-events: auto;
}

.equipment-suggestion {
  display: block;
  width: 100%;
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  text-align: left;
  cursor: pointer;
}

.equipment-suggestion .stack-copy-event {
  color: var(--ink-muted);
}

.equipment-suggestion:active {
  transform: scale(0.985);
}

.quest-editor-input {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--accept);
  caret-color: var(--accept);
  font-family: var(--display-font-family);
  font-weight: var(--display-font-weight);
  line-height: 0.9;
  letter-spacing: 0;
  text-transform: uppercase;
}

.quest-editor-input::placeholder {
  color: var(--accept);
  opacity: 1;
}

.quest-editor-input::selection {
  color: #fffaf7;
  background: rgba(25, 154, 74, 0.92);
}

.feedback {
  position: fixed;
  left: 50%;
  top: calc(var(--score-top) - 14px);
  z-index: 65;
  min-width: 0;
  max-width: min(42vw, 120px);
  padding: 8px 12px;
  border-radius: 999px;
  transform: translate(-50%, 10px) scale(0.9);
  text-align: center;
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  color: #fffaf7;
  background: rgba(17, 17, 17, 0.92);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 180ms ease;
}

.feedback.is-visible {
  opacity: 1;
  transform: translate(-50%, -6px) scale(1);
}

body[data-view="library"] .feedback {
  opacity: 0;
  pointer-events: none;
}

.location-picker {
  position: fixed;
  inset: auto 0 0;
  z-index: 68;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(38px + env(safe-area-inset-bottom));
  padding: 4px var(--content-inset) calc(4px + env(safe-area-inset-bottom));
  color: var(--signal);
  background: var(--paper);
  transform: translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 180ms ease;
}

.location-picker.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.location-picker-button {
  display: block;
  width: min(100%, var(--desktop-max-width));
  min-height: 30px;
  padding: 4px 10px;
  border: 0;
  border-radius: 0;
  color: var(--signal);
  background: transparent;
  font-family: var(--display-font-family);
  font-size: 1rem;
  font-weight: var(--display-font-weight);
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  text-align: center;
  overflow: hidden;
}

.location-picker-button:disabled {
  opacity: 1;
}

.location-picker-viewport {
  position: relative;
  display: block;
  width: 100%;
  height: 1.1em;
  overflow: hidden;
}

.location-picker-label {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location-picker-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location-picker-slide-current {
  animation: location-slide-current 260ms ease forwards;
}

.location-picker-slide-next {
  transform: translateX(100%);
  animation: location-slide-next 260ms ease forwards;
}

@keyframes location-slide-current {
  to {
    transform: translateX(-100%);
  }
}

@keyframes location-slide-next {
  to {
    transform: translateX(0);
  }
}

@media (min-width: 700px) {
  :root {
    --content-inset: 10px;
    --title-pad-top: 10px;
    --title-pad-bottom: 6px;
    --header-gap: 12px;
    --score-gap: 20px;
    --header-action-shadow: 0 14px 24px rgba(183, 31, 23, 0.24);
  }

  .timeline-view {
    padding-left: var(--content-inset);
    padding-right: var(--content-inset);
  }

  .score-wrap {
    width: 188px;
  }

  .quest-reel-item {
    font-size: var(--reel-font-size, clamp(3.4rem, 10vw, 7.4rem));
  }
}

@media (min-width: 800px) {
  .stack-header {
    left: 50%;
    right: auto;
    width: min(100%, var(--desktop-max-width));
    transform: translateX(-50%);
  }

  .timeline-view {
    width: min(100%, var(--desktop-max-width));
    margin-inline: auto;
  }
}
