@font-face {
  font-family: "Fraunces";
  src: url("../fonts/Fraunces.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Literata";
  src: url("../fonts/Literata.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #1f1a14;
  --paper: #f3ebe0;
  --sand: #e6d7c3;
  --clay: #8b4513;
  --sea: #3d6b8c;
  --land: #c4a574;
  --olive: #5a6b3a;
  --focus: #2c5282;
  --radius: 0.5rem;
  --border: 2px solid var(--ink);
  --shadow: 0 2px 0 color-mix(in srgb, var(--ink) 18%, transparent);
  --font-display: "Fraunces", "Palatino Linotype", Palatino, serif;
  --font-body: "Literata", "Georgia", serif;
  /* Geometric page frame width — keep round chrome inside this inset (FR-023). */
  --page-frame: 14px;
}

html {
  height: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--sand);
  background-image:
    linear-gradient(
      165deg,
      color-mix(in srgb, var(--paper) 28%, transparent),
      color-mix(in srgb, var(--sand) 35%, transparent)
    ),
    url("../img/page-texture.png");
  background-size: auto, 220px 220px;
  background-repeat: no-repeat, repeat;
  line-height: 1.45;
}

/* Subtle Middle Eastern geometric page frame (FR-023 / SC-041: all four sides, home + round) */
body.has-page-frame {
  position: relative;
  box-sizing: border-box;
  min-height: 100%;
  min-height: 100dvh;
  margin: 0;
  overflow-x: clip;
  border: var(--page-frame) solid transparent;
  border-image-source: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Crect width='48' height='48' fill='%23c4a574'/%3E%3Cpath fill='none' stroke='%235c4033' stroke-width='1.2' d='M0 24h48M24 0v48M8 8l32 32M40 8L8 40'/%3E%3Cpath fill='none' stroke='%238b6914' stroke-width='0.9' d='M12 0v48M36 0v48M0 12h48M0 36h48'/%3E%3Ccircle cx='24' cy='24' r='6' fill='none' stroke='%233d4a2e' stroke-width='1'/%3E%3Cpath fill='none' stroke='%23e8dcc8' stroke-width='0.8' d='M24 6l4 10h10l-8 6 3 10-9-6-9 6 3-10-8-6h10z'/%3E%3C/svg%3E");
  border-image-slice: 14;
  border-image-repeat: round;
  border-image-width: var(--page-frame);
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--paper) 75%, white),
    inset 0 0 0 5px color-mix(in srgb, var(--clay) 40%, var(--ink));
}

main {
  max-width: min(96rem, 100%);
  margin: 0 auto;
  padding: 0.65rem 0.75rem 1.5rem;
  box-sizing: border-box;
}

.section {
  display: none;
}

.section.is-active {
  display: block;
  animation: fade-in 0.35s ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(0.35rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: 0.01em;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  margin: 0.4rem 0 0.6rem;
  line-height: 1.05;
}

h2 {
  font-size: 1.55rem;
  margin: 0 0 0.75rem;
}

h3 {
  font-size: 1.05rem;
  margin: 0 0 0.45rem;
}

.purpose {
  max-width: 42rem;
  margin: 0 0 1.25rem;
  font-size: 1.05rem;
}

.top-actions,
.home-footer,
.player-actions,
.dialog-actions,
.choice-row,
.zoom-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.top-actions {
  justify-content: flex-end;
}

.home-footer {
  margin-top: 1.75rem;
}

button,
.map-card {
  font: inherit;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 88%, white);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  padding: 0.55rem 0.95rem;
  transition:
    background 0.15s ease,
    transform 0.12s ease,
    box-shadow 0.15s ease;
}

button:hover,
.map-card:hover {
  background: color-mix(in srgb, var(--sand) 70%, white);
  transform: translateY(-1px);
}

button:active,
.map-card:active {
  transform: translateY(1px);
  box-shadow: none;
}

button:focus-visible,
.map-card:focus-visible,
input:focus-visible,
.name-choices button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--focus) 40%, transparent);
}

u.mnemonic,
.mnemonic {
  text-decoration: underline;
  text-underline-offset: 0.12em;
  font-style: normal;
  font-weight: inherit;
}

button.is-selected {
  background: color-mix(in srgb, var(--olive) 22%, var(--paper));
  border-color: var(--olive);
}

.player-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  margin: 0 0 1.35rem;
  padding: 0.85rem 1rem;
  border: var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper) 75%, white);
}

.player-badge {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center; /* Last score group centered as a unit with the name (FR-015) */
  column-gap: 1rem;
  row-gap: 0.35rem;
  min-width: 8rem;
  flex: 1 1 12rem;
}

.player-name {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5.5vw, 3rem);
  font-weight: 650;
  line-height: 1.05;
  letter-spacing: 0.01em;
  margin-inline-end: 0;
}

.player-recent-score {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  margin-inline-start: 0;
  font-family: var(--font-display);
  line-height: 1.1;
}

.player-recent-score .last-score-label {
  font-size: clamp(0.7rem, 1.6vw, 0.85rem);
  font-weight: 550;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.75;
}

.player-recent-score .last-score-value {
  /* ~¾ of .player-name size (FR-015 / FR-052) */
  font-size: clamp(1.5rem, 4.125vw, 2.25rem);
  font-weight: 650;
  opacity: 0.92;
}

.player-recent-score[hidden] {
  display: none !important;
}

.asked-count {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.85;
}

.map-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem 1.25rem;
  align-items: stretch;
}

.map-list > li {
  display: flex;
  min-height: 100%;
}

.map-card {
  width: 100%;
  height: 100%;
  text-align: left;
  display: grid;
  gap: 0.45rem;
  align-content: start;
  padding: 1.35rem 1.4rem;
  min-height: 6.5rem;
}

.map-card .map-title {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.2vw, 1.55rem);
  font-weight: 650;
}

.map-card .map-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: center;
}

.map-card .marks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
}

.map-card .mark {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
  opacity: 0.75;
}

.map-card .mark.is-filled {
  opacity: 1;
}

.map-card .mark-box {
  position: relative;
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  border: 2px solid var(--ink);
  border-radius: 0.22rem;
  background: color-mix(in srgb, var(--paper) 70%, white);
  box-shadow: 1px 1px 0 color-mix(in srgb, var(--ink) 18%, transparent);
}

.map-card .mark.is-filled .mark-box {
  background: color-mix(in srgb, var(--olive) 22%, var(--paper));
  border-color: var(--olive);
}

.map-card .mark-box .mark-check {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.map-card .mark.is-filled .mark-box .mark-check {
  display: block;
}

.map-card .stars {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  opacity: 0.9;
}

.map-card .map-note {
  font-size: 0.95rem;
  opacity: 0.8;
}

.map-stage .place-marker {
  fill: color-mix(in srgb, var(--clay) 70%, white);
  stroke: var(--ink);
  stroke-width: 1.5;
}

.map-stage .place-marker.disputed {
  fill: color-mix(in srgb, var(--sea) 35%, white);
}

.map-stage .disputed-label {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 650;
  fill: var(--clay);
  paint-order: stroke;
  stroke: color-mix(in srgb, var(--paper) 90%, white);
  stroke-width: 3px;
  text-anchor: middle;
  pointer-events: none;
}

.map-stage .feedback-arc {
  fill: none;
  stroke: var(--clay);
  stroke-width: 2.5;
  stroke-dasharray: 6 4;
  opacity: 0.9;
  pointer-events: none;
}

.map-stage .feedback-tap {
  pointer-events: none;
}

.map-stage .feedback-tap path {
  fill: none;
  stroke: var(--olive);
  stroke-width: 2.25;
  stroke-linecap: square;
}

.map-stage .feedback-tap-ring {
  fill: none;
  stroke: color-mix(in srgb, var(--olive) 70%, var(--ink));
  stroke-width: 1.75;
  pointer-events: none;
}

.map-stage .feedback-correct {
  fill: color-mix(in srgb, var(--olive) 35%, white);
  stroke: var(--olive);
  stroke-width: 2;
  pointer-events: none;
}

.map-stage .feature-path {
  fill: none;
  stroke: transparent;
  stroke-width: 1.5;
  pointer-events: none;
}

/* Drawn map rivers stay visible (do not inherit transparent feature-path stroke). */
.map-stage .map-river,
.map-stage [id^="river-"] {
  stroke: #5d747e;
  stroke-width: 1.15;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-stage .feature-path.feature-area {
  fill: transparent;
}

.map-stage .feature-path.is-highlighted,
.map-stage .map-river.is-highlighted,
.map-stage [id^="river-"].is-highlighted {
  stroke: #c45c26;
  stroke-width: 5.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  fill: none;
  opacity: 0.95;
}

.map-stage .feature-path.feature-area.is-highlighted {
  fill: color-mix(in srgb, #c45c26 12%, transparent);
}

.name-choices button.choice-correct {
  background: color-mix(in srgb, #3d7a4a 28%, var(--paper));
  border-color: #3d7a4a;
}

.name-choices button.choice-wrong {
  background: color-mix(in srgb, #a33c2c 24%, var(--paper));
  border-color: #a33c2c;
}

/* Fill framed viewport; play box scales as one unit to fit (const 1.6.0 / FR-056). */
#round.is-active {
  min-height: calc(100dvh - (2 * var(--page-frame)) - 2.4rem);
  max-height: calc(100dvh - (2 * var(--page-frame)) - 2.4rem);
  width: 100%;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.35rem;
  box-sizing: border-box;
  overflow: hidden;
}

.round-layout {
  position: relative;
  width: 100%;
  max-width: min(100%, 56rem);
  max-height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 0.4rem;
  justify-items: stretch;
  padding: 0.45rem 0.5rem 0.65rem;
  border: var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper) 78%, white);
  box-shadow: 0 8px 28px color-mix(in srgb, var(--ink) 14%, transparent);
  box-sizing: border-box;
  transform-origin: center center;
}

.round-header {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem 1.25rem;
  align-items: center;
  text-align: center;
  margin-bottom: 0.85rem; /* ~0.75–1rem above map (FR-049) */
}

.prompt {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2.8vw, 1.55rem);
  flex: 0 1 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0.35rem 0.55rem;
  text-align: center;
}

.prompt.is-find .prompt-mode {
  font-weight: 500;
  opacity: 0.72;
  font-size: 0.92em;
}

.prompt.is-name .prompt-mode {
  font-weight: 700;
  opacity: 1;
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  max-width: 22rem;
  line-height: 1.25;
}

.prompt-target {
  font-weight: 700;
  font-size: 1.18em;
  letter-spacing: 0.01em;
}

.prompt-target[hidden] {
  display: none !important;
}

.round-score {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3.2vw, 1.85rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.75rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: color-mix(in srgb, var(--olive) 18%, var(--paper));
  box-shadow: var(--shadow);
  min-width: 5.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.round-score-label {
  flex: 0 0 auto;
}

.round-score-value {
  display: inline-block;
  min-width: 2.4ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
  transform-origin: 50% 50%;
}

.round-score-value.is-flipping {
  animation: score-digit-flip 0.14s ease-out;
}

@keyframes score-digit-flip {
  from {
    transform: translateY(0.4em) scaleY(0.55);
    opacity: 0.4;
  }
  to {
    transform: translateY(0) scaleY(1);
    opacity: 1;
  }
}

.map-stage {
  position: relative;
  /* Leave vertical room for header + feedback; whole box may still unit-scale via JS. */
  width: min(
    100%,
    calc(100dvw - (2 * var(--page-frame)) - 2rem),
    calc(min(58dvh - (2 * var(--page-frame)), 48rem) * 1.13)
  );
  aspect-ratio: 1.127 / 1;
  max-height: min(58dvh - (2 * var(--page-frame)), 48rem);
  height: auto;
  min-height: 0;
  margin-inline: auto;
  margin-bottom: 0.85rem; /* ~0.75–1rem below map (FR-049) */
  overflow: hidden;
  border: none;
  border-radius: 0;
  background: transparent;
  touch-action: manipulation;
  box-sizing: border-box;
}

.map-stage svg {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  pointer-events: auto;
  border: var(--border);
  border-radius: var(--radius);
  box-sizing: border-box;
}

.map-stage .place-label {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 650;
  fill: var(--ink);
  paint-order: stroke;
  stroke: color-mix(in srgb, var(--paper) 90%, white);
  stroke-width: 3px;
  pointer-events: none;
}

.map-stage .water-label {
  font-family: var(--font-display);
  font-size: 22px;
  font-style: italic;
  font-weight: 600;
  fill: var(--sea);
  paint-order: stroke;
  stroke: color-mix(in srgb, #e8f2f8 85%, white);
  stroke-width: 4px;
  pointer-events: none;
}

.map-stage .guess-marker,
.map-stage .answer-marker {
  pointer-events: none;
}

.name-choices {
  width: min(100%, 42rem);
  margin-inline: auto;
  display: grid;
  gap: 0.55rem;
  justify-self: center;
}

.name-choices button {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.name-choices .choice-key {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 2px solid var(--ink);
  border-radius: 0.35rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  background: color-mix(in srgb, var(--sand) 55%, white);
}

.name-choices .choice-label {
  flex: 1 1 auto;
}

.feedback-slot {
  position: relative;
  width: min(100%, 42rem);
  /* Fixed worst-case height (multi-line fact + near-miss + Continue); no internal scroll. */
  min-height: 20rem;
  height: 20rem;
  margin: 0.35rem auto 0.15rem;
  padding: 0;
  box-sizing: border-box;
  display: flex;
  align-items: stretch;
  justify-content: center;
  justify-self: center;
  flex-shrink: 0;
}

.feedback-panel {
  position: absolute;
  inset: 0;
  width: 100%;
  padding: 0.55rem 0.9rem 0.65rem;
  border: var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper) 82%, white);
  text-align: center;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.2rem;
}

.feedback-panel #feedback-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3.2vw, 2rem);
  line-height: 1.15;
}

.feedback-panel #feedback-score,
.feedback-panel #feedback-near {
  margin: 0;
  font-size: clamp(1.15rem, 2.4vw, 1.4rem);
  line-height: 1.25;
}

.feedback-panel #feedback-fact {
  flex: 0 1 auto;
  overflow: hidden;
  min-height: 0;
  max-width: 100%;
  margin: 0.15rem 0 0;
  font-size: clamp(1.1rem, 2.2vw, 1.35rem);
  line-height: 1.3;
}

.feedback-panel #feedback-next {
  flex: 0 0 auto;
  margin-top: auto;
  font-size: 1.1rem;
}

.feedback-panel[hidden],
.name-choices[hidden],
.token-tray[hidden],
.asked-count[hidden],
button[hidden],
.results-overlay[hidden],
.march-skip[hidden] {
  display: none !important;
}

.round-layout.is-camp {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.round-layout.is-camp .feedback-slot {
  display: none;
}

.token-tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
  max-width: 100%;
  padding: 0.35rem 0.15rem 0.15rem;
  box-sizing: border-box;
}

.camp-anchors {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.camp-slot-anchor {
  position: absolute;
  pointer-events: none;
}

.camp-token {
  font-family: var(--font-display);
  font-size: clamp(0.68rem, 1.4vw, 0.85rem);
  font-weight: 650;
  line-height: 1.05;
  padding: 0.15rem 0.2rem 0.2rem;
  border: 2px solid var(--ink);
  border-radius: 0.35rem;
  background: color-mix(in srgb, var(--paper) 78%, #e7d3ae);
  color: var(--ink);
  box-shadow: none;
  cursor: grab;
  touch-action: none;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  position: relative;
  box-sizing: border-box;
  overflow: hidden;
  flex: 0 0 auto;
}

.camp-token.is-placed {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  min-width: 0;
  margin: 0;
  pointer-events: auto;
  background: #f4ecda;
}

.slot-group.is-covered .slot-number,
.slot-group.is-covered .slot-function {
  opacity: 0;
}

.camp-token.is-dragging {
  pointer-events: none;
  margin: 0;
  z-index: 40;
}

.camp-tent-cluster {
  width: 72%;
  height: 50%;
  flex: 0 0 auto;
  display: block;
  pointer-events: none;
}

.camp-token-label {
  position: absolute;
  left: 0.15rem;
  right: 0.15rem;
  bottom: 0.12rem;
  display: block;
  text-align: center;
  width: auto;
  line-height: 1.05;
  overflow-wrap: normal;
  word-break: normal;
}

.map-stage svg.is-explorer .slot-group[data-slot-id^="tribe-"] .slot-hit {
  fill: transparent;
  stroke: none;
}

.camp-token.is-selected {
  outline: 3px solid color-mix(in srgb, var(--olive) 70%, #2a5a3a);
  outline-offset: 1px;
}

.camp-token.is-correct {
  background: color-mix(in srgb, #2f7d4a 28%, var(--paper));
  border-color: #2f7d4a;
}

.camp-token.is-wrong {
  background: color-mix(in srgb, #a33b2e 26%, var(--paper));
  border-color: #a33b2e;
}

.march-skip {
  justify-self: center;
  z-index: 6;
}

.camp-token.is-marching-token {
  pointer-events: none;
  z-index: 6;
}

.round-layout.is-camp .map-stage {
  background: transparent;
  padding: 0;
}

.round-layout.is-camp .map-stage svg {
  padding: 0;
  background: transparent;
}

.prompt.is-arrange .prompt-mode {
  font-weight: 700;
}

.results-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: color-mix(in srgb, var(--ink) 28%, transparent);
  border-radius: inherit;
}

.results-box,
.sources-box {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.25rem 1.35rem;
  border: var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper) 80%, white);
}

.results-overlay .results-box {
  width: min(100%, 34rem);
  max-height: min(100%, calc(100dvh - (2 * var(--page-frame)) - 4rem));
  overflow: hidden;
  padding: 1.75rem 1.85rem;
  box-shadow: 0 12px 40px color-mix(in srgb, var(--ink) 28%, transparent);
  box-sizing: border-box;
  transform-origin: center center;
}

.results-overlay .results-box h2 {
  margin: 0 0 0.65rem;
  font-size: clamp(2rem, 4.5vw, 2.75rem);
  line-height: 1.15;
}

.results-overlay .results-box p {
  margin: 0.35rem 0;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  line-height: 1.3;
}

.results-overlay .results-box button {
  margin-top: 1rem;
  font-size: clamp(1.15rem, 2.5vw, 1.45rem);
}

.sources-box ul {
  padding-left: 1.2rem;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
  z-index: 40;
}

.dialog-backdrop.is-open {
  display: flex;
  animation: fade-in 0.2s ease-out;
}

.dialog {
  width: min(100%, 26rem);
  padding: 1.2rem 1.25rem;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 12px 40px color-mix(in srgb, var(--ink) 28%, transparent);
}

.dialog-setup,
.dialog-history {
  width: min(100%, 30rem);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
  max-height: min(50vh, 22rem);
  overflow: auto;
}

.history-list li {
  padding: 0.55rem 0.7rem;
  border: var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper) 88%, white);
}

.history-list .history-points {
  font-family: var(--font-display);
  font-weight: 650;
}

.history-list .history-level {
  font-size: 0.95rem;
  opacity: 0.85;
}

.dialog label {
  display: block;
  margin: 0.65rem 0 0.35rem;
}

.dialog input[type="text"] {
  width: 100%;
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: var(--border);
  border-radius: var(--radius);
  background: white;
}

.dialog input[type="range"] {
  width: 100%;
}

.dialog-actions {
  margin-top: 1rem;
}

.dialog-actions-setup {
  margin-top: 2rem;
  padding-top: 0.35rem;
}

.setup-choices {
  display: grid;
  gap: 1rem;
}

.player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.player-list button {
  width: 100%;
  text-align: left;
}

@media (max-width: 640px) {
  main {
    padding: 0.75rem 0.85rem 2rem;
  }

  .map-list {
    gap: 0.85rem 0.75rem;
  }

  .map-card {
    padding: 1.15rem 1rem;
    min-height: 5.75rem;
  }

  .map-stage {
    max-height: min(50dvh - (2 * var(--page-frame)), 36rem);
    width: min(
      100%,
      calc(100dvw - (2 * var(--page-frame)) - 1.5rem),
      calc(min(50dvh - (2 * var(--page-frame)), 36rem) * 1.13)
    );
  }

  .feedback-slot {
    min-height: 16rem;
    height: 16rem;
    margin: 0.35rem auto 0.15rem;
    padding: 0;
  }

  .results-overlay .results-box {
    width: min(100%, 92vw);
    max-height: min(88dvh, calc(100% - 0.5rem));
    padding: 1.25rem 1.15rem;
  }

  .results-overlay .results-box h2 {
    font-size: clamp(1.55rem, 6.5vw, 2.1rem);
  }

  .results-overlay .results-box p {
    font-size: clamp(1.1rem, 4.2vw, 1.45rem);
  }

  .results-overlay .results-box button {
    font-size: clamp(1rem, 3.8vw, 1.25rem);
  }

  body.has-page-frame {
    --page-frame: 10px;
    border-width: var(--page-frame);
  }

  .map-stage .place-label {
    font-size: 15px;
  }

  .map-stage .water-label {
    font-size: 18px;
  }

  .player-name {
    font-size: clamp(1.75rem, 8vw, 2.4rem);
  }
}
