:root {
  color-scheme: light;
  --ink: #2c2c2c;
  --muted: #6d6f70;
  --paper: #ffffff;
  --panel: #ffffff;
  --line: #d3d3d3;
  --red: #ed6767;
  --orange: #eeb75f;
  --yellow: #eceb67;
  --green: #289a48;
  --blue: #adaed7;
  --violet: #713c97;
  --trust: #289a48;
  --shadow: 0 18px 52px rgba(44, 44, 44, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Poppins, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 241, 241, 0.98)),
    repeating-linear-gradient(90deg, rgba(237, 103, 103, 0.04) 0 1px, transparent 1px 76px);
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

.topbar,
.game-shell {
  width: min(1220px, calc(100% - 28px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 0;
}

.back-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  text-decoration: none;
  font-weight: 800;
}

.title-lockup {
  display: grid;
  grid-template-columns: 42px auto;
  column-gap: 10px;
  align-items: center;
  text-align: right;
}

.title-lockup span,
.title-lockup small {
  display: block;
  grid-column: 2;
}

.title-lockup img {
  grid-row: 1 / span 2;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 8px 20px rgba(44, 44, 44, 0.14);
}

.title-lockup span {
  font-weight: 900;
}

.title-lockup small {
  color: var(--muted);
}

.partner-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 22px rgba(44, 44, 44, 0.08);
}

.partner-lockup span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.partner-lockup img {
  display: block;
  width: auto;
  max-width: 128px;
  height: 34px;
  object-fit: contain;
}

.intro-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
  gap: 40px;
  align-items: start;
  padding: 48px 0 64px;
}

.intro-copy h1 {
  font-size: clamp(1.9rem, 3.8vw, 3rem);
  margin: 8px 0 12px;
}

.intro-sub {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
  margin: 0 0 16px;
  max-width: 480px;
}

.preview-badge {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--muted);
  background: rgba(255,255,255,0.8);
  margin: 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p,
li {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(2.35rem, 7vw, 5.2rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.intro-panel p:not(.eyebrow):not(.preview-badge) {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.preview-note {
  max-width: 720px;
  padding: 12px 14px;
  border-left: 5px solid var(--red);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.origin-card {
  display: grid;
  gap: 12px;
  max-width: 620px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 32px rgba(44, 44, 44, 0.1);
}

.origin-card span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
  text-transform: uppercase;
}

.origin-card div {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.origin-card img {
  display: block;
  width: auto;
  max-width: min(220px, 100%);
  height: 56px;
  object-fit: contain;
}

.town-form,
.panel-card,
.resource-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 36px rgba(23, 33, 38, 0.1);
}

.town-form {
  padding: 20px;
}

.town-form-mark {
  display: none;
}

.town-form label {
  display: block;
  margin-bottom: 9px;
  font-weight: 900;
}

.town-row {
  display: flex;
  gap: 10px;
}

.town-row input {
  min-width: 0;
  flex: 1;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.town-row button,
.primary-button,
.secondary-button,
.choice-grid button {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.town-row button:hover,
.town-row button:focus-visible,
.primary-button:hover,
.primary-button:focus-visible,
.secondary-button:hover,
.secondary-button:focus-visible,
.choice-grid button:hover,
.choice-grid button:focus-visible,
.back-link:hover,
.back-link:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(23, 33, 38, 0.16);
}

.form-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.town-seed-preview {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.play-panel {
  padding-bottom: 32px;
}

.hud {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(44,44,44,0.06);
}

.hud-title {
  flex: 1;
  min-width: 0;
}

.hud h1 {
  font-size: 1.15rem;
  font-family: Poppins, sans-serif;
  font-weight: 900;
  margin: 0;
  line-height: 1.2;
}

.chapter-copy {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.year-title-badge {
  margin: 2px 0 0;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--ink);
}

.town-seed-badge {
  margin: 4px 0 0;
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


.resource-grid {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.resource-card {
  min-height: 0;
  padding: 6px 10px;
  min-width: 64px;
}

.resource-card span,
.resource-card strong,
.resource-card small {
  display: block;
}

.resource-card span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.resource-card strong {
  margin-top: 2px;
  font-size: 1rem;
  font-weight: 900;
}

.resource-card small {
  display: none;
}

.resource-card.future {
  display: none;
}

.meter {
  height: 6px;
  overflow: hidden;
  margin-top: 6px;
  border-radius: 999px;
  background: #ece5d9;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--orange), var(--yellow), var(--green), var(--blue), var(--violet));
  transition: width 500ms ease;
}

.trust-card .meter span {
  background: var(--trust);
}

.community-card .meter span {
  background: #2f9b57;
}

.civic-card .meter span {
  background: #2d71be;
}

.tension-card .meter span {
  background: #d75151;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 18px;
  align-items: start;
}

.diorama-panel {
  min-width: 0;
}

.diorama {
  position: relative;
  width: 100%;
  height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  box-shadow: var(--shadow);
}

.sky-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #5b9dc2 0%, #8bbdd4 45%, #c8dfe8 70%, #e8d5b0 100%);
}

.collage-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left bottom;
}

.sky { display: none; }

.buildings {
  display: none;
}

.building {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  padding: 10px 6px;
  border: 3px solid rgba(23, 33, 38, 0.72);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  color: #223039;
  font-size: clamp(0.72rem, 1.6vw, 0.92rem);
  text-align: center;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.52) 0 12px, transparent 12px 24px), #eeb75f;
}

.school {
  height: 84%;
  background-color: #ed6767;
}

.shop {
  height: 72%;
  background-color: #93cc86;
}

.library {
  height: 90%;
  background-color: #adaed7;
}

.square {
  position: absolute;
  inset: 0;
  background: none;
  border: none;
}

.stage {
  position: absolute;
  left: 1%;
  bottom: 0;
  width: 16%;
  min-width: 80px;
  height: 62%;
  border: 3px solid rgba(255,255,255,0.7);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: rgba(255,255,255,0.08);
  animation: popIn 280ms ease both;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
}

.stage-roof { display: none; }

.stage-deck {
  background: none;
  border: none;
  color: #fff;
  font-weight: 900;
  font-size: 0.75rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  padding: 0;
  height: auto;
  position: static;
  grid-area: unset;
  place-items: unset;
}

.dance-floor {
  position: absolute;
  left: 46%;
  right: 28%;
  bottom: 20%;
  height: 18%;
  border: 2px dashed rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
}

.tent {
  position: absolute;
  display: grid;
  place-items: end center;
  width: 68px;
  height: 54px;
  padding-bottom: 5px;
  border: 2px solid rgba(23, 33, 38, 0.5);
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(135deg, #fff 0 33%, #efc84b 33% 66%, #fff 66%);
  font-size: 0.7rem;
  font-weight: 900;
}

.tent-a {
  left: 26%;
  bottom: 14%;
}

.tent-b {
  left: 40%;
  bottom: 14%;
  background: linear-gradient(135deg, #fff 0 33%, #65ad74 33% 66%, #fff 66%);
}

.table {
  position: absolute;
  width: 32px;
  height: 24px;
  border: 2px solid rgba(23, 33, 38, 0.45);
  border-radius: 6px;
  background: #f8efe0;
}

.table-a {
  left: 34%;
  bottom: 18%;
}

.table-b {
  left: 46%;
  bottom: 18%;
}

.parade-street {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 24%;
  background: none;
}

.route-line {
  display: none;
}

.walker-lane {
  position: absolute;
  inset: 0;
}

.person {
  position: absolute;
  bottom: 32px;
  left: -52px;
  width: 26px;
  height: 48px;
  border-radius: 14px 14px 6px 6px;
  background: var(--shirt, #276f9c);
  border: 2px solid rgba(23, 33, 38, 0.6);
  animation: walkBy var(--duration, 9s) linear forwards;
}

.person::before {
  content: "";
  position: absolute;
  top: -18px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(23, 33, 38, 0.55);
  background: var(--skin, #c98d61);
}

.person.dancer {
  animation: joinDance 900ms ease forwards, danceBob 620ms ease-in-out 900ms infinite alternate;
  z-index: 3;
}

.person.marcher {
  animation: walkBy var(--duration, 6s) linear forwards;
  border-width: 3px;
  border-color: rgba(255,255,255,0.7);
}

.table.roots-active {
  background: linear-gradient(135deg, #fdf6e3 0%, #ffe8cc 100%);
  border-color: #d94848;
  border-width: 3px;
  box-shadow: 0 0 0 4px rgba(217,72,72,0.18);
}

.cost-note {
  font-size: 0.75rem;
  color: var(--muted, #6b7280);
  margin: 4px 0 12px;
}

.customize-details {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.customize-details summary {
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 900;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.customize-details summary::-webkit-details-marker { display: none; }

.customize-details summary::after {
  content: " ▸";
  font-size: 0.7rem;
}

.customize-details[open] summary::after {
  content: " ▾";
}

.customize-details[open] summary {
  border-bottom: 1px solid var(--line);
}

.customize-details .customize-group:last-child {
  margin-bottom: 14px;
}

.customize-details .customize-group {
  padding: 0 12px;
}

.customize-group { margin-top: 16px; }
.customize-label {
  font-size: 0.84rem;
  font-weight: 900;
  margin: 0 0 8px;
}
.customize-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.customize-btn {
  display: grid;
  gap: 2px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}
.customize-btn strong { font-size: 0.84rem; font-weight: 900; }
.customize-btn span   { font-size: 0.7rem; color: var(--muted); }
.customize-btn.selected,
.customize-btn:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}
.customize-btn.selected span,
.customize-btn:hover span { color: rgba(255,255,255,0.7); }

.resume-section {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.96);
}
.resume-label { margin: 0 0 2px; font-weight: 900; }
.resume-sub   { margin: 0 0 12px; font-size: 0.86rem; color: var(--muted); }
.new-game-link {
  width: 100%;
  margin-top: 8px;
  padding: 6px 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.84rem;
  text-decoration: underline;
  cursor: pointer;
}
.new-game-link:hover { color: var(--ink); }

.challenge-card { border-color: var(--red); }
.challenge-eyebrow { color: var(--red); }
.challenge-choices {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.challenge-choice-btn {
  width: 100%;
  min-height: 56px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  line-height: 1.4;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}
.challenge-choice-btn strong { display: block; font-weight: 900; margin-bottom: 2px; }
.challenge-choice-btn small  { display: block; font-size: 0.74rem; color: var(--muted); }
.challenge-choice-btn:not(:disabled):hover {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}
.challenge-choice-btn:not(:disabled):hover small { color: rgba(255,255,255,0.7); }
.challenge-choice-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.failure-card {
  border-color: var(--red);
  background: rgba(237,103,103,0.08) !important;
}
.failure-eyebrow { color: var(--red); }

.yearend-card {
  border-color: var(--trust);
  background: rgba(40,154,72,0.06) !important;
}
.yearend-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}
.yearend-stat {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: center;
}
.yearend-stat strong { display: block; font-size: 1.4rem; font-weight: 900; }
.yearend-stat span {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}
.yearend-copy {
  font-size: 0.92rem;
  color: var(--muted);
  margin: 0 0 12px;
  line-height: 1.55;
}

.yearend-delta {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
}

.yearend-delta-item {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  font-size: 0.82rem;
  color: var(--muted);
}
.yearend-history {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}
.yearend-history-dot {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 900;
}

.absent-profiles { margin-top: 16px; }
.absent-card {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 6px;
  background: var(--panel);
}
.absent-card strong { display: block; font-size: 0.84rem; font-weight: 900; }
.absent-card small  { font-size: 0.76rem; color: var(--muted); }

.recovery-actions {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.recovery-actions h3 {
  margin: 0 0 10px;
  font-size: 0.94rem;
  line-height: 1.35;
}

.control-panel {
  display: grid;
  gap: 14px;
}

.panel-card {
  padding: 16px;
  animation: panelEnter 220ms ease both;
}

.step-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 16px;
  padding-left: 20px;
  color: var(--muted);
}

.step-list li {
  line-height: 1.42;
}

.step-list li.current {
  color: var(--ink);
  font-weight: 900;
}

.step-list li.done {
  color: var(--trust);
  font-weight: 900;
}

.primary-button,
.secondary-button {
  width: 100%;
}

.primary-button:disabled {
  opacity: 0.62;
  cursor: default;
  transform: none;
}

.secondary-button {
  background: #fff;
  color: var(--ink);
}

.footer-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.footer-actions button,
.modal-close,
.support-links a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
}

.footer-actions button:first-child,
.support-links a:first-child {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.info-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(44, 44, 44, 0.62);
}

.modal-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: min(720px, calc(100vh - 40px));
  overflow: auto;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-panel h2 {
  max-width: 620px;
  font-size: clamp(1.5rem, 4vw, 2.4rem);
}

.modal-panel p {
  color: var(--muted);
  line-height: 1.64;
}

.modal-close {
  float: right;
  margin-left: 14px;
}

.support-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0;
}

.modal-note {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}

.choice-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.choice-grid button {
  justify-content: center;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.choice-grid button.selected {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.organizer-card {
  border-color: rgba(31, 122, 105, 0.48);
}

.character-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.character-portrait {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  flex-shrink: 0;
  border: 2px solid rgba(31, 122, 105, 0.3);
}

.character-header .eyebrow {
  margin: 0;
}

.organizer-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.58;
}

.safety-footer {
  width: min(1220px, calc(100% - 28px));
  margin: 0 auto;
  padding: 0 0 28px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.safety-footer p {
  margin: 0;
}

.step-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(44, 44, 44, 0.06);
}

.step-dot {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #ece5d9;
  transition: background 400ms ease, transform 300ms ease;
  position: relative;
}

.step-dot.current {
  background: var(--orange);
  transform: scaleY(1.6);
}

.step-dot.done {
  background: var(--trust);
}

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

@keyframes panelEnter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes walkBy {
  from { transform: translateX(0); }
  to   { transform: translateX(calc(100vw + 170px)); }
}

@keyframes walkDance {
  0%   { transform: translateX(0)                               translateY(0)    rotate(0deg); }
  12%  { transform: translateX(calc((100vw + 170px) * 0.12))   translateY(-9px) rotate(-6deg); }
  25%  { transform: translateX(calc((100vw + 170px) * 0.25))   translateY(0)    rotate(0deg); }
  37%  { transform: translateX(calc((100vw + 170px) * 0.37))   translateY(-9px) rotate(6deg); }
  50%  { transform: translateX(calc((100vw + 170px) * 0.5))    translateY(0)    rotate(0deg); }
  62%  { transform: translateX(calc((100vw + 170px) * 0.62))   translateY(-9px) rotate(-6deg); }
  75%  { transform: translateX(calc((100vw + 170px) * 0.75))   translateY(0)    rotate(0deg); }
  87%  { transform: translateX(calc((100vw + 170px) * 0.87))   translateY(-9px) rotate(6deg); }
  100% { transform: translateX(calc(100vw + 170px))             translateY(0)    rotate(0deg); }
}

.person.marcher.dancing-marcher {
  animation: walkDance var(--duration, 22s) linear forwards;
}

@keyframes joinDance {
  to {
    left: var(--dance-left, 52%);
    bottom: var(--dance-bottom, 22px);
  }
}

@keyframes danceBob {
  from { transform: translateY(0) rotate(-2deg); }
  to   { transform: translateY(-8px) rotate(2deg); }
}

.parade-bubble {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.18);
  animation: bubbleRise 3.2s ease-out forwards;
  pointer-events: none;
}

@keyframes bubbleRise {
  0%   { transform: translateY(0) scale(0.6);   opacity: 0.9; }
  60%  { opacity: 0.7; }
  100% { transform: translateY(-140px) scale(1.3); opacity: 0; }
}

.confetti-piece {
  position: absolute;
  width: 7px;
  height: 7px;
  background: var(--cc, #e40303);
  border-radius: 1px;
  animation: confettiBurst 2.8s ease-out forwards;
  pointer-events: none;
}

@keyframes confettiBurst {
  0%   { transform: translateY(0) rotate(var(--rot, 0deg)) scale(1);    opacity: 1; }
  70%  { opacity: 0.8; }
  100% { transform: translateY(-100px) rotate(calc(var(--rot, 0deg) + 540deg)) scale(0.4); opacity: 0; }
}

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

@media (max-width: 980px) {
  .intro-panel,
  .hud,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .control-panel {
    order: 1;
  }

  .diorama-panel {
    order: 2;
  }

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

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .title-lockup {
    text-align: left;
  }

  .partner-lockup {
    align-items: flex-start;
    flex-direction: column;
    width: 100%;
  }

  .partner-lockup img {
    max-width: 190px;
  }

  .modal-panel {
    padding: 18px;
  }

  .modal-close {
    float: none;
    width: 100%;
    margin: 0 0 14px;
  }

  .footer-actions button,
  .support-links a {
    width: 100%;
  }

  h1 {
    font-size: 2.35rem;
  }

  .town-row {
    flex-direction: column;
  }

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

  .diorama {
    height: 300px;
  }

  .resource-card {
    min-height: 80px;
    padding: 10px;
  }

  .resource-card strong {
    font-size: 1.15rem;
    margin-top: 4px;
  }

  .resource-card small {
    display: none;
  }

  .buildings {
    inset-inline: 3%;
    gap: 6px;
  }

  .building {
    padding-inline: 3px;
    font-size: 0.68rem;
  }

  .square {
    inset: 0;
  }

  .stage {
    left: 3%;
    min-width: 60px;
  }

  .dance-floor {
    left: 36%;
    right: 36%;
  }

  .tent {
    width: 56px;
    height: 46px;
    font-size: 0.66rem;
  }
}

@media (max-width: 390px) {
  .resource-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Invite counter ────────────────────────────────────────── */
.invite-counter {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 12px;
  border: 1.5px solid var(--trust);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 900;
  color: var(--trust);
  letter-spacing: 0.02em;
}

.walker.invitable {
  cursor: pointer;
  filter: drop-shadow(0 0 5px #f1c84b);
  transition: filter 0.15s;
}
.walker.invitable:hover {
  filter: drop-shadow(0 0 8px #eeb75f) brightness(1.1);
}
.person.invitable {
  cursor: pointer;
  filter: drop-shadow(0 0 5px #f1c84b);
}
.person.invited {
  filter: drop-shadow(0 0 6px var(--trust));
}

/* ── Quiz ──────────────────────────────────────────────────── */
.quiz-container {
  display: grid;
  gap: 16px;
  margin-top: 14px;
}

.quiz-block {
  display: grid;
  gap: 6px;
}

.quiz-question {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 4px;
  line-height: 1.45;
}

.quiz-option {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  font-family: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.12s, border-color 0.12s;
}
.quiz-option:hover:not(:disabled) {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}
.quiz-option:disabled {
  opacity: 0.45;
  cursor: default;
}
.quiz-option.correct {
  border-color: var(--trust);
  background: rgba(40, 154, 72, 0.08);
  opacity: 1;
}

.quiz-response {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 4px 0 0;
  font-style: italic;
  line-height: 1.5;
}

/* ── Milestone sort ────────────────────────────────────────── */
.milestone-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.milestone-card {
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.milestone-card:hover {
  border-color: var(--orange);
}
.milestone-card.selected {
  border-color: var(--orange);
  background: rgba(238, 183, 95, 0.1);
  cursor: default;
}
.milestone-card.correct-seq {
  border-color: var(--trust);
  background: rgba(40, 154, 72, 0.08);
  cursor: default;
}
.milestone-card.shake {
  animation: shake 0.35s ease;
}

.card-label {
  font-size: 0.88rem;
  font-weight: 900;
}
.card-year {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 2px;
}
.card-detail {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.5;
  display: none;
}
.milestone-card.correct-seq .card-detail {
  display: block;
}

.milestone-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 8px 0 0;
  min-height: 18px;
  line-height: 1.5;
}

.roots-family-chip {
  display: inline-block;
  margin: 8px 0;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.roots-choice-grid {
  margin-top: 10px;
}

.panel-body {
  font-size: 0.86rem;
  color: var(--muted);
  margin: 4px 0 0;
  line-height: 1.5;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  60%       { transform: translateX(6px); }
}

/* ── Outreach tiles ────────────────────────────────────────── */
.outreach-grid {
  display: grid;
  gap: 8px;
  margin: 12px 0 14px;
}

.outreach-tile {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.12s, background 0.12s;
}
.outreach-tile strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 900;
}
.outreach-tile small {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 2px;
}
.tile-costs {
  display: flex;
  gap: 10px;
  margin-top: 5px;
}
.tile-cost {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--red);
}
.tile-gain {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--trust);
}
.outreach-tile:hover:not(.selected):not(:disabled) {
  border-color: var(--ink);
}
.outreach-tile.selected {
  border-color: var(--trust);
  background: rgba(40, 154, 72, 0.07);
}
.outreach-tile:disabled {
  cursor: default;
  opacity: 0.6;
}
