:root {
  color-scheme: dark;
  --ink: #2d1c0d;
  --paper: #efd9a6;
  --paper-dark: #7a551e;
  --gold: #f3d57a;
  --green: #d6f06c;
  --shadow: rgba(3, 8, 4, 0.72);
  --stage-padding: clamp(32px, 5vw, 112px);
  --panel-gap: clamp(18px, 1.6vw, 32px);
  --center-width: clamp(560px, 38vw, 730px);
  --journal-width: clamp(520px, 32vw, 650px);
  --stage-width: calc(var(--center-width) + var(--panel-gap) + var(--journal-width));
  --center-left: max(18px, calc((100vw - var(--stage-width)) / 2));
  --journal-left: calc(var(--center-left) + var(--center-width) + var(--panel-gap));
  --button-row-height: clamp(68px, 9dvh, 92px);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--paper);
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 235, 156, 0.1), rgba(0, 0, 0, 0.52) 72%),
    linear-gradient(90deg, rgba(0, 10, 5, 0.7), transparent 18% 82%, rgba(0, 10, 5, 0.72)),
    url("assets/jungle-background.webp") center / cover fixed;
}

button,
input {
  font: inherit;
}

.app-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  place-content: center;
  gap: 18px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 235, 156, 0.06), rgba(0, 0, 0, 0.7) 72%),
    url("assets/jungle-background.webp") center / cover fixed;
  backdrop-filter: blur(6px);
  transition: opacity 0.5s ease;
}

.app-loader.is-done {
  opacity: 0;
  pointer-events: none;
}

.app-loader-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 239, 184, 0.2);
  border-top-color: #f3d57a;
  border-radius: 50%;
  animation: aranya-spin 0.85s linear infinite;
}

.app-shell.is-hidden {
  opacity: 0;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
  transition: opacity 0.4s ease;
}

.brand-logo {
  position: absolute;
  left: var(--stage-padding);
  top: clamp(4px, 0.6dvh, 10px);
  z-index: 5;
  width: clamp(360px, 26vw, 540px);
  max-width: 36vw;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 16px 16px rgba(0, 0, 0, 0.78));
}

.stats-counter {
  position: absolute;
  left: calc(var(--center-left) + (var(--center-width) - min(500px, 31vw)) / 2);
  top: clamp(167px, 23.5dvh, 205px);
  z-index: 4;
  width: min(500px, 31vw);
  aspect-ratio: 1422 / 281;
  filter: drop-shadow(0 14px 14px rgba(0, 0, 0, 0.58));
}

.stats-counter img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
}

.stats-counter p {
  position: absolute;
  inset: 30% 2% 24% 15%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 5%;
  margin: 0;
  color: #f8df92;
  text-align: center;
  text-shadow: 0 2px 2px #171006, 0 0 7px rgba(0, 0, 0, 0.72);
  font-weight: 700;
  line-height: 1.05;
}

.stats-counter span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(12px, 0.95vw, 17px);
}

.stats-counter b {
  margin-right: 5px;
  color: #ffe9a6;
  font-size: 1.35em;
}

.leaderboard-button {
  position: absolute;
  left: 16%;
  bottom: 15%;
  z-index: 7;
  width: clamp(58px, 8vw, 84px);
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 12px 12px rgba(0, 0, 0, 0.62));
}

.leaderboard-button img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.leaderboard-button:active {
  transform: translateY(2px);
}

.game-board {
  position: absolute;
  inset: 0;
  display: block;
  overflow: visible;
}

.expedition-column {
  display: block;
  position: absolute;
  left: var(--center-left);
  top: clamp(222px, 30dvh, 300px);
  min-width: 0;
  min-height: 0;
  width: var(--center-width);
  height: auto;
}

.center-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  aspect-ratio: 1048 / 941;
  height: auto;
  max-height: min(53dvh, 560px);
  filter: drop-shadow(0 24px 22px var(--shadow));
}

.journal-panel {
  position: absolute;
  left: var(--journal-left);
  top: 50%;
  width: var(--journal-width);
  height: auto;
  aspect-ratio: 632 / 941;
  transform: translateY(-50%);
  min-width: 0;
  min-height: 0;
  overflow: visible;
  filter: drop-shadow(0 24px 22px var(--shadow));
}

.panel-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.center-panel .panel-art {
  inset: -5% -4% -6%;
  width: 108%;
  height: 111%;
}

.journal-panel .panel-art {
  object-fit: fill;
}

.center-content {
  position: absolute;
  inset: 13% 16% 19%;
  display: grid;
  place-items: center;
  color: var(--ink);
  overflow: visible;
}

.board-kicker {
  margin: 0;
  text-align: center;
  text-transform: uppercase;
  font-weight: 700;
  font-size: clamp(12px, 1.1vw, 18px);
  color: #4a3515;
}

.board-kicker::before,
.board-kicker::after {
  content: " ✤ ";
  color: #586023;
}

.upload-drop {
  position: relative;
  display: grid;
  place-items: center;
  justify-self: center;
  align-self: center;
  width: min(88%, 520px);
  aspect-ratio: 743 / 364;
  height: auto;
  max-height: 70%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  cursor: pointer;
  text-align: center;
}

.upload-drop.has-image {
  cursor: default;
}

.upload-drop.is-disabled {
  cursor: wait;
  pointer-events: none;
}

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

.preview-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  display: none;
  width: var(--preview-width, 420px);
  height: var(--preview-height, 236px);
  transform: translate(-50%, -50%);
  z-index: 2;
  overflow: visible;
  pointer-events: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#previewImage {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border: 7px solid rgba(255, 236, 166, 0.98);
  border-radius: 10px;
  background: transparent;
  box-shadow: 0 14px 18px rgba(46, 29, 8, 0.38);
}

.image-loader {
  position: absolute;
  inset: 7px;
  display: none;
  place-items: center;
  z-index: 12;
  border-radius: 10px;
  background: rgba(29, 20, 8, 0.38);
  pointer-events: none;
}

.image-loader::before {
  content: "";
  width: clamp(34px, 4vw, 54px);
  height: clamp(34px, 4vw, 54px);
  border: 4px solid rgba(255, 239, 184, 0.35);
  border-top-color: #fff4bd;
  border-radius: 50%;
  animation: aranya-spin 0.85s linear infinite;
}

.upload-drop.is-loading .image-loader {
  display: grid;
}

@keyframes aranya-spin {
  to {
    transform: rotate(360deg);
  }
}

.upload-drop.has-image .preview-wrap {
  display: block;
}

.clear-image {
  position: absolute;
  top: -18px;
  right: -18px;
  display: none;
  place-items: center;
  width: clamp(32px, 3vw, 44px);
  height: clamp(32px, 3vw, 44px);
  border: 3px solid rgba(255, 232, 158, 0.95);
  border-radius: 50%;
  color: #fff6cf;
  background: #5f2618;
  box-shadow: 0 7px 10px rgba(0, 0, 0, 0.52), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  cursor: pointer;
  z-index: 20;
  line-height: 1;
  font-size: clamp(23px, 2.4vw, 32px);
  font-weight: 700;
}

.upload-drop.has-image .clear-image {
  display: grid;
}

.upload-drop.is-loading .clear-image {
  display: none;
}

.upload-art {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  z-index: 1;
  pointer-events: auto;
  filter: drop-shadow(0 8px 9px rgba(46, 29, 8, 0.28));
}

.upload-label {
  position: absolute;
  left: 50%;
  top: 59%;
  transform: translateX(-50%);
  z-index: 2;
  color: #2e2511;
  font-size: clamp(17px, 1.8vw, 28px);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 239, 178, 0.8);
  pointer-events: auto;
  white-space: nowrap;
}

.upload-drop.has-image .upload-art,
.upload-drop.has-image .upload-label {
  display: none;
}

.name-form,
.name-plate {
  position: absolute;
  left: 50%;
  bottom: clamp(11px, 3.2%, 24px);
  z-index: 8;
  width: min(48%, 300px);
  transform: translateX(-50%);
}

.name-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.name-form[hidden],
.name-plate[hidden],
.user-actions[hidden] {
  display: none;
}

.name-input {
  min-width: 0;
  height: clamp(34px, 4.5dvh, 44px);
  border: 2px solid rgba(69, 45, 16, 0.46);
  border-radius: 8px;
  padding: 0 12px;
  color: #2c1d0c;
  background: rgba(255, 238, 177, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 4px 8px rgba(39, 24, 6, 0.16);
  outline: none;
  font-size: clamp(15px, 1.25vw, 19px);
  font-weight: 700;
}

.name-input::placeholder {
  color: rgba(45, 28, 13, 0.64);
}

.name-input:focus {
  border-color: rgba(79, 61, 24, 0.88);
  background: rgba(255, 238, 177, 0.34);
}

.name-save {
  height: clamp(34px, 4.5dvh, 44px);
  border: 2px solid rgba(255, 232, 158, 0.86);
  border-radius: 8px;
  padding: 0 13px;
  color: #fff0bd;
  background: rgba(75, 42, 17, 0.76);
  box-shadow: 0 5px 8px rgba(39, 24, 6, 0.25);
  cursor: pointer;
  font-weight: 700;
}

.name-plate {
  margin: 0;
  overflow: hidden;
  color: rgba(45, 28, 13, 0.82);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(16px, 1.3vw, 21px);
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(255, 239, 178, 0.7);
}

.user-actions {
  position: absolute;
  left: 50%;
  bottom: clamp(-32px, -3%, -12px);
  z-index: 8;
  transform: translateX(-50%);
  display: flex;
  gap: clamp(8px, 1vw, 16px);
  justify-content: center;
  align-items: center;
}

.action-btn {
  display: block;
  width: clamp(40px, 5.5vw, 66px);
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.action-btn img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
}
.action-btn:active {
  transform: translateY(2px);
}

.journal-content h2 {
  margin: 0;
  color: #4c2f0e;
  text-transform: uppercase;
  text-align: center;
  font-size: clamp(16px, 2.4dvh, 25px);
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 0 rgba(255, 241, 194, 0.75);
}

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

.journal-content {
  position: absolute;
  top: 17%;
  left: 47%;
  width: 60%;
  height: 68%;
  transform: translateX(-50%);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(6px, 0.8dvh, 11px);
  color: var(--ink);
  background: transparent;
  overflow: hidden;
}

.journal-content h3 {
  margin: 0;
  color: #50340e;
  text-align: center;
  text-transform: uppercase;
  font-size: clamp(11px, 1.65dvh, 16px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.journal-text {
  min-height: 0;
  padding: clamp(8px, 1.2dvh, 14px) 8% 4% 5%;
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  color: #2f2211;
  background: transparent;
  font-size: clamp(15px, 1.75dvh, 20px);
  line-height: 1.58;
  overflow-wrap: anywhere;
}

.journal-text,
.journal-text * {
  text-align: left;
}

.journal-text h1,
.journal-text h2,
.journal-text h3,
.journal-text h4 {
  margin: 0.6em 0 0.25em;
  color: #4c2f0e;
  line-height: 1.25;
}
.journal-text h1 { font-size: 1.3em; }
.journal-text h2 { font-size: 1.15em; }
.journal-text h3 { font-size: 1.05em; }
.journal-text h4 { font-size: 1em; }
.journal-text h1:first-child,
.journal-text h2:first-child,
.journal-text h3:first-child,
.journal-text h4:first-child { margin-top: 0; }

.journal-text p { margin: 0.4em 0; }
.journal-text p:first-child { margin-top: 0; }

.journal-text ul,
.journal-text ol {
  margin: 0.4em 0;
  padding-left: 1.4em;
}
.journal-text li { margin: 0.15em 0; }

.journal-text strong { color: #3b2510; }

.journal-text hr {
  border: none;
  border-top: 1px solid #c9a96e;
  margin: 0.6em 0;
}

.journal-text::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.journal-text.is-waiting::after {
  content: "|";
  animation: aranya-blink 0.75s steps(1) infinite;
}

@keyframes aranya-blink {
  50% {
    opacity: 0;
  }
}

.action-row {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
  gap: clamp(10px, 1.3vw, 20px);
  align-items: center;
  width: 100%;
  height: var(--button-row-height);
  margin: clamp(-18px, -1.8dvh, -8px) 0 0;
  overflow: visible;
}

.action-button {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  padding: 0;
  color: #ffe8a9;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 12px 11px rgba(0, 0, 0, 0.65));
}

.action-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.action-button span {
  position: absolute;
  inset: 24% 8% 22% 22%;
  display: grid;
  align-content: center;
  text-align: center;
  pointer-events: none;
}

.rescue span {
  inset: 24% 8% 22% 18%;
}

.action-button b,
.action-button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-button b {
  text-transform: uppercase;
  font-size: clamp(13px, 1.12vw, 20px);
  line-height: 1.05;
  text-shadow: 0 2px 2px #1b1108;
}

.action-button small {
  margin-top: 4px;
  font-size: clamp(9px, 0.68vw, 12px);
  color: #fff0bd;
}

.action-button:active {
  transform: translateY(3px);
}

.action-button:disabled {
  opacity: 0.48;
  cursor: wait;
}

.leaderboard-modal[hidden] {
  display: none;
}

.leaderboard-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}

.leaderboard-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 229, 144, 0.14), transparent 34%),
    rgba(5, 9, 4, 0.74);
  backdrop-filter: blur(2px);
}

.leaderboard-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: clamp(10px, 1.4dvh, 16px);
  width: min(760px, 94vw);
  height: min(790px, 90dvh);
  padding: clamp(22px, 3vw, 34px);
  border: 7px solid rgba(66, 39, 13, 0.94);
  border-radius: 8px;
  color: #2d1c0d;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 244, 196, 0.38), transparent 24%),
    radial-gradient(circle at 86% 82%, rgba(113, 67, 20, 0.22), transparent 28%),
    linear-gradient(rgba(239, 217, 166, 0.76), rgba(213, 174, 101, 0.8)),
    url("assets/parchment-texture.webp") center / cover;
  background-blend-mode: screen, multiply, normal, multiply;
  box-shadow: 0 28px 38px rgba(0, 0, 0, 0.68), inset 0 0 0 3px rgba(255, 233, 166, 0.5);
  overflow: hidden;
}

.leaderboard-dialog::before {
  content: "";
  position: absolute;
  inset: 12px;
  z-index: -1;
  border: 3px solid rgba(255, 229, 148, 0.34);
  border-radius: 5px;
  background:
    radial-gradient(circle at 24% 22%, rgba(255, 246, 206, 0.34), transparent 30%),
    linear-gradient(rgba(238, 211, 145, 0.74), rgba(220, 181, 106, 0.82)),
    url("assets/parchment-texture.webp") center / cover;
  background-blend-mode: screen, normal, multiply;
}

.leaderboard-dialog h2 {
  margin: 0;
  padding-right: 42px;
  color: #4a2c0c;
  text-transform: uppercase;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.05;
  text-align: center;
  text-shadow: 0 1px 0 rgba(255, 241, 194, 0.88);
}

.leaderboard-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2px solid rgba(82, 51, 17, 0.55);
  border-radius: 50%;
  color: #fff2c5;
  background: rgba(91, 38, 19, 0.88);
  cursor: pointer;
  font-size: 25px;
  font-weight: 700;
  line-height: 1;
}

.leaderboard-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 clamp(4px, 1vw, 16px);
}

.leaderboard-tab {
  min-width: 0;
  border: 2px solid rgba(78, 48, 14, 0.74);
  border-radius: 8px;
  padding: 10px 8px;
  color: #f7e2a1;
  background:
    linear-gradient(rgba(98, 57, 19, 0.9), rgba(55, 31, 12, 0.92));
  cursor: pointer;
  font-weight: 700;
  text-shadow: 0 2px 2px #1b1108;
  box-shadow: 0 6px 8px rgba(55, 31, 12, 0.22), inset 0 1px 0 rgba(255, 239, 178, 0.22);
}

.leaderboard-tab.is-active {
  color: #2b1b0b;
  background:
    linear-gradient(rgba(243, 213, 122, 0.96), rgba(191, 135, 49, 0.9)),
    url("assets/parchment-texture.webp") center / cover;
  text-shadow: 0 1px 0 rgba(255, 241, 194, 0.8);
}

.leaderboard-panel {
  min-height: 0;
  height: 100%;
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.leaderboard-panel[hidden] {
  display: none;
}

.leaderboard-panel::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.record-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.record-summary p {
  margin: 0;
  padding: 12px 8px;
  border: 2px solid rgba(75, 47, 15, 0.5);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 242, 193, 0.42), rgba(228, 189, 111, 0.2)),
    url("assets/parchment-texture.webp") center / cover;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 249, 218, 0.35);
}

.record-summary span,
.record-summary b {
  display: block;
}

.record-summary span {
  margin-bottom: 4px;
  font-size: 12px;
  text-transform: uppercase;
}

.record-summary b {
  font-size: clamp(20px, 3vw, 30px);
}

.leaderboard-muted {
  margin: 14px 0 8px;
  color: rgba(45, 28, 13, 0.76);
  font-weight: 700;
}

.recent-runs,
.leaderboard-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recent-runs li,
.leaderboard-list li {
  display: grid;
  align-items: center;
  min-height: 44px;
  border: 2px solid rgba(75, 47, 15, 0.38);
  border-radius: 8px;
  padding: 9px 12px;
  background:
    linear-gradient(rgba(255, 242, 193, 0.38), rgba(228, 189, 111, 0.18)),
    url("assets/parchment-texture.webp") center / cover;
}

.recent-runs li {
  padding: 0;
  overflow: hidden;
}

.leaderboard-list li {
  grid-template-columns: 52px minmax(0, 1fr) minmax(150px, auto);
  gap: 10px;
}

.leaderboard-list li.is-me {
  border-color: rgba(93, 104, 35, 0.72);
  background: rgba(215, 240, 108, 0.2);
}

.record-row-button {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  min-width: 0;
  border: 0;
  padding: 8px 10px;
  color: #2d1c0d;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.record-row-button:hover,
.record-row-button:focus-visible {
  background: rgba(255, 232, 158, 0.24);
  outline: none;
}

.record-row-button img {
  width: 62px;
  height: 48px;
  border: 2px solid rgba(75, 47, 15, 0.45);
  border-radius: 6px;
  object-fit: cover;
  background: rgba(45, 28, 13, 0.18);
}

.record-row-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.leaderboard-list span,
.leaderboard-list small,
.recent-runs span,
.recent-runs b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-list small,
.recent-runs span {
  color: rgba(45, 28, 13, 0.72);
}

.recent-runs .empty-row,
.leaderboard-list .empty-row {
  display: block;
  color: rgba(45, 28, 13, 0.72);
  text-align: center;
}

.record-detail-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
}

.record-back {
  justify-self: start;
  border: 2px solid rgba(78, 48, 14, 0.68);
  border-radius: 8px;
  padding: 8px 13px;
  color: #f7e2a1;
  background:
    linear-gradient(rgba(98, 57, 19, 0.9), rgba(55, 31, 12, 0.92));
  cursor: pointer;
  font-weight: 700;
  text-shadow: 0 2px 2px #1b1108;
}

.record-detail-card {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  border: 2px solid rgba(75, 47, 15, 0.42);
  border-radius: 8px;
  padding: 10px;
  background:
    linear-gradient(rgba(255, 242, 193, 0.4), rgba(228, 189, 111, 0.2)),
    url("assets/parchment-texture.webp") center / cover;
}

.record-detail-image {
  width: 100%;
  aspect-ratio: 1;
  border: 3px solid rgba(75, 47, 15, 0.54);
  border-radius: 8px;
  object-fit: cover;
  background: rgba(45, 28, 13, 0.16);
}

.record-detail-copy {
  min-width: 0;
}

.record-detail-mode {
  margin: 0 0 6px;
  color: rgba(45, 28, 13, 0.72);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
}

.record-detail-copy h3 {
  margin: 0;
  overflow: hidden;
  color: #3a240d;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(22px, 3vw, 32px);
}

.record-detail-text {
  min-height: 0;
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border: 2px solid rgba(75, 47, 15, 0.32);
  border-radius: 8px;
  padding: 14px;
  color: #2f2211;
  background:
    linear-gradient(rgba(255, 242, 193, 0.36), rgba(228, 189, 111, 0.18)),
    url("assets/parchment-texture.webp") center / cover;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.record-detail-text h1,
.record-detail-text h2,
.record-detail-text h3 {
  margin: 0.5em 0 0.2em;
  color: #4c2f0e;
}
.record-detail-text h1:first-child,
.record-detail-text h2:first-child,
.record-detail-text h3:first-child { margin-top: 0; }
.record-detail-text p { margin: 0.35em 0; }
.record-detail-text p:first-child { margin-top: 0; }
.record-detail-text ul,
.record-detail-text ol { margin: 0.35em 0; padding-left: 1.3em; }
.record-detail-text li { margin: 0.1em 0; }

.record-detail-text::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* ── Recent Discoveries Strip ── */

.recent-discoveries {
  min-width: 0;
  overflow: hidden;
  /* fade edges so cards blend into the journal paper */
  -webkit-mask-image: linear-gradient(to right, black 0%, black 92%, transparent 100%);
  mask-image: linear-gradient(to right, black 0%, black 92%, transparent 100%);
}

.recent-discoveries h3 {
  margin-bottom: clamp(6px, 0.9dvh, 10px);
}

.discovery-cards {
  display: flex;
  gap: clamp(4px, 0.5vw, 7px);
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 2px clamp(8px, 1.2vw, 14px) 4px clamp(8px, 1.2vw, 14px);
  /* Keep the row open at card height even when empty */
  min-height: clamp(66px, 8.5dvh, 92px);
}

.discovery-cards::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.discovery-card {
  position: relative;
  flex: 0 0 auto;
  width: clamp(66px, 8.5dvh, 92px);
  aspect-ratio: 3 / 4;
  scroll-snap-align: start;
  cursor: pointer;
  border: 0;
  padding: 0;
  /* webp card art as background — photo and label layer on top */
  background-color: rgba(210, 185, 140, 0.35);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  color: var(--ink);
  border-radius: 3px;
}

.discovery-card:active {
  transform: scale(0.96);
}

.discovery-card-thumb {
  position: absolute;
  top: 8%;
  left: 10%;
  width: 80%;
  height: 60%;
  object-fit: cover;
  border-radius: 3px;
  z-index: 1;
  /* vintage tone: warm sepia + slight desaturation */
  filter: sepia(0.2) contrast(1.05) brightness(0.92) saturate(0.82);
}

/* parchment wash over the thumbnail */
.discovery-card::after {
  content: '';
  position: absolute;
  top: 8%;
  left: 10%;
  width: 80%;
  height: 60%;
  border-radius: 3px;
  background: rgba(160, 130, 80, 0.10);
  mix-blend-mode: multiply;
  z-index: 2;
  pointer-events: none;
}

.discovery-card-name {
  position: absolute;
  top: 72%;
  left: 10%;
  width: 82%;
  z-index: 3;
  text-align: left;
  font-size: clamp(7px, 0.95dvh, 10px);
  font-weight: 600;
  color: #1e0e03;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-shadow: 0 1px 0 rgba(255, 241, 194, 0.6);
}

.discovery-card-name--pending {
  opacity: 0.6;
  font-style: italic;
}

.discovery-name-pending {
  text-align: center;
  font-style: italic;
  color: #7a5c2e;
  font-size: 0.85rem;
  padding: 0.75rem 1rem;
}

/* ── Discovery Detail Modal ── */

.discovery-modal[hidden] {
  display: none;
}

.discovery-modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: grid;
  place-items: center;
  padding: 18px;
}

.discovery-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 229, 144, 0.14), transparent 34%),
    rgba(5, 9, 4, 0.74);
  backdrop-filter: blur(2px);
}

.discovery-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: clamp(2px, 0.3dvh, 4px);
  width: min(680px, 94vw);
  height: min(620px, 88dvh);
  padding: clamp(22px, 3vw, 34px);
  border: 7px solid rgba(66, 39, 13, 0.94);
  border-radius: 8px;
  color: #2d1c0d;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 244, 196, 0.38), transparent 24%),
    radial-gradient(circle at 86% 82%, rgba(113, 67, 20, 0.22), transparent 28%),
    linear-gradient(rgba(239, 217, 166, 0.76), rgba(213, 174, 101, 0.8)),
    url("assets/parchment-texture.webp") center / cover;
  background-blend-mode: screen, multiply, normal, multiply;
  box-shadow: 0 28px 38px rgba(0, 0, 0, 0.68), inset 0 0 0 3px rgba(255, 233, 166, 0.5);
  overflow: hidden;
}

.discovery-dialog::before {
  content: "";
  position: absolute;
  inset: 12px;
  z-index: -1;
  border: 3px solid rgba(255, 229, 148, 0.34);
  border-radius: 5px;
  background:
    radial-gradient(circle at 24% 22%, rgba(255, 246, 206, 0.34), transparent 30%),
    linear-gradient(rgba(238, 211, 145, 0.74), rgba(220, 181, 106, 0.82)),
    url("assets/parchment-texture.webp") center / cover;
  background-blend-mode: screen, normal, multiply;
}

.discovery-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2px solid rgba(82, 51, 17, 0.55);
  border-radius: 50%;
  color: #fff2c5;
  background: rgba(91, 38, 19, 0.88);
  cursor: pointer;
  font-size: 25px;
  font-weight: 700;
  line-height: 1;
  z-index: 5;
}

.discovery-header {
  display: grid;
  grid-template-columns: clamp(60px, 10dvh, 90px) minmax(0, 1fr);
  gap: clamp(10px, 1.5vw, 18px);
  align-items: center;
}

.discovery-thumb {
  width: 100%;
  aspect-ratio: 1;
  border: 3px solid rgba(75, 47, 15, 0.54);
  border-radius: 8px;
  object-fit: cover;
  background: rgba(45, 28, 13, 0.16);
}

.discovery-header-copy {
  min-width: 0;
}

.discovery-dialog h2 {
  margin: 0;
  color: #4a2c0c;
  font-size: clamp(20px, 2.8vw, 30px);
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(255, 241, 194, 0.88);
}

.discovery-date {
  margin: 4px 0 0;
  color: rgba(45, 28, 13, 0.72);
  font-size: clamp(12px, 1.5dvh, 15px);
  font-weight: 700;
}

/* ── Discovery Speaker Row ── */

.discovery-speaker-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 0;
}

.discovery-speaker {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(78, 48, 14, 0.74);
  border-radius: 50%;
  color: #f7e2a1;
  background: linear-gradient(rgba(98, 57, 19, 0.9), rgba(55, 31, 12, 0.92));
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(55, 31, 12, 0.22), inset 0 1px 0 rgba(255, 239, 178, 0.22);
  transition: box-shadow 0.3s, border-color 0.3s;
}

.discovery-speaker:disabled {
  opacity: 0.35;
  cursor: default;
}

.discovery-speaker.is-playing {
  border-color: #6abf4b;
  box-shadow: 0 0 14px rgba(106, 191, 75, 0.6), 0 0 6px rgba(106, 191, 75, 0.4), inset 0 1px 0 rgba(255, 239, 178, 0.22);
}

.discovery-speaker:active:not(:disabled) {
  transform: translateY(1px);
}

/* ── Discovery Tabs ── */

.discovery-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.discovery-tab {
  position: relative;
  min-width: 0;
  border: 2px solid rgba(78, 48, 14, 0.74);
  border-radius: 8px;
  padding: 8px 4px;
  color: #f7e2a1;
  background:
    linear-gradient(rgba(98, 57, 19, 0.9), rgba(55, 31, 12, 0.92));
  cursor: pointer;
  font-weight: 700;
  font-size: clamp(11px, 1.3dvh, 14px);
  text-shadow: 0 2px 2px #1b1108;
  box-shadow: 0 6px 8px rgba(55, 31, 12, 0.22), inset 0 1px 0 rgba(255, 239, 178, 0.22);
  text-align: center;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.discovery-tab.is-active {
  color: #2b1b0b;
  background:
    linear-gradient(rgba(243, 213, 122, 0.96), rgba(191, 135, 49, 0.9)),
    url("assets/parchment-texture.webp") center / cover;
  text-shadow: 0 1px 0 rgba(255, 241, 194, 0.8);
}

.discovery-tab.is-explored {
  border-color: rgba(93, 104, 35, 0.72);
}

.discovery-tab:active {
  transform: translateY(1px);
}

/* ── Discovery Tab Panels ── */

.discovery-tabpanels {
  min-height: 0;
  overflow: hidden;
}

.discovery-tabpanel {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.discovery-tabpanel[hidden] {
  display: none;
}

.discovery-tabpanel::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* ── Discovery Loader ── */

.discovery-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 1;
}

.discovery-loader[hidden] {
  display: none;
}

.discovery-loader::before {
  content: "";
  width: 40px;
  height: 40px;
  border: 4px solid rgba(78, 48, 14, 0.2);
  border-top-color: #7a551e;
  border-radius: 50%;
  animation: aranya-spin 0.85s linear infinite;
}

/* ── Discovery Tab Text ── */

.discovery-tabtext {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border: 2px solid rgba(75, 47, 15, 0.32);
  border-radius: 8px;
  padding: 14px;
  color: #2f2211;
  background:
    linear-gradient(rgba(255, 242, 193, 0.36), rgba(228, 189, 111, 0.18)),
    url("assets/parchment-texture.webp") center / cover;
  overflow-wrap: anywhere;
  line-height: 1.55;
  font-size: clamp(14px, 1.6dvh, 18px);
}

.discovery-tabtext::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.discovery-tabtext h1,
.discovery-tabtext h2,
.discovery-tabtext h3 {
  margin: 0.5em 0 0.2em;
  color: #4c2f0e;
}
.discovery-tabtext h1:first-child,
.discovery-tabtext h2:first-child,
.discovery-tabtext h3:first-child { margin-top: 0; }
.discovery-tabtext p { margin: 0.35em 0; }
.discovery-tabtext p:first-child { margin-top: 0; }
.discovery-tabtext ul,
.discovery-tabtext ol { margin: 0.35em 0; padding-left: 1.3em; }
.discovery-tabtext li { margin: 0.1em 0; }
.discovery-tabtext strong { color: #3b2510; }

.followup-check {
  font-size: 12px;
  color: #5a7a12;
  margin-right: 2px;
}

.followup-check[hidden] {
  display: none;
}

@media (max-width: 1180px) {
  html,
  body {
    min-height: 100%;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell {
    position: relative;
    min-height: 100dvh;
    height: auto;
    padding: 8px 0 24px;
    overflow: visible;
  }

  .brand-logo {
    position: relative;
    left: auto;
    top: auto;
    display: block;
    margin: 0 auto 8px;
    max-width: min(520px, 82vw);
    width: min(520px, 82vw);
  }

  .stats-counter {
    position: relative;
    left: auto;
    top: auto;
    width: min(92vw, 520px);
    margin: 0 auto 6px;
  }

  .leaderboard-button {
    position: absolute;
    left: 13%;
    right: auto;
    top: auto;
    bottom: 10%;
    width: clamp(56px, 12vw, 78px);
  }

  .stats-counter span {
    font-size: clamp(11px, 2.7vw, 16px);
  }

  .game-board {
    position: relative;
    inset: auto;
    grid-template-columns: 1fr;
    justify-items: center;
    align-items: start;
    row-gap: 12px;
    padding-inline: 12px;
    width: 100%;
    height: auto;
  }

  .expedition-column {
    position: relative;
    left: auto;
    top: auto;
    display: block;
    width: min(94vw, 680px);
    height: auto;
    grid-template-rows: auto clamp(64px, 9dvh, 82px);
    align-content: start;
  }

  .center-panel {
    width: 100%;
    aspect-ratio: 1048 / 941;
    height: auto;
    max-height: none;
  }

  .center-content {
    inset: 13% 14% 18%;
  }

  .journal-panel {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    display: block;
    width: min(94vw, 560px);
    height: auto;
    aspect-ratio: 632 / 941;
    justify-self: center;
    transform: none;
  }

  .action-row {
    width: 100%;
    margin-top: clamp(-18px, -2dvh, -8px);
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 8px;
  }

  .brand-logo {
    width: min(300px, 82vw);
    max-width: min(300px, 82vw);
  }

  .stats-counter {
    width: min(94vw, 360px);
  }

  .stats-counter p {
    inset: 21% 8% 20%;
    gap: 2%;
  }

  .stats-counter span {
    font-size: 10px;
  }

  .stats-counter b {
    margin-right: 3px;
  }

  .leaderboard-button {
    left: 12%;
    right: auto;
    top: auto;
    bottom: 9%;
    width: 52px;
  }

  .discovery-modal {
    padding: 10px;
  }

  .discovery-dialog {
    gap: 10px;
    height: 90dvh;
    padding: 18px 14px;
  }

  .center-content {
    inset: 15% 12% 19%;
  }

  .board-kicker {
    display: none;
  }

  .upload-drop {
    width: min(92%, 360px);
    max-height: 74%;
  }

  .upload-label {
    font-size: 18px;
  }

  .preview-wrap {
    width: var(--preview-width, 320px);
    height: var(--preview-height, 180px);
  }

  .name-form,
  .name-plate {
    bottom: 5px;
    width: min(68%, 260px);
  }

  .user-actions {
    bottom: -14px;
  }

  .name-form {
    gap: 5px;
  }

  .name-input,
  .name-save {
    height: 32px;
    font-size: 14px;
  }

  .name-save {
    padding: 0 9px;
  }

  .action-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .action-button span {
    inset: 22% 7% 22% 22%;
  }

  .action-button b {
    font-size: 15px;
  }

  .action-button small {
    display: none;
  }

  .leaderboard-modal {
    padding: 10px;
  }

  .leaderboard-dialog {
    gap: 10px;
    height: 90dvh;
    padding: 18px 14px;
  }

  .record-summary {
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }

  .leaderboard-list li {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .leaderboard-list small {
    grid-column: 2;
  }

  .record-detail-card {
    grid-template-columns: 1fr;
  }

  .record-detail-image {
    width: min(190px, 70%);
    justify-self: center;
  }
}

/* ── Background Music Toggle ── */
.bgm-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 30;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 2px solid rgba(255, 232, 158, 0.5);
  border-radius: 50%;
  color: #f7e2a1;
  background: rgba(20, 12, 5, 0.7);
  backdrop-filter: blur(4px);
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  transition: background 0.2s, border-color 0.2s;
  padding: 0;
}

.bgm-toggle:hover,
.bgm-toggle:focus-visible {
  background: rgba(40, 25, 10, 0.85);
  border-color: rgba(255, 232, 158, 0.8);
  outline: none;
}

.bgm-toggle:active {
  transform: translateY(1px);
}

.bgm-icon-off {
  display: none;
}

.bgm-toggle.is-muted .bgm-icon-on {
  display: none;
}

.bgm-toggle.is-muted .bgm-icon-off {
  display: block;
}
