:root {
  --paper: #f2eee5;
  --panel: #fbf9f4;
  --ink: #1e2a2e;
  --ink-soft: #3c464a;
  --muted: #6f6a60;
  --line: #e3dccd;
  --accent: #c8603f;
  --sage: #5f8168;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- boot ---------- */

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 100% at 50% 0%, #fbf8f1 0%, var(--paper) 55%, #e8e2d4 100%);
  z-index: 50;
}

.boot-inner {
  text-align: center;
  width: 280px;
}

.boot-mark {
  color: var(--accent);
  opacity: 0.9;
  margin-bottom: 6px;
}

.boot-title {
  font-family: var(--serif);
  font-size: 25px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.boot-note {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 18px;
}

.boot-bar {
  height: 2px;
  background: #e0d9c9;
  border-radius: 2px;
  overflow: hidden;
}

.boot-bar span {
  display: block;
  height: 100%;
  width: 40%;
  background: var(--accent);
  border-radius: 2px;
  animation: slide 1.35s cubic-bezier(0.6, 0, 0.4, 1) infinite;
}

@keyframes slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(300%);
  }
}

/* ---------- shell ---------- */

.app {
  display: flex;
  height: 100%;
}

.panel {
  width: 372px;
  flex: 0 0 372px;
  display: flex;
  flex-direction: column;
  padding: 24px 26px 18px;
  background: linear-gradient(180deg, #fdfbf6 0%, #f8f5ec 100%);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.level-nav {
  display: flex;
  gap: 5px;
}

.dot {
  width: 26px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  cursor: pointer;
  transition: all 0.18s ease;
  padding: 0;
}

.dot:hover:not(:disabled) {
  border-color: var(--ink);
  color: var(--ink);
}

.dot[aria-current="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fbf9f4;
}

.dot:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.dot.done::after {
  content: "";
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--sage);
  margin: 1px auto 0;
}

.dot[aria-current="true"].done::after {
  background: #b9d3bd;
}

/* ---------- brief ---------- */

.brief {
  margin-top: 30px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.chip::before {
  content: "";
  width: 16px;
  height: 1px;
  background: currentColor;
  opacity: 0.7;
}

h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 33px;
  line-height: 1.06;
  letter-spacing: -0.015em;
  margin: 13px 0 7px;
}

.subtitle {
  font-size: 13px;
  color: var(--accent);
  margin: 0 0 14px;
  letter-spacing: 0.01em;
}

.brief-text {
  font-size: 13.5px;
  line-height: 1.58;
  color: var(--ink-soft);
  margin: 0;
}

/* ---------- controls ---------- */

.controls {
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  gap: 19px;
}

.control-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 9px;
}

.control-label {
  font-size: 10.5px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
}

.control-value {
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: grab;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: #e2dbcb;
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid #fdfbf6;
  box-shadow: 0 1px 4px rgba(30, 42, 46, 0.28);
}

input[type="range"]::-moz-range-track {
  height: 3px;
  background: #e2dbcb;
  border-radius: 2px;
}

input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid #fdfbf6;
}

input[type="range"]:disabled {
  cursor: default;
  opacity: 0.45;
}

.segments {
  display: flex;
  gap: 6px;
}

.segment {
  flex: 1;
  padding: 9px 0;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.16s ease;
}

.segment:hover {
  border-color: #cfc6b4;
}

.segment[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fbf9f4;
}

/* ---------- actions ---------- */

.actions {
  margin-top: 26px;
}

.primary {
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: #fbf9f4;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 6px 14px -8px rgba(30, 42, 46, 0.55);
}

.primary:hover:not(:disabled) {
  background: #2c3b41;
  transform: translateY(-1px);
}

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

.primary:disabled {
  opacity: 0.38;
  cursor: default;
  box-shadow: none;
}

.primary.pulse {
  animation: press 1.6s ease-in-out infinite;
}

@keyframes press {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(200, 96, 63, 0.4);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(200, 96, 63, 0);
  }
}

.status {
  min-height: 36px;
  margin-top: 11px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

.status.bad {
  color: #a8402a;
}

.status.good {
  color: var(--sage);
}

/* ---------- hint ---------- */

.hint-wrap {
  margin-top: auto;
  padding-top: 20px;
}

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: #cdc4b2;
  text-underline-offset: 3px;
}

.link-btn:hover {
  color: var(--ink);
}

.hint {
  margin: 11px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: #4e585c;
  border-left: 2px solid var(--accent);
  padding-left: 11px;
}

.panel-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #a89f8f;
}

.foot-btn {
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #a89f8f;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: #d8cfbd;
  text-underline-offset: 3px;
}

.foot-btn:hover {
  color: var(--ink);
}

/* ---------- stage ---------- */

.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  background: var(--paper);
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 130px rgba(120, 100, 70, 0.13);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.readout {
  position: absolute;
  left: 20px;
  bottom: 20px;
  display: flex;
  gap: 20px;
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(251, 249, 244, 0.84);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.readout .item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.readout .k {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: #a09786;
}

.readout .v {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.badge {
  position: absolute;
  top: 20px;
  left: 20px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(31, 42, 46, 0.86);
  color: #f6f2e8;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(28, 38, 42, 0.3);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 0.25s ease;
}

.card {
  width: min(470px, 100%);
  padding: 30px 32px 26px;
  border-radius: 16px;
  border: 1px solid #e6dfd0;
  background: linear-gradient(180deg, #fffdf8, #f8f4ea);
  box-shadow: 0 30px 70px -30px rgba(30, 42, 46, 0.55), 0 2px 0 rgba(255, 255, 255, 0.8) inset;
  animation: rise 0.32s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
}

.card-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sage);
}

.card h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 27px;
  letter-spacing: -0.01em;
  margin: 10px 0 8px;
}

.card-detail {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 18px;
  font-family: var(--mono);
}

.card-note {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(125, 155, 130, 0.11);
  border: 1px solid rgba(125, 155, 130, 0.28);
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.card-actions .primary {
  flex: 1;
}

/* Only "Play again" is left on the final card, so it takes the full width. */
.card-actions.single .ghost {
  flex: 1;
}

.ghost {
  padding: 13px 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.ghost:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.foot-links {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

a.foot-btn {
  color: #a89f8f;
  text-decoration-color: #d8cfbd;
}

a.foot-btn:hover {
  color: var(--ink);
}

/* ---------- "want more" card ---------- */

.card-more {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 18px;
  padding: 15px 18px;
  border-radius: 10px;
  background: #1f2a2e;
  border: 1px solid #1f2a2e;
  color: #f7f3e7;
  text-decoration: none;
  box-shadow: 0 8px 20px -14px rgba(30, 42, 46, 0.7);
  transition: background 0.16s ease, transform 0.16s ease;
}

.card-more:hover {
  background: #2b3a3f;
  transform: translateY(-1px);
}

.card-more-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.card-more-label span {
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 400;
}

.card-more-note {
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  letter-spacing: 0.04em;
  color: #a4b0ab;
}

/* ---------- narrow ---------- */

@media (max-width: 860px) {
  .app {
    flex-direction: column-reverse;
  }

  .panel {
    width: 100%;
    flex: 0 0 auto;
    max-height: 54vh;
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 18px 20px 14px;
  }

  .brief {
    margin-top: 18px;
  }

  h1 {
    font-size: 27px;
  }

  .stage {
    min-height: 46vh;
  }

  .hint-wrap {
    margin-top: 14px;
  }

  .readout {
    left: 12px;
    bottom: 12px;
    gap: 14px;
    padding: 8px 12px;
  }
}
