:root {
  --paper: #f6f1e6;
  --paper-raised: #fdfaf3;
  --ink: #221e19;
  --ink-soft: #6c6357;
  --line: #d9cfbc;
  --vermilion: #b93a26;
  --vermilion-dark: #94291a;
  --indigo: #24476b;
  --sea: #d5e0e0;
  --land: #efe6d2;
  --border: #bfb196;
  --thumb: 22px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

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

body {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}

h1,
h2,
p,
ol {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

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

/* ---- Top bar ---- */

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 54px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-raised);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.seal {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--vermilion);
  color: var(--paper-raised);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1;
}

.seal-large {
  width: 68px;
  height: 68px;
  border-radius: 8px;
  font-size: 44px;
  transform: rotate(-3deg);
}

.status {
  display: flex;
  gap: 20px;
  color: var(--ink-soft);
  font-size: 14px;
  white-space: nowrap;
}

.status b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.status > span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.exhibit-nav button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--ink);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.exhibit-nav button:hover:not(:disabled) {
  background: var(--line);
}

.exhibit-nav button:disabled {
  cursor: default;
  opacity: 0.25;
}

main {
  flex: 1;
  min-height: 0;
}

/* ---- Buttons ---- */

.button {
  padding: 10px 18px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.12s, color 0.12s;
}

.button:hover:not(:disabled) {
  background: var(--ink);
  color: var(--paper-raised);
}

.button.primary {
  border-color: var(--vermilion);
  background: var(--vermilion);
  color: var(--paper-raised);
}

.button.primary:hover:not(:disabled) {
  border-color: var(--vermilion-dark);
  background: var(--vermilion-dark);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.button.small {
  padding: 3px 12px;
  font-size: 13px;
}

/* ---- Intro and final screens ---- */

body[data-screen="intro"],
body[data-screen="done"] {
  height: auto;
  min-height: 100%;
}

.intro,
.done {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 620px;
  margin: 0 auto;
  padding: 48px 20px 64px;
  text-align: center;
}

.intro h1,
.done h1 {
  font-family: var(--serif);
  font-weight: 500;
}

.intro h1 {
  margin-top: 22px;
  font-size: clamp(38px, 8vw, 60px);
  line-height: 1.1;
}

.lede {
  margin-top: 10px;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 20px;
}

.source {
  margin-top: 6px;
  color: var(--vermilion);
  font-size: 14px;
}

.rules {
  margin: 34px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: rule;
  text-align: left;
}

.rules li {
  position: relative;
  padding: 11px 0 11px 42px;
  border-top: 1px solid var(--line);
  counter-increment: rule;
}

.rules li:last-child {
  border-bottom: 1px solid var(--line);
}

.rules li::before {
  content: counter(rule);
  position: absolute;
  left: 8px;
  color: var(--vermilion);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.2;
}

.fine {
  margin: 18px 0 28px;
  color: var(--ink-soft);
  font-size: 14px;
}

.intro .button {
  padding: 13px 32px;
  font-size: 16px;
}

.done-verdict {
  margin-top: 20px;
  color: var(--vermilion);
  font-family: var(--serif);
  font-size: 20px;
}

.done h1 {
  margin-top: 4px;
  font-size: clamp(40px, 9vw, 60px);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.done h1 span {
  color: var(--ink-soft);
  font-size: 0.42em;
}

.share {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 26px;
  padding: 18px 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-raised);
}

.share pre {
  margin: 0;
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  text-align: left;
  white-space: pre-wrap;
}

.recap-note {
  margin: 30px 0 0;
}

.recap {
  width: 100%;
  margin: 12px 0 28px;
  padding: 0;
  list-style: none;
  text-align: left;
}

.recap li {
  border-top: 1px solid var(--line);
}

.recap li:last-child {
  border-bottom: 1px solid var(--line);
}

.recap-row {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 10px 6px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
}

.recap-row:hover {
  background: var(--paper-raised);
}

.recap-row img {
  display: block;
  width: 58px;
  height: 58px;
  border-radius: 3px;
  background: var(--line);
  object-fit: cover;
}

.recap-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.recap-text strong {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 500;
}

.recap-text span {
  color: var(--ink-soft);
  font-size: 13px;
}

.recap-points {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- Game layout: map and timeline beside a side panel ---- */

.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(340px, 30vw, 440px);
  height: 100%;
}

.board {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.map {
  flex: 1;
  min-height: 0;
  background: var(--sea);
  cursor: crosshair;
  font-family: var(--sans);
}

.map.leaflet-container {
  background: var(--sea);
}

.map.leaflet-grab,
.map .leaflet-grab {
  cursor: crosshair;
}

.map.is-revealed,
.map.is-revealed .leaflet-grab {
  cursor: grab;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 16px;
  border-left: 1px solid var(--line);
  background: var(--paper-raised);
  overflow-y: auto;
}

/* ---- Pins ---- */

.guess-line {
  pointer-events: none;
}

.pin {
  background: none;
  border: none;
}

.pin span {
  display: block;
  width: 22px;
  height: 22px;
  border: 2px solid var(--paper-raised);
  border-radius: 50% 50% 50% 0;
  box-shadow: 0 1px 4px rgb(34 30 25 / 45%);
  transform: rotate(-45deg);
}

.pin-guess span {
  background: var(--indigo);
}

.pin-answer span {
  background: var(--vermilion);
}

/* ---- Timeline ---- */

.timeline {
  flex: none;
  padding: 10px 26px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-raised);
}

.timeline-label {
  min-height: 22px;
  color: var(--ink-soft);
  font-size: 14px;
  text-align: center;
}

.timeline-label b {
  color: var(--indigo);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.timeline-label .answer-text {
  color: var(--vermilion);
}

.timeline-track {
  position: relative;
  height: var(--thumb);
  margin-top: 4px;
}

.timeline-track::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  transform: translateY(-50%);
}

.band {
  position: absolute;
  top: 50%;
  min-width: 6px;
  height: 10px;
  border-radius: 3px;
  transform: translateY(-50%);
}

.band-hint {
  background: rgb(36 71 107 / 25%);
}

.band-answer {
  background: var(--vermilion);
}

.timeline input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: var(--thumb);
  margin: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.timeline input::-webkit-slider-runnable-track {
  height: var(--thumb);
  background: transparent;
}

.timeline input::-moz-range-track {
  height: var(--thumb);
  background: transparent;
}

.timeline input::-webkit-slider-thumb {
  width: var(--thumb);
  height: var(--thumb);
  border: 3px solid var(--paper-raised);
  border-radius: 50%;
  background: var(--indigo);
  box-shadow: 0 1px 4px rgb(34 30 25 / 45%);
  appearance: none;
  -webkit-appearance: none;
}

.timeline input::-moz-range-thumb {
  width: var(--thumb);
  height: var(--thumb);
  box-sizing: border-box;
  border: 3px solid var(--paper-raised);
  border-radius: 50%;
  background: var(--indigo);
  box-shadow: 0 1px 4px rgb(34 30 25 / 45%);
}

.timeline input:disabled {
  cursor: default;
}

/* Hidden until the player chooses, so the middle isn't mistaken for a guess. */
.is-unset input::-webkit-slider-thumb {
  opacity: 0;
}

.is-unset input::-moz-range-thumb {
  opacity: 0;
}

.ticks {
  position: relative;
  height: 20px;
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.tick {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

/* ---- Photos ---- */

.gallery {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.photo {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ece5d6;
  cursor: zoom-in;
  overflow: hidden;
}

.photo img {
  display: block;
  width: 100%;
  height: clamp(200px, 38vh, 420px);
  object-fit: contain;
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.thumb {
  position: relative;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  background: #ece5d6;
  cursor: pointer;
  overflow: hidden;
}

.thumb.is-active {
  border-color: var(--vermilion);
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb span {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgb(34 30 25 / 72%);
  color: var(--paper-raised);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.5;
}

/* ---- Hints ---- */

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

.hints h2,
.details h2 {
  font-family: var(--serif);
  font-weight: 500;
}

.hints h2 {
  font-size: 17px;
}

.hints-left {
  color: var(--ink-soft);
  font-size: 13px;
}

.hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 5px 0;
  border-top: 1px solid var(--line);
}

.hint-name {
  color: var(--ink-soft);
}

.hint-value {
  font-weight: 600;
  text-align: right;
}

/* ---- Submit and next ---- */

.actions {
  position: sticky;
  bottom: -16px;
  margin: auto -16px -16px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: var(--paper-raised);
}

.actions .button {
  width: 100%;
  padding: 12px;
  font-size: 16px;
}

.needs {
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 13px;
  text-align: center;
}

/* ---- Reveal ---- */

.result {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.result-points {
  color: var(--vermilion);
  font-family: var(--serif);
  font-size: 42px;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.result-max {
  color: var(--ink-soft);
}

.meter-row {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.meter-bar {
  height: 6px;
  margin: 3px 0;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.meter-bar span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--indigo);
}

.meter-note {
  color: var(--ink-soft);
  font-size: 13px;
}

.details {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.details h2 {
  font-size: 21px;
  line-height: 1.2;
}

.title-ja {
  margin-top: -6px;
  color: var(--vermilion);
  font-family: var(--serif);
}

.facts {
  color: var(--ink-soft);
}

.details .photo img {
  height: clamp(160px, 26vh, 300px);
}

.card-text {
  white-space: pre-line;
}

/* ---- Lightbox ---- */

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: none;
  background: rgb(20 17 14 / 94%);
  color: var(--paper-raised);
}

.lightbox::backdrop {
  background: transparent;
}

.lightbox-stage {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  height: 100%;
}

.lightbox-stage img {
  display: block;
  width: 100%;
  height: 100dvh;
  padding: 44px 0;
  object-fit: contain;
}

.lightbox-button {
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  font-size: 40px;
  line-height: 56px;
  height: 56px;
}

.lightbox.is-single .prev,
.lightbox.is-single .next {
  visibility: hidden;
}

.lightbox .close {
  position: absolute;
  top: 0;
  right: 0;
  width: 56px;
}

.lightbox-count {
  position: absolute;
  bottom: 12px;
  left: 50%;
  font-size: 14px;
  transform: translateX(-50%);
}

/* ---- Phones and narrow windows: one scrolling column ---- */

@media (max-width: 860px) {
  body[data-screen="guessing"],
  body[data-screen="reveal"] {
    height: auto;
    min-height: 100%;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 1100;
    padding: 8px 14px;
  }

  .brand {
    font-size: 17px;
  }

  .status {
    gap: 10px;
    font-size: 13px;
  }

  /* Leaves room for the exhibit controls beside the seal. */
  .brand span:last-child {
    display: none;
  }

  /* Let the map, timeline and panel pieces sort into one column. */
  .game {
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: auto;
  }

  .board,
  .panel {
    display: contents;
  }

  .result,
  .details,
  .hints,
  .gallery {
    margin: 0 14px;
  }

  .result {
    order: 1;
    margin-top: 14px;
  }

  .gallery {
    order: 1;
    margin-top: 14px;
  }

  .map {
    flex: none;
    order: 2;
    height: 58vh;
    min-height: 300px;
    border-block: 1px solid var(--line);
  }

  .timeline {
    order: 3;
    padding: 4px 22px 0;
    border: none;
    background: none;
  }

  .hints {
    order: 4;
  }

  .details {
    order: 4;
    border-top: none;
    padding-top: 0;
  }

  .details .gallery {
    margin: 0;
    order: 0;
  }

  .actions {
    order: 5;
    position: sticky;
    bottom: 0;
    z-index: 1000;
    margin: auto 0 0;
    padding: 10px 14px 12px;
  }

  .photo img {
    height: 40vh;
  }

  .tick {
    font-size: 11px;
  }

  .lightbox-stage {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
  }

  .lightbox-button {
    font-size: 32px;
  }

  .intro,
  .done {
    padding: 32px 16px 48px;
  }

  .recap-row {
    gap: 10px;
  }
}
