/* Shared shell for the two history games. */
.history-arcade, .history-fieldwork {
  --night: #12152b;
  --light: #f8f5ff;
  --soft: #c5c8e2;
  --edge: #ffffff24;
  --highlight: #d8f5a0;
  color: var(--light);
  min-height: 100vh;
  background: radial-gradient(ellipse at 85% 0, #32265d, transparent 55%),
    radial-gradient(ellipse at 0 100%, #16384b, transparent 55%), var(--night);
  color-scheme: dark;
}
.history-fieldwork {
  --night: #0d1b28;
  --highlight: #a8efda;
  background: radial-gradient(ellipse at 0 0, #254757, transparent 62%), var(--night);
}
:is(.history-arcade,.history-fieldwork) header {
  height: 65px;
  padding-inline: clamp(14px, 4vw, 50px);
  border-color: var(--edge);
}
:is(.history-arcade,.history-fieldwork) .brand { color: var(--light); }
:is(.history-arcade,.history-fieldwork) .brand small { color: var(--soft); }
:is(.history-arcade,.history-fieldwork) .brand-mark { background: #ffffff20; }
:is(.history-arcade,.history-fieldwork) .history-main {
  max-width: 1320px;
  padding-inline: clamp(10px, 3vw, 38px);
}
:is(.history-arcade,.history-fieldwork) .history-nav-link,
:is(.history-arcade,.history-fieldwork) footer a { color: var(--light); }
:is(.history-arcade,.history-fieldwork) .game-breadcrumb { display: none; }
:is(.history-arcade,.history-fieldwork) .history-intro {
  padding: 15px 0 9px;
  margin-bottom: 5px;
  display: flex;
  flex-direction: row;
  align-items: end;
  gap: 9px;
}
:is(.history-arcade,.history-fieldwork) .history-intro .eyebrow { margin-bottom: 5px; color: var(--soft); }
:is(.history-arcade,.history-fieldwork) .history-intro h1 { font-size: clamp(25px, 4vw, 38px); margin: 0 0 4px; letter-spacing: -.6px; }
:is(.history-arcade,.history-fieldwork) .intro-copy { color: var(--soft); font-size: 12px; }
:is(.history-arcade,.history-fieldwork) #history-score { color: var(--highlight); font: 700 clamp(23px, 3.6vw, 38px)/1 var(--sans); }
:is(.history-arcade,.history-fieldwork) #history-score small { color: var(--soft); }
:is(.history-arcade,.history-fieldwork) .history-controls { margin-bottom: 12px; }
:is(.history-arcade,.history-fieldwork) .secondary {
  color: var(--light);
  background: #ffffff0c;
  border: 1px solid var(--edge);
  box-shadow: none;
}
:is(.history-arcade,.history-fieldwork) .secondary:hover { background: #ffffff25; }
:is(.history-arcade,.history-fieldwork) .history-modes [aria-current="page"] {
  background: var(--highlight);
  color: var(--accent-ink);
  border-color: transparent;
}
:is(.history-arcade,.history-fieldwork) footer { margin-top: 16px; border-color: var(--edge); color: var(--soft); }
:is(.history-arcade,.history-fieldwork) footer p { color: var(--soft); }

/* What Came First */
.first-board {
  position: relative;
  isolation: isolate;
  overflow: clip;
  border: 1px solid var(--edge);
  border-radius: 24px;
  padding: clamp(12px, 2.2vw, 26px);
  text-align: center;
  background: linear-gradient(125deg, #26294f, #34355c 58%, #25284f);
}
.first-board::before, .first-board::after {
  content: '';
  position: absolute;
  width: 70%;
  height: 115%;
  border-radius: 45% 55% 70% 30% / 64% 36% 64% 36%;
  z-index: -1;
  pointer-events: none;
  animation: drift 14s ease-in-out infinite alternate;
}
.first-board::before { left: -29%; top: -30%; background: #8b72e74c; }
.first-board::after { right: -36%; bottom: -49%; background: #529cbd49; animation-delay: -7s; }
@keyframes drift { to { transform: translate(11%, 6%) rotate(9deg); } }
.first-round-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 7px;
  padding-bottom: 4px;
}
.first-hud-label {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  color: var(--soft);
  font: 700 10px var(--sans);
  letter-spacing: .08em;
}
.first-hud-label strong { font-size: 16px; color: var(--light); letter-spacing: 0; }
.first-hearts { display: flex; gap: 4px; color: var(--accent); font: 23px/1 var(--sans); }
.heart-empty { color: #cebadb; }
.heart-hit { animation: heart-hit .35s ease-out; }
@keyframes heart-hit { 40% { transform: translateX(-5px) scale(1.12); } 70% { transform: translateX(4px); } }
.life-loss {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  pointer-events: none;
  background: radial-gradient(ellipse at center, #080d0966 0%, transparent 58%);
  animation: life-window 1.9s both;
}
.life-loss-panel {
  width: min(320px, 100%);
  border: 1px solid var(--glass-edge);
  border-radius: 22px;
  padding: 20px 22px 18px;
  background: radial-gradient(ellipse at top, #829d5022, transparent 75%), var(--glass);
  backdrop-filter: blur(8px);
  box-shadow: 0 20px 64px #0008, var(--glass-light);
  text-align: center;
  animation: life-pop .42s both;
}
.life-loss-panel strong { display: block; margin-top: 4px; color: var(--ink); font: 600 14px var(--sans); }
.life-loss-hearts { display: flex; justify-content: center; gap: 12px; margin: 6px 0 2px; }
.life-loss-hearts svg { width: min(62px, 23%); overflow: visible; fill: var(--accent); }
.life-full { filter: drop-shadow(0 2px 8px #c7f47b28); }
.life-loss-hearts .life-empty { fill: #ffffff0a; stroke: #aeb9b060; stroke-width: 2; }
.life-loss-hearts .life-cracked { fill: var(--accent-hover); }
.life-half { transform-box: view-box; transform-origin: center; animation: life-break .76s .52s cubic-bezier(.3,.6,.6,1) both; }
.life-left { --shard-x: -15px; --shard-turn: -25deg; }
.life-right { --shard-x: 15px; --shard-turn: 26deg; }
.life-crack {
  fill: none;
  stroke: var(--accent-ink);
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 54;
  animation: life-crack .86s .22s both;
}
@keyframes life-pop {
  0% { transform: translateY(12px) scale(.84); }
  62% { transform: translateY(-1px) scale(1.045); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes life-window { 0%, 100% { opacity: 0; } 10%, 81% { opacity: 1; } }
@keyframes life-break { to { opacity: 0; transform: translate(var(--shard-x), 30px) rotate(var(--shard-turn)); } }
@keyframes life-crack {
  0% { stroke-dashoffset: 54; }
  33% { opacity: 1; stroke-dashoffset: 0; }
  100% { opacity: 0; stroke-dashoffset: 0; }
}
.first-prompt h2 { font: 700 clamp(25px, 4.5vw, 49px)/1.03 var(--sans); letter-spacing: -.045em; margin: 14px 0 5px; }
.first-instruction { font-size: 14px; margin: 0 0 13px; color: var(--highlight); }
.miss-message { color: #ffb6c4; }
.first-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: clamp(5px, 1.5vw, 16px);
  align-items: stretch;
  max-width: 960px;
  margin: 0 auto;
}
.first-or {
  align-self: center;
  display: grid;
  place-items: center;
  width: clamp(22px, 3.7vw, 40px);
  aspect-ratio: 1;
  background: #0d123774;
  border: 1px solid var(--edge);
  border-radius: 50%;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
}
.first-choice {
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-align: left;
  padding: 0;
  background: var(--surface-raised);
  border: 1px solid transparent;
  border-radius: 18px;
  overflow: hidden;
  color: var(--light);
  box-shadow: 0 12px 30px #10122343;
}
button.first-choice { width: 100%; transition: transform .45s cubic-bezier(.22,1,.36,1), box-shadow .45s, background .45s; }
button.first-choice:hover { transform: translateY(-5px); box-shadow: 0 20px 44px #090e3766; background: var(--surface-hover); }
button.first-choice:active { transform: translateY(-1px) scale(.985); }
button.first-choice:focus-visible { outline-color: var(--accent); }
.deal-board .first-choice { animation: deal .36s cubic-bezier(.2,.8,.2,1) backwards; }
.deal-board .first-choice:last-child { animation-delay: 70ms; }
@keyframes deal { from { opacity: .15; transform: translateY(12px) scale(.98); } }
.first-art {
  display: grid;
  place-items: center;
  width: 100%;
  height: clamp(115px, 30vh, 275px);
  overflow: hidden;
  background: var(--paper);
}
.first-image-frame { height: 100%; width: 100%; overflow: hidden; }
.first-image-frame[style] { height: auto; }
.first-art img { display: block; width: 100%; height: 100%; object-fit: contain; }
.first-image-frame[style] img { height: auto; }
.first-symbol {
  color: #343e5d;
  background: repeating-radial-gradient(circle at 46% 53%, transparent 0 34px, #ffffff40 35px 36px), #b9c3e5;
}
.first-symbol svg { width: clamp(52px, 10vw, 108px); padding: 12px; border: 1px solid currentColor; border-radius: 26%; background: #ffffff54; }
.theme-video-games { background-color: #c4afea; color: #463373; }
.theme-people { background-color: #eac9bb; color: #733e41; }
.theme-architecture { background-color: #b6d7d0; color: #24535b; }
.theme-paintings { background-color: #e9b9d3; color: #733460; }
.theme-events,.theme-sports { background-color: #e4e6ad; color: #515a31; }
.first-card-body { display: flex; flex: 1; flex-direction: column; gap: 4px; padding: clamp(8px, 1.5vw, 16px); }
.first-category { color: #c7caff; font-size: 9px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.first-name { font: 700 clamp(16px, 2.6vw, 27px)/1.12 var(--sans); overflow-wrap: anywhere; }
.first-event { color: var(--soft); font-size: 12px; line-height: 1.35; }
.first-revealed.is-earlier { border-color: var(--highlight); box-shadow: 0 0 0 2px #d8f5a032; }
.first-revealed.is-missed { border-color: #ff9baf; }
.first-revealed .first-art { height: clamp(100px, 21vh, 185px); }
.first-reveal-date { display: block; font: 700 28px/1.1 var(--sans); color: var(--highlight); margin-top: 4px; animation: date-pop .27s ease-out; }
.first-reveal-date small { display: block; margin-top: 3px; font: 700 9px/1.4 var(--sans); letter-spacing: .06em; }
@keyframes date-pop { from { transform: translateY(4px); opacity: .35; } }
.first-story { font-size: 12px; line-height: 1.4; }
.first-source { color: var(--soft); font-size: 10px; line-height: 1.4; }
.first-source a,.first-timeline a { color: var(--accent); text-underline-offset: 2px; }
.first-board .first-next { margin: 11px auto 0; max-width: 280px; min-height: 42px; padding: 8px 13px; color: var(--accent-ink); background: var(--highlight); box-shadow: none; }
.first-board .first-next {
  border-radius: 999px;
  padding: 13px 22px;
  transition: transform .4s cubic-bezier(.22,1,.36,1), box-shadow .4s;
}
.first-next:hover { transform: translateY(-2px); box-shadow: 0 8px 26px #c7f47b26; }
.first-board .first-next:active { transform: scale(.96); }
.first-next span { transition: transform .4s cubic-bezier(.22,1,.36,1); }
.first-next:hover span { transform: translateX(5px); }

/* Keep the photograph and field notes together during the photo reveal. */
.history-revealing .photo-panel { view-transition-name: field-photo; }
.history-revealing .guess-panel { view-transition-name: field-notes; }
.history-revealing #history-score { view-transition-name: earned-score; }
::view-transition-group(*) { animation-duration: .65s; animation-timing-function: cubic-bezier(.22,1,.36,1); }
::view-transition { pointer-events: none; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
.first-results { max-width: 790px; margin-inline: auto; background: var(--surface); border-color: var(--edge); padding: clamp(13px, 2vw, 23px); }
.first-result-summary { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 14px; }
.first-result-summary .eyebrow { color: var(--highlight); margin-bottom: 4px; }
.first-result-summary h2 { margin: 0; }
.first-result-stats { margin: 5px 0 0; color: var(--soft); font-size: 12px; }
.first-result-summary .primary { width: auto; min-height: 40px; gap: 12px; padding: 6px 10px 6px 13px; color: var(--accent-ink); background: var(--highlight); box-shadow: none; }
.first-result-summary .primary:hover { background: var(--accent-hover); box-shadow: none; }
.first-results h3 { font: 21px var(--serif); margin: 15px 0 6px; }
.first-timeline { list-style: none; padding: 0; margin: 0; border-block: 1px solid var(--edge); }
.first-timeline li { display: grid; grid-template-columns: 82px minmax(0, 1fr) 32px; gap: 8px; align-items: center; padding: 3px 1px; }
.first-timeline li + li { border-top: 1px solid var(--edge); }
.first-timeline li div { display: grid; gap: 1px; }
.first-timeline strong { font-size: 13px; line-height: 1.25; }
.first-timeline .first-event { font-size: 11px; }
.first-year { color: var(--highlight); font: 16px/1.25 var(--serif); font-variant-numeric: tabular-nums; }
.first-timeline a { display: grid; place-items: center; height: 30px; border-radius: 6px; font-size: 15px; text-decoration: none; }
.first-timeline a:hover { background: #ffffff14; color: #f1f5ff; }

/* Time & Place */
.history-fieldwork .history-date label,.history-fieldwork .history-date small { color: var(--soft); }
.history-fieldwork .history-date input,.history-fieldwork #photo-year-number { color: var(--light); background: var(--paper); border-color: var(--edge); }
.history-fieldwork .photo-grid { gap: 12px; align-items: stretch; }
.history-fieldwork .history-panel { background: var(--surface); border-color: var(--edge); padding: clamp(12px, 1.7vw, 21px); }
.history-fieldwork .photo-panel { display: flex; flex-direction: column; }
.history-fieldwork .history-round { margin-bottom: 10px; }
.history-fieldwork .history-round strong,.history-fieldwork .history-label { color: var(--highlight); }
.history-fieldwork .photo-frame {
  display: grid;
  place-items: safe center;
  container-type: size;
  height: clamp(240px, 51vh, 570px);
  max-height: none;
  background: var(--paper);
  border: 1px solid #ffffff16;
}
.history-fieldwork .historic-photo-view {
  width: calc(min(100cqw, 100cqh * var(--photo-ratio, 1.5)) * var(--photo-zoom, 1));
}
.history-fieldwork .photo-tools { margin-top: 8px; }
.history-fieldwork #photo-zoom-level,.history-fieldwork .history-instruction,.history-fieldwork .range-ends { color: var(--soft); }
.history-fieldwork .photo-tools button { min-height: 34px; padding: 7px 10px; }
.history-fieldwork .guess-panel h2 { margin: 2px 0 8px; }
.photo-year-control {
  --year-progress: .5;
  --thumb-size: 22px;
  position: relative;
  padding-top: 20px;
}
.photo-year-bubble {
  position: absolute;
  top: 0;
  left: calc(var(--year-progress) * (100% - var(--thumb-size)) + var(--thumb-size) / 2);
  padding: 1px 6px 2px;
  border-radius: 5px;
  color: var(--accent-ink);
  background: var(--highlight);
  font: 700 11px var(--sans);
  translate: -50% 0;
  pointer-events: none;
}
.history-fieldwork #photo-year {
  appearance: none;
  display: block;
  height: 26px;
  margin: 0;
  border-radius: 999px;
  background: linear-gradient(to right, var(--highlight) calc(var(--year-progress) * 100%), #525e53 0) center / 100% 5px no-repeat;
}
.history-fieldwork #photo-year::-webkit-slider-thumb {
  appearance: none;
  width: var(--thumb-size);
  height: var(--thumb-size);
  border: 4px solid var(--accent);
  border-radius: 50%;
  background: var(--accent-surface);
  box-shadow: 0 0 0 3px #c7f47b20;
}
.history-fieldwork #photo-year::-moz-range-thumb {
  box-sizing: border-box;
  width: var(--thumb-size);
  height: var(--thumb-size);
  border: 4px solid var(--accent);
  border-radius: 50%;
  background: var(--accent-surface);
  box-shadow: 0 0 0 3px #c7f47b20;
}
.history-fieldwork #photo-year:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }
.photo-context {
  margin: 8px 0 0;
  padding: 7px 9px;
  border-inline-start: 2px solid var(--highlight);
  border-radius: 4px;
  background: #ffffff08;
  color: var(--soft);
  font-size: 12px;
  line-height: 1.35;
}
.photo-context strong { color: var(--highlight); }
.history-fieldwork .place-fieldset { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 10px; }
.history-fieldwork .place-option { background: #ffffff0a; border-color: var(--edge); line-height: 1.25; font-size: 12px; }
.history-fieldwork .place-option:has(:checked) { color: var(--ink); background: var(--accent-surface); border-color: var(--highlight); }
.history-fieldwork :is(#photo-year,.place-option input) { accent-color: var(--highlight); }
.history-fieldwork .history-instruction { font-size: 11px; margin: 9px 0; }
.history-fieldwork .photo-clues { margin: 8px 0 10px; }
.history-fieldwork .photo-hint,.history-fieldwork .history-reveal { background: var(--surface-raised); }
.history-fieldwork .photo-answer,.history-fieldwork .history-credit a,.history-fieldwork .history-result-list a { color: var(--highlight); }
.history-fieldwork .history-credit { color: var(--soft); }
.history-fieldwork .score-breakdown div { border-color: var(--edge); }
.history-fieldwork .history-result-list li { background: var(--surface-raised); }
.history-fieldwork .primary { color: var(--accent-ink); background: var(--highlight); box-shadow: none; min-height: 45px; }
.history-fieldwork .primary:disabled { color: var(--muted); background: var(--surface-raised); }
.history-fieldwork #lock-photo { margin-top: 8px; }
.history-fieldwork .history-reveal { animation: deal .28s ease-out; }
@media (min-width: 1000px) {
  .history-arcade .history-main { position: relative; }
  .history-arcade .history-controls { position: absolute; top: 29px; left: 50%; transform: translateX(-50%); }
  .history-arcade .history-intro { margin-bottom: 11px; }
}
@media (min-width: 561px) and (max-height: 760px) {
  .deal-board .first-art { height: clamp(115px, 25vh, 190px); }
  .reveal-board .first-art { height: clamp(90px, 19svh, 150px); }
}
@media (max-width: 760px) {
  :is(.history-arcade,.history-fieldwork) .history-total { display: block; }
  .history-fieldwork .photo-frame { height: clamp(125px, 23svh, 215px); }
  .history-fieldwork .history-round { margin-bottom: 6px; }
  .history-fieldwork .history-controls { gap: 6px; margin-bottom: 8px; }
  .history-fieldwork :is(.history-modes a, .history-date input, .history-date button) { min-height: 34px; padding-block: 6px; }
  .history-fieldwork .photo-grid { gap: 8px; }
  .history-fieldwork .photo-tools { margin-top: 5px; }
  .history-fieldwork .guess-panel h2 { font-size: 24px; }
}
@media (max-width: 560px) {
  :is(.history-arcade,.history-fieldwork) header { height: 56px; }
  :is(.history-arcade,.history-fieldwork) .intro-copy { display: none; }
  .first-choice { border-radius: 11px; }
  .first-art { height: clamp(105px, 22vh, 155px); }
  .first-streak { display: none; }
  .first-story { font-size: 11px; }
  .first-timeline li { grid-template-columns: 57px minmax(0, 1fr) 27px; gap: 6px; }
  .first-year { font-size: 14px; }
}
@media (max-width: 760px) and (max-height: 700px) {
  .history-fieldwork .photo-frame { height: clamp(112px, 19svh, 145px); }
}
@media (prefers-reduced-motion: reduce) {
  .first-board::before,.first-board::after,.deal-board .first-choice,.first-reveal-date,.heart-hit,.history-fieldwork .history-reveal { animation: none; }
  button.first-choice { transition: none; }
  button.first-choice:hover { transform: none; }
  .first-next, .first-next span { transition: none; }
  .first-next:hover, .first-next:hover span { transform: none; }
  .life-loss, .life-loss-panel, .life-half, .life-crack { animation: none; }
  .life-cracked { opacity: .5; filter: none; }
}
