:root {
  color-scheme: dark;
  --wall-1: #2e2419;
  --wall-2: #4a3a29;
  --wall-3: #20190f;
  --ink: #f7f0df;
  --muted: #cdbb98;
  --gold: #c59d5a;
  --gold-bright: #e1c58c;
  --bronze: #7f5f35;
  --panel: rgba(34, 25, 15, 0.78);
  --panel-soft: rgba(55, 39, 21, 0.62);
  --border: rgba(202, 162, 93, 0.35);
  --danger: #ff8d82;
  --good: #8fe8a2;
  --shadow: 0 18px 35px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(232, 184, 113, 0.2), transparent 34%),
    radial-gradient(circle at 84% 86%, rgba(145, 95, 41, 0.24), transparent 40%),
    linear-gradient(165deg, var(--wall-3), var(--wall-1) 42%, var(--wall-2));
  font-family: Georgia, "Times New Roman", serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.26;
  background-image: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 0,
    rgba(255, 255, 255, 0.03) 1px,
    transparent 1px,
    transparent 4px
  );
}

.app-shell {
  width: min(1180px, calc(100% - 24px));
  margin: 18px auto 28px;
  position: relative;
  z-index: 1;
}

.app-shell::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 24% 18%, rgba(255, 238, 198, 0.09), transparent 38%),
    radial-gradient(circle at 82% 72%, rgba(225, 173, 94, 0.08), transparent 40%);
  mix-blend-mode: screen;
  opacity: 0.7;
  animation: ambientFloat 14s ease-in-out infinite alternate;
}

.debug-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  top: 10px;
  border: 1px solid rgba(255, 198, 120, 0.8);
  background: rgba(70, 45, 20, 0.9);
  color: #ffe7be;
  padding: 8px 10px;
  border-radius: 10px;
  z-index: 999;
  font-size: 13px;
}

.debug-banner.warn {
  border-color: rgba(255, 99, 99, 0.9);
  background: rgba(96, 24, 20, 0.92);
  color: #ffe1de;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 14px;
}

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

h1 {
  font-size: clamp(32px, 4.5vw, 54px);
  letter-spacing: 0.012em;
  line-height: 0.95;
}

.kicker {
  color: var(--gold-bright);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  margin-bottom: 4px;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  font: inherit;
}

.chip,
.btn,
.option-btn,
.inventory-btn,
.rank-btn,
.share-btn {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(155, 117, 58, 0.3), rgba(72, 49, 24, 0.35));
  color: var(--ink);
  border-radius: 12px;
  padding: 9px 12px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease;
  box-shadow: inset 0 1px 0 rgba(255, 227, 185, 0.15);
  font-weight: 600;
}

.chip:hover,
.btn:hover,
.option-btn:hover,
.inventory-btn:hover,
.rank-btn:hover,
.share-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 224, 168, 0.66);
}

.btn.accent {
  background: linear-gradient(120deg, #ad8346, #d4ae73);
  color: #291a0f;
  border-color: rgba(255, 233, 191, 0.8);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow);
}

.stat-card span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-card strong {
  font-size: 20px;
}

.main-grid {
  display: grid;
  grid-template-columns: 1.08fr 1fr;
  gap: 14px;
}

.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-head h2 {
  font-size: 24px;
  color: #f6e7c9;
}

.panel-head span,
.gallery-sub,
#imageTag {
  color: var(--muted);
  font-size: 13px;
}

.mission-copy {
  color: #e7ddca;
  margin-bottom: 10px;
  line-height: 1.4;
}

.rules-panel {
  margin-bottom: 10px;
  border: 1px solid rgba(233, 200, 139, 0.35);
  border-radius: 10px;
  background: rgba(88, 63, 31, 0.35);
  padding: 8px 10px;
}

.rules-panel h3 {
  font-size: 15px;
  margin: 0 0 6px;
}

.rules-panel ul {
  margin: 0;
  padding-left: 16px;
  display: grid;
  gap: 4px;
  color: #e8dac2;
  font-size: 13px;
}

.mission-area {
  display: grid;
  gap: 10px;
}

.prompt {
  font-size: 20px;
  line-height: 1.4;
}

.option-list,
.rank-list {
  display: grid;
  gap: 8px;
}

.option-btn {
  text-align: left;
}

.option-btn .n {
  margin-right: 8px;
  color: var(--gold-bright);
}

.feedback-area {
  margin-top: 12px;
  min-height: 104px;
  border-radius: 14px;
  border: 1px dashed rgba(238, 202, 143, 0.35);
  background: rgba(75, 52, 26, 0.35);
  padding: 10px;
  display: grid;
  align-content: start;
  gap: 7px;
}

.mission-tools-row {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.curator-stamp {
  border: 2px solid rgba(218, 73, 47, 0.7);
  color: rgba(243, 102, 71, 0.9);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  letter-spacing: 0.12em;
  transform: rotate(-9deg) scale(0.6);
  opacity: 0;
}

.curator-stamp.show {
  animation: stampIn 0.45s ease forwards;
}

.feedback-good {
  color: var(--good);
  font-weight: 700;
}

.feedback-bad {
  color: var(--danger);
  font-weight: 700;
}

.feedback-meta {
  font-size: 13px;
  color: #dbccb4;
}

.canvas-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 8px solid #5a4124;
  box-shadow:
    inset 0 0 0 2px rgba(219, 179, 109, 0.7),
    inset 0 0 0 8px rgba(101, 70, 35, 0.9),
    0 14px 24px rgba(0, 0, 0, 0.45);
  background: #130b06;
}

#revealCanvas,
#previewCanvas,
#particleCanvas {
  width: 100%;
  height: auto;
  display: block;
}

#revealCanvas {
  touch-action: none;
  cursor: crosshair;
}

#previewCanvas,
#particleCanvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.caption-plaque,
.whisper-line {
  position: absolute;
  left: 14px;
  right: 14px;
  border: 1px solid rgba(239, 211, 165, 0.55);
  background: rgba(45, 30, 15, 0.82);
  color: #f3e8d2;
  border-radius: 9px;
  padding: 7px 10px;
  pointer-events: none;
}

.caption-plaque {
  bottom: 10px;
  font-size: 14px;
  line-height: 1.35;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.caption-plaque.fade {
  animation: plaqueFade 0.38s ease;
}

.whisper-line {
  top: 10px;
  font-style: italic;
  font-size: 13px;
  color: #ffe9bf;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

@keyframes plaqueFade {
  0% {
    opacity: 0.25;
    transform: translateY(4px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.whisper-line.show {
  opacity: 1;
  transform: translateY(0);
}

.scanner-bar {
  margin-top: 8px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #f0d09a, transparent);
  box-shadow: 0 0 18px rgba(255, 209, 137, 0.55);
  animation: scanPulse 0.8s linear infinite;
}

.ink-meter {
  margin-top: 8px;
  display: grid;
  gap: 4px;
}

.ink-meter span {
  font-size: 12px;
  color: var(--muted);
}

.ink-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 230, 184, 0.2);
  overflow: hidden;
}

.ink-fill {
  height: 100%;
  background: linear-gradient(90deg, #f4d39f, #d09a49);
  width: 100%;
  transition: width 0.15s linear;
}

.tool-row {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.inventory-btn {
  font-size: 13px;
  padding: 9px;
  position: relative;
}

.inventory-btn span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.inventory-btn .icon {
  display: block;
  width: 18px;
  height: 18px;
  margin: 0 auto 2px;
  opacity: 0.9;
}

.inventory-btn.active {
  border-color: #f2d59e;
  box-shadow: 0 0 0 1px rgba(254, 215, 142, 0.8) inset;
}

.gallery-panel {
  margin-top: 14px;
}

.selector-help {
  color: var(--muted);
  font-size: 13px;
}

.tags-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.tag-chip {
  border: 1px solid rgba(239, 211, 165, 0.5);
  background: rgba(106, 76, 40, 0.44);
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: #f3dfba;
}

.gallery-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.gallery-card {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(224, 186, 120, 0.35);
  background: rgba(59, 40, 19, 0.46);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.gallery-card:hover {
  transform: translateY(-2px);
  border-color: rgba(246, 220, 164, 0.85);
  box-shadow: 0 0 24px rgba(240, 214, 159, 0.2);
}

.gallery-card.exhibit-selected {
  border-color: rgba(245, 216, 160, 0.9);
  box-shadow: 0 0 0 1px rgba(245, 216, 160, 0.7) inset;
}

.gallery-card img {
  width: 100%;
  display: block;
  aspect-ratio: 4/3;
  object-fit: cover;
}

.gallery-meta {
  padding: 8px;
  display: grid;
  gap: 8px;
}

.rank-item {
  border: 1px solid rgba(224, 186, 120, 0.25);
  padding: 9px;
  border-radius: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: rgba(87, 60, 30, 0.3);
}

.rank-item.dragging {
  opacity: 0.5;
}

.rank-controls {
  display: flex;
  gap: 6px;
}

.rank-btn {
  padding: 4px 8px;
  font-size: 12px;
}

.rank-item.tap-selected {
  border-color: #f5d9a5;
  box-shadow: 0 0 0 1px rgba(245, 217, 165, 0.72) inset;
}

.win-flash {
  animation: pulseWin 0.75s ease;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(14, 10, 7, 0.62);
  display: grid;
  place-items: center;
  z-index: 998;
  padding: 16px;
}

.modal-card {
  width: min(480px, 100%);
  border: 1px solid rgba(230, 198, 134, 0.45);
  border-radius: 14px;
  background: rgba(43, 30, 17, 0.95);
  box-shadow: 0 15px 32px rgba(0, 0, 0, 0.45);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.modal-help {
  color: var(--muted);
  font-size: 13px;
}

.modal-input {
  border: 1px solid rgba(230, 198, 134, 0.45);
  border-radius: 10px;
  background: rgba(14, 9, 5, 0.7);
  color: var(--ink);
  padding: 10px;
}

.modal-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
}

#revealCanvas.tool-none {
  cursor: default;
}

#revealCanvas.tool-chisel,
#revealCanvas.tool-axe,
#revealCanvas.tool-spray,
#revealCanvas.tool-scanner,
#revealCanvas.tool-bomb {
  cursor: none;
}

@keyframes pulseWin {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 213, 145, 0.5);
  }
  100% {
    box-shadow: 0 0 0 22px rgba(255, 213, 145, 0);
  }
}

@keyframes scanPulse {
  0% {
    transform: translateX(-22%);
  }
  100% {
    transform: translateX(22%);
  }
}

@keyframes stampIn {
  0% { opacity: 0; transform: rotate(-9deg) scale(0.4); }
  55% { opacity: 1; transform: rotate(-7deg) scale(1.08); }
  100% { opacity: 0.9; transform: rotate(-8deg) scale(1); }
}

@keyframes ambientFloat {
  0% { transform: translateY(0px); opacity: 0.55; }
  100% { transform: translateY(-8px); opacity: 0.78; }
}

@media (max-width: 980px) {
  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main-grid {
    grid-template-columns: 1fr;
  }

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

  .topbar {
    flex-direction: column;
    align-items: start;
  }

  .mission-tools-row {
    flex-wrap: wrap;
  }
}
