:root {
  --ink: #f2efe7;
  --muted: #8b8984;
  --bg: #0b0b0d;
  --panel: #111114;
  --line: rgba(255, 255, 255, 0.12);
  --green: #b6f23b;
  --green-rgb: 182, 242, 59;
  --red: #ff4b3e;
  --red-rgb: 255, 75, 62;
  --yellow: #ffd447;
  --yellow-rgb: 255, 212, 71;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Space Grotesk", sans-serif;
}

.site-info {
  position: relative;
  padding: 80px 24px;
  border-top: 1px solid var(--line);
  background: #0e0e11;
}

.site-info-inner {
  width: min(980px, 100%);
  margin: 0 auto;
}

.info-kicker {
  margin: 0 0 14px;
  color: var(--green);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
}

.site-info h2 {
  max-width: 760px;
  margin: 0 0 20px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1;
  letter-spacing: -0.055em;
}

.site-info-inner > p:not(.info-kicker, .responsibility-note) {
  max-width: 720px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 42px;
}

.info-grid article {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.018);
}

.info-grid h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.info-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.responsibility-note {
  margin: 30px 0 0;
  color: #777570;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  line-height: 1.6;
  letter-spacing: 0.06em;
}

button,
input,
select {
  font: inherit;
}

button,
input,
select,
a {
  -webkit-tap-highlight-color: transparent;
}

.app {
  --breathing-speed: 1.8s;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(circle at 50% 43%, rgba(255, 255, 255, 0.025), transparent 34%),
    linear-gradient(115deg, transparent 49.8%, rgba(255, 255, 255, 0.018) 50%, transparent 50.2%),
    var(--bg);
  transition: background-color 650ms ease;
}

.app::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

.topbar,
.footer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 38px;
}

.topbar {
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 50%;
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--green);
  inset: 5px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #696966;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.settings-button,
.close-button {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.settings-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
}

.settings-button:hover,
.close-button:hover {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.04);
}

.settings-button svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.game {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 24px;
  text-align: center;
}

.signal {
  width: 86.4px;
  height: 86.4px;
  display: grid;
  place-items: center;
  position: relative;
  margin-bottom: 42px;
}

.signal-glow,
.signal-core {
  position: absolute;
  border-radius: 50%;
}

.signal-glow {
  inset: 0;
  background: rgba(255, 255, 255, 0.05);
  transform: scale(0.7);
  opacity: 0;
  transition: all 650ms ease;
}

.signal-core {
  width: 26.4px;
  height: 26.4px;
  background: #343437;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: all 450ms ease;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 13.2px;
  font-weight: 700;
  letter-spacing: 0.24em;
  transition: color 450ms ease;
}

h1 {
  max-width: 980px;
  margin: 0;
  font-size: clamp(48.6px, 7.2vw, 104.4px);
  line-height: 0.92;
  letter-spacing: -0.07em;
  text-wrap: balance;
}

.app.hide-main-text #prompt,
#prompt[hidden] {
  display: none;
}

.app.hide-main-text .round-progress {
  margin-top: 0;
}

.subtext {
  min-height: 24px;
  margin: 18px 0 38px;
  color: var(--muted);
  font-size: 16px;
}

.round-progress {
  width: min(360px, 72vw);
  height: 4px;
  margin-top: 28px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  opacity: 0;
  transition: opacity 250ms ease;
}

.round-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--muted);
  box-shadow: 0 0 12px currentColor;
}

.app[data-mode="green"] .round-progress,
.app[data-mode="red"] .round-progress,
.app[data-mode="event"] .round-progress {
  opacity: 1;
}

.app[data-mode="green"] .round-progress-fill {
  color: var(--green);
  background: var(--green);
}

.app[data-mode="red"] .round-progress-fill {
  color: var(--red);
  background: var(--red);
}

.app[data-mode="event"] .round-progress-fill {
  color: var(--yellow);
  background: var(--yellow);
}

.start-button {
  min-width: 230px;
  border: 0;
  border-radius: 999px;
  padding: 18px 22px 18px 28px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  color: #10120c;
  background: var(--green);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.09em;
  box-shadow: 0 0 0 0 rgba(var(--green-rgb), 0.3);
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.start-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.start-settings-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 67px;
  height: 67px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition: transform 180ms ease, color 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.start-settings-button:hover {
  transform: translateY(-3px);
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.05);
}

.start-settings-button svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.start-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 38px rgba(var(--green-rgb), 0.16);
}

.start-button:active {
  transform: translateY(0);
}

.button-icon {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
  font-size: 18px;
}

.session-controls {
  display: none;
  align-items: center;
  gap: 18px;
  margin-top: 8px;
}

.text-button {
  border: 0;
  padding: 10px 4px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.13em;
}

.text-button:hover {
  color: var(--ink);
}

.text-button.danger:hover {
  color: var(--red);
}

.control-divider {
  width: 1px;
  height: 13px;
  background: var(--line);
}

.footer {
  justify-content: center;
  border-top: 1px solid var(--line);
  color: #6f6e6a;
  font-family: "DM Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
}

.footer p {
  margin: 0;
}

.settings-modal {
  width: min(860px, calc(100% - 32px));
  max-height: calc(100svh - 32px);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  color: var(--ink);
  background: #111114;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.65);
}

.settings-modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
}

.settings-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100svh - 34px);
}

.settings-header,
.settings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 26px;
}

.settings-header {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
}

.settings-kicker {
  margin: 0 0 5px;
  color: var(--green);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.2em;
}

.settings-header h2 {
  margin: 0;
  font-size: 27px;
  letter-spacing: -0.04em;
}

.close-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}

.settings-body {
  padding: 8px 26px;
  overflow-y: auto;
}

.settings-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 30px;
  align-items: center;
  padding: 26px 0;
}

.settings-section + .settings-section {
  border-top: 1px solid var(--line);
}

.setting-copy h3 {
  margin: 0 0 7px;
  font-size: 16px;
}

.setting-copy p {
  max-width: 290px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.setting-copy .setting-disclaimer {
  margin-top: 8px;
  color: var(--yellow);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.interval-control {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.duration-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(230px, 1fr));
  gap: 14px;
  align-items: end;
}

.duration-section,
.objective-settings,
.event-settings {
  grid-template-columns: 1fr;
  gap: 20px;
}

.duration-section .setting-copy p,
.objective-settings .setting-copy p,
.event-settings .setting-copy p {
  max-width: none;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
}

.difficulty-control,
.standalone-select,
.color-interval {
  margin: 0;
}

.difficulty-control,
.standalone-select,
.section-select {
  display: grid;
  grid-template-columns: 1fr 150px;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
}

.difficulty-control select,
.standalone-select select,
.section-select select,
.frequency-control select {
  width: 100%;
  padding: 11px 34px 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #19191c;
  outline: none;
  cursor: pointer;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.difficulty-control select:focus,
.standalone-select select:focus,
.section-select select:focus,
.frequency-control select:focus {
  border-color: rgba(var(--green-rgb), 0.7);
}

.color-interval {
  padding: 13px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.color-interval legend {
  padding: 0 7px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
}

.color-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
}

.green-interval .color-dot {
  background: var(--green);
}

.red-interval .color-dot {
  background: var(--red);
}

.interval-control label {
  display: grid;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
}

.number-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  transition: border-color 180ms ease, background-color 180ms ease;
}

.number-field:focus-within {
  border-color: rgba(var(--green-rgb), 0.7);
  background: rgba(var(--green-rgb), 0.04);
}

.number-field input {
  width: 44px;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  outline: none;
  font-family: "DM Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  text-align: right;
  -moz-appearance: textfield;
}

.number-field input::-webkit-inner-spin-button,
.number-field input::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.number-field span,
.range-dash {
  color: #575753;
}

.toggle-list {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.event-settings .toggle-list:has(.toggle-row:only-child) {
  grid-template-columns: 1fr;
}

.objective-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.objective-row {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.objective-row strong,
.objective-row small {
  display: block;
}

.objective-row strong {
  font-size: 13px;
}

.objective-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.endless-objective {
  align-items: flex-start;
}

.objective-badge {
  flex: 0 0 auto;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
}

.objective-controls {
  flex: 0 0 auto;
  display: grid;
  justify-items: end;
  gap: 10px;
}

.possibility-control {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
}

.possibility-control select {
  width: 90px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #19191c;
  outline: none;
  font-family: "DM Mono", monospace;
  font-size: 9px;
}

.possibility-control select:disabled {
  opacity: 0.4;
}

.frequency-control {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}

.display-toggle-row {
  min-width: 280px;
}

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row strong {
  font-size: 13px;
}

.toggle-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.toggle {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 22px;
}

.toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: #29292d;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #858580;
  transition: transform 180ms ease, background-color 180ms ease;
}

.toggle input:checked + .toggle-track {
  border-color: var(--green);
  background: rgba(var(--green-rgb), 0.22);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(16px);
  background: var(--green);
}

.toggle input:focus-visible + .toggle-track {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.range-dash {
  align-self: end;
  padding-bottom: 8px;
}

.settings-footer {
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
}

.modal-button {
  padding: 12px 17px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
}

.modal-button.secondary {
  color: var(--muted);
  background: transparent;
}

.modal-button.primary {
  border-color: var(--green);
  color: #10120c;
  background: var(--green);
}

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

.app[data-mode="green"] .signal-glow {
  background: rgba(var(--green-rgb), 0.18);
  transform: scale(1);
  opacity: 1;
  animation: breathe var(--breathing-speed) ease-in-out infinite;
}

.app[data-mode="green"] .signal-core {
  background: var(--green);
  box-shadow: 0 0 22px rgba(var(--green-rgb), 0.8);
}

.app[data-mode="green"] .eyebrow {
  color: var(--green);
}

.app[data-mode="red"] .signal-glow {
  background: rgba(var(--red-rgb), 0.17);
  transform: scale(1);
  opacity: 1;
}

.app[data-mode="red"] .signal-core {
  background: var(--red);
  box-shadow: 0 0 22px rgba(var(--red-rgb), 0.75);
}

.app[data-mode="red"] .eyebrow {
  color: var(--red);
}

.app[data-mode="event"] {
  background:
    radial-gradient(circle at 50% 43%, rgba(var(--yellow-rgb), 0.18), transparent 42%),
    linear-gradient(115deg, transparent 49.8%, rgba(var(--yellow-rgb), 0.05) 50%, transparent 50.2%),
    #181407;
}

.app[data-mode="event"] .signal-glow {
  background: rgba(var(--yellow-rgb), 0.2);
  transform: scale(1);
  opacity: 1;
  animation: breathe var(--breathing-speed) ease-in-out infinite;
}

.app[data-mode="event"] .signal-core {
  background: var(--yellow);
  box-shadow: 0 0 24px rgba(var(--yellow-rgb), 0.8);
}

.app[data-mode="event"] .eyebrow {
  color: var(--yellow);
}

.app[data-mode="running"] .start-button,
.app[data-mode="green"] .start-button,
.app[data-mode="red"] .start-button,
.app[data-mode="event"] .start-button,
.app[data-mode="paused"] .start-button {
  display: none;
}

.app[data-mode="running"] .start-actions,
.app[data-mode="green"] .start-actions,
.app[data-mode="red"] .start-actions,
.app[data-mode="event"] .start-actions,
.app[data-mode="paused"] .start-actions {
  display: none;
}

.app[data-mode="green"] .session-controls,
.app[data-mode="red"] .session-controls,
.app[data-mode="event"] .session-controls,
.app[data-mode="paused"] .session-controls {
  display: flex;
}

.app[data-mode="paused"] .signal-core {
  background: #e3b341;
  box-shadow: 0 0 22px rgba(227, 179, 65, 0.45);
}

.app[data-mode="paused"] .eyebrow {
  color: #e3b341;
}

@keyframes breathe {
  0%, 100% { transform: scale(0.9); opacity: 0.65; }
  50% { transform: scale(1.15); opacity: 1; }
}

@media (max-width: 680px) {
  .topbar,
  .footer {
    padding: 22px 20px;
  }

  .game {
    padding: 50px 20px;
  }

  .signal {
    margin-bottom: 32px;
  }

  h1 {
    font-size: clamp(43.2px, 14.4vw, 68.4px);
  }

  .footer p:last-child {
    display: none;
  }

  .settings-section {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .duration-settings {
    grid-template-columns: 1fr;
  }

  .section-heading-row {
    flex-direction: column;
    align-items: stretch;
  }

  .section-select {
    grid-template-columns: 1fr 150px;
    align-items: center;
  }

  .toggle-list {
    grid-template-columns: 1fr;
  }

  .objective-list {
    grid-template-columns: 1fr;
  }

  .interval-control {
    justify-content: flex-start;
  }

  .toggle-list {
    width: 100%;
  }

  .site-info {
    padding: 58px 20px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }
}

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