:root {
  --ink: #3b2414;
  --paper: #efe0bd;
  --paper-2: #e2cc9c;
  --leather: #3a2214;
  --leather-hi: #5a3720;
  --leather-lo: #1c0f08;
  --brass: #c8973a;
  --brass-hi: #f6dc95;
  --brass-lo: #6b4716;
  --oxblood: #8b1e1e;
  --cream: #ead6a6;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-display: 'Cinzel', 'Times New Roman', serif;
  --font-logo: 'Cinzel Decorative', 'Cinzel', serif;
  --font-text: 'EB Garamond', Georgia, serif;
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --grain-soft: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .3  0 0 0 0 .2  0 0 0 0 .1  0 0 0 .16 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --mottle: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.035' numOctaves='4' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .9 -.25'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --leather-bg:
    var(--grain),
    var(--mottle),
    radial-gradient(120% 140% at 50% 0%, var(--leather-hi), var(--leather) 55%, var(--leather-lo));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #120a05;
  color: var(--cream);
  font-family: var(--font-text);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #1a0f08;
  isolation: isolate;
}

/* On a desktop, preview the game in a phone-sized frame on a dark desk. */
@media (min-width: 640px) {
  body {
    background:
      radial-gradient(60% 50% at 50% 40%, rgba(120, 70, 30, .25), transparent 70%),
      repeating-linear-gradient(92deg, #1b0f08 0 14px, #20130a 14px 30px, #180d07 30px 41px),
      #150b05;
  }
  #app {
    inset: 20px auto;
    left: 50%;
    width: 430px;
    height: min(932px, calc(100vh - 40px));
    transform: translateX(-50%);
    border-radius: 34px;
    box-shadow: 0 0 0 10px #0b0603, 0 0 0 11px #3a2616, 0 30px 80px rgba(0, 0, 0, .7);
  }
}

html.inspect body { overflow: auto; }
html.inspect #app {
  position: absolute;
  inset: 0 auto auto 0;
  left: 0;
  top: 0;
  width: 430px;
  height: 932px;
  transform: scale(2);
  transform-origin: 0 0;
  border-radius: 0;
}

#stage { position: absolute; inset: 0; }
#stage.shake { animation: shake .38s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake {
  10%, 90% { transform: translate(-1px, 1px); }
  25%, 75% { transform: translate(3px, -2px); }
  40%, 60% { transform: translate(-4px, 2px); }
  50% { transform: translate(2px, 3px); }
}

#map, #fx { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#map { touch-action: none; cursor: grab; }
#map:active { cursor: grabbing; }
#fx { pointer-events: none; }

#grid-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#grid-labels span {
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--font-text);
  font-style: italic;
  font-size: 11.5px;
  color: rgba(59, 36, 20, .72);
  white-space: nowrap;
  text-shadow: 0 0 3px rgba(239, 224, 189, .9);
  will-change: transform;
}

/* ---------- Map overlays: region names, tooltip, vault pointer, scale ---------- */
#map-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#map-labels span {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  font-family: var(--font-text);
  font-style: italic;
  font-weight: 700;
  font-variant: small-caps;
  letter-spacing: .26em;
  color: rgba(52, 30, 14, .92);
  text-shadow:
    0 0 2px rgba(242, 228, 196, 1), 0 0 5px rgba(242, 228, 196, .95),
    0 0 10px rgba(242, 228, 196, .8);
  will-change: transform, opacity;
}
#map-labels .region-mountains { font-size: 20px; }
#map-labels .region-forest { font-size: 19px; color: rgba(44, 50, 18, .92); }
#map-labels .region-hills { font-size: 17px; }
#map-labels .region-plains { font-size: 17px; letter-spacing: .38em; }

.map-tip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  max-width: 240px;
  padding: 9px 14px 10px;
  color: var(--ink);
  pointer-events: none;
  background: var(--grain-soft), linear-gradient(175deg, #f8edcf, #e8d3a3);
  border: 1px solid rgba(59, 36, 20, .45);
  border-radius: 4px;
  box-shadow: 0 6px 16px rgba(30, 15, 5, .35);
  --arrow: 50%;
}
.map-tip[hidden] { display: none; }
.map-tip::after {
  content: '';
  position: absolute;
  left: var(--arrow);
  bottom: -7px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  background: #e9d5a6;
  border-right: 1px solid rgba(59, 36, 20, .45);
  border-bottom: 1px solid rgba(59, 36, 20, .45);
  transform: rotate(45deg);
}
.map-tip.show { animation: tip-in .22s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes tip-in { from { opacity: 0; margin-top: 6px; } to { opacity: 1; margin-top: 0; } }
.tip-title { font-family: var(--font-display); font-weight: 700; font-size: 14px; letter-spacing: .04em; }
.tip-body { margin-top: 2px; font-family: var(--font-text); font-style: italic; font-size: 15px; line-height: 1.2; }

.edge-pointer {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 4;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.edge-pointer[hidden] { display: none; }
.ep-arrow {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
}
.ep-arrow::before {
  content: '';
  position: absolute;
  right: -7px;
  top: 50%;
  margin-top: -8px;
  border-left: 12px solid #8b1e1e;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .4));
}
.ep-icon {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #f8edcf, #dcc28c);
  box-shadow: 0 0 0 1.5px #3b2414, 0 4px 10px rgba(30, 15, 5, .45);
}
.ep-icon svg { width: 100%; height: 100%; display: block; }
.ep-dist {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  margin-top: 1px;
  white-space: nowrap;
  font-family: var(--font-text);
  font-style: italic;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  text-shadow: 0 0 3px rgba(239, 224, 189, 1), 0 0 2px rgba(239, 224, 189, 1);
}

.scale-bar {
  position: absolute;
  z-index: 9;
  left: 12px;
  bottom: calc(100px + var(--safe-bottom) + 12px);
  pointer-events: none;
  filter: drop-shadow(0 0 2px rgba(239, 224, 189, .9));
}
.scale-bar svg { display: block; }

/* ---------- Top bar ---------- */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(var(--safe-top) + 10px) 14px 12px;
  background: var(--leather-bg);
  border-bottom: 1px solid #0d0603;
  box-shadow: 0 1px 0 rgba(255, 220, 160, .08) inset, 0 8px 22px rgba(0, 0, 0, .5);
}
.topbar::before {
  content: '';
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 6px;
  border-bottom: 1.5px dashed rgba(226, 184, 118, .55);
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .6));
}
.topbar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 4px;
  background: linear-gradient(180deg, #f6dc95, #b8862f 45%, #5c3b10);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .6);
}

.logo {
  font-family: var(--font-logo);
  font-weight: 900;
  font-size: 23px;
  letter-spacing: .16em;
  padding-left: .16em;
  background: linear-gradient(180deg, #fff3c9 0%, #f0c86e 40%, #a26f24 58%, #f6dc95 80%, #c08a35 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1.5px 0 rgba(0, 0, 0, .85)) drop-shadow(0 0 10px rgba(240, 190, 100, .25));
}

/* The game menu button, where the area counter used to be. */
.menu-btn {
  justify-self: start;
  width: 40px;
  height: 40px;
  margin: -6px 0 -6px -8px;
  padding: 7px;
  border: 0;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .5));
  transition: transform .15s ease;
}
.menu-btn svg { width: 100%; height: 100%; display: block; }
.menu-btn:active { transform: scale(.9); }

.stat {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--cream);
  min-width: 0;
}
.stat-right { justify-content: flex-end; text-align: right; }
.stat .glyph { width: 22px; height: 22px; flex: none; opacity: .9; }
.stat .glyph svg { width: 100%; height: 100%; display: block; }
.stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16.5px;
  line-height: 1;
  letter-spacing: .04em;
  color: #f3dfaa;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .7);
}
#stat-gps .glyph path, #stat-gps .glyph circle { transition: opacity .4s ease, fill .4s ease, stroke .4s ease; }
#stat-gps[data-q='q2'] .g-out { opacity: .22; }
#stat-gps[data-q='q1'] .g-out,
#stat-gps[data-q='q1'] .g-in,
#stat-gps[data-q='q0'] .g-out,
#stat-gps[data-q='q0'] .g-in { opacity: .22; }
#stat-gps[data-q='q1'] .g-dot { fill: #f08a6e; }
#stat-gps[data-q='q0'] .g-dot { opacity: .35; }
#stat-gps[data-q='q1'] .stat-value { color: #f08a6e; }

/* ---------- Dock ---------- */
.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  height: calc(100px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: var(--leather-bg);
  border-top: 1px solid #0d0603;
  box-shadow: 0 -10px 26px rgba(0, 0, 0, .5);
}
.dock::before {
  content: '';
  position: absolute;
  left: 7px;
  right: 7px;
  top: 7px;
  border-top: 1.5px dashed rgba(226, 184, 118, .55);
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .6));
}
.dock::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -4px;
  z-index: 1;
  height: 4px;
  background: linear-gradient(0deg, #f6dc95, #b8862f 45%, #5c3b10);
  box-shadow: 0 -2px 4px rgba(0, 0, 0, .5);
}

.dock-btn {
  justify-self: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .6));
  transition: transform .15s ease;
}
.dock-btn svg { width: 100%; height: 100%; display: block; }
.dock-btn:active { transform: scale(.92); }
#btn-recenter.attention { animation: attention 1.6s ease-in-out infinite; }
@keyframes attention {
  0%, 100% { filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .6)); }
  50% { filter: drop-shadow(0 0 10px rgba(255, 200, 110, .8)); }
}

.action {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
  transform: translateY(-34px);
}

.medallion {
  position: relative;
  width: 108px;
  height: 108px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, .6));
  transition: transform .18s cubic-bezier(.3, 1.6, .5, 1), filter .4s ease;
}
.medallion svg { width: 100%; height: 100%; display: block; }
.medallion::after {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 0 22px 4px rgba(255, 205, 120, .55), inset 0 0 12px rgba(255, 220, 150, .3);
  transition: opacity .4s ease;
}
.medallion.ready::after { animation: glow 2.6s ease-in-out infinite; }
@keyframes glow { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.medallion:active { transform: scale(.93); }
.medallion.disabled { filter: grayscale(.8) brightness(.58) contrast(.95) drop-shadow(0 10px 12px rgba(0, 0, 0, .6)); }
.medallion.busy .m-icon { animation: dig .42s ease-in-out infinite; transform-origin: 60px 60px; }
@keyframes dig { 50% { transform: rotate(-14deg) translateY(3px); } }
.medallion .m-sheen { transform: translateX(-80px); }
.medallion.ready .m-sheen { animation: sheen 3.4s ease-in-out infinite; }
@keyframes sheen { 0% { transform: translateX(-80px); } 55%, 100% { transform: translateX(150px); } }

/* Status ribbon above the medallion */
.ribbon {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 54px);
  z-index: 3;
  transform: translate(-50%, 10px) scale(.96);
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(30, 15, 5, .45));
  transition: opacity .3s ease, transform .35s cubic-bezier(.3, 1.4, .5, 1);
}
.ribbon.visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.ribbon.nudge .ribbon-body { animation: nudge .45s ease; }
@keyframes nudge { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.ribbon-body {
  display: block;
  padding: 8px 30px 9px;
  white-space: nowrap;
  font-family: var(--font-text);
  font-style: italic;
  font-weight: 600;
  font-size: 16.5px;
  color: var(--ink);
  background:
    var(--grain-soft),
    linear-gradient(180deg, #f6e8c6, #e3cc98);
  clip-path: polygon(0 0, 100% 0, calc(100% - 13px) 50%, 100% 100%, 0 100%, 13px 50%);
}

/* ---------- Reveal ---------- */
.reveal {
  position: absolute;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  --glow: rgba(170, 110, 60, .35);
  --tone: #e6b77a;
}
.reveal[hidden] { display: none; }
.reveal[data-rarity='common'] { --glow: rgba(190, 120, 60, .3); --tone: #e2a669; }
.reveal[data-rarity='uncommon'] { --glow: rgba(170, 200, 235, .28); --tone: #cfdcf0; }
.reveal[data-rarity='rare'] { --glow: rgba(255, 196, 90, .38); --tone: #f5cf72; }
.reveal[data-rarity='legendary'] { --glow: rgba(255, 168, 50, .5); --tone: #ffcf5c; }
.reveal[data-rarity='junk'] { --glow: rgba(120, 90, 60, .25); --tone: #cdb48a; }

.reveal-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 36%, var(--glow) 0%, rgba(24, 11, 5, .93) 38%, rgba(6, 3, 1, .98) 100%);
  backdrop-filter: blur(3px) saturate(.7);
  -webkit-backdrop-filter: blur(3px) saturate(.7);
  opacity: 0;
  transition: opacity .55s ease;
}
.reveal.show .reveal-backdrop { opacity: 1; }
.reveal.closing .reveal-backdrop,
.reveal.closing .reveal-stage,
.reveal.closing .reveal-info,
.reveal.closing .reveal-rays,
.reveal.closing .reveal-halo { opacity: 0; transition: opacity .4s ease; }

.reveal-rays {
  position: absolute;
  left: 50%;
  top: 36%;
  width: 1500px;
  height: 1500px;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, rgba(255, 222, 150, .13) 0deg 3deg, transparent 3deg 9deg, rgba(255, 222, 150, .07) 9deg 13deg, transparent 13deg 22deg);
  -webkit-mask-image: radial-gradient(circle, rgba(0, 0, 0, .9) 4%, transparent 26%);
  mask-image: radial-gradient(circle, rgba(0, 0, 0, .9) 4%, transparent 26%);
  opacity: 0;
  transition: opacity 1.2s ease;
  animation: spin 50s linear infinite;
  pointer-events: none;
}
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.reveal[data-rarity='legendary'].show .reveal-rays { opacity: .4; }
.reveal[data-rarity='legendary'].lit .reveal-rays { opacity: .85; }
.reveal[data-rarity='rare'].lit .reveal-rays { opacity: .5; }

.reveal-halo {
  position: absolute;
  left: 50%;
  top: 36%;
  width: 520px;
  height: 520px;
  transform: translate(-50%, -50%) scale(.6);
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 1s ease, transform 1.6s cubic-bezier(.2, .8, .2, 1);
  pointer-events: none;
}
.reveal.lit .reveal-halo { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.reveal-particles { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.reveal-stage {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--safe-top) + 7%);
  height: 50%;
  display: grid;
  place-items: center;
}
.reveal:not([data-kind='coin']) .reveal-coin { display: none; }
.reveal.turnable :is(.reveal-coin, .reveal-artifact) { cursor: grab; touch-action: none; }
.reveal.turnable :is(.reveal-coin, .reveal-artifact):active { cursor: grabbing; }
.reveal:not([data-kind='artifact'], [data-kind='junk']) .reveal-artifact { display: none; }
.reveal:is([data-kind='coin'], [data-kind='artifact'], [data-kind='junk']) .paper-card { display: none; }
.reveal[data-kind='tomb'] { --glow: rgba(255, 196, 110, .32); --tone: #f0cf86; }

.reveal-info {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: calc(26px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.reveal-info > * {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .6s ease, transform .7s cubic-bezier(.2, .9, .3, 1);
}
.reveal.info-in .reveal-info > * { opacity: 1; transform: none; transition-delay: calc(var(--i, 0) * .13s); }
.reveal:not(.info-in) .reveal-info { pointer-events: none; }
.reveal-info > [hidden] { display: none; }
.reveal:not([data-kind='coin'], [data-kind='artifact'], [data-kind='junk']) :is(.reveal-context, .reveal-rarity, .reveal-name, .reveal-desc, .reveal-hint) { display: none; }

.reveal-context {
  margin-bottom: 8px;
  font-family: var(--font-text);
  font-style: italic;
  font-size: 17px;
  color: #e6c78a;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}

.reveal-rarity {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .42em;
  padding-left: .42em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--tone);
  text-shadow: 0 0 12px var(--glow);
}
/* "Artefakt z grobowca IV" is long: tighter spacing keeps it on one line. */
.reveal[data-kind='artifact'] .reveal-rarity { letter-spacing: .26em; padding-left: .26em; }
.reveal-rarity::before,
.reveal-rarity::after {
  content: '';
  flex: 0 1 42px;
  min-width: 14px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--tone));
}
.reveal-rarity::after { background: linear-gradient(270deg, transparent, var(--tone)); }

.reveal-name {
  margin: 8px 0 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 29px;
  line-height: 1.1;
  letter-spacing: .03em;
  background: linear-gradient(180deg, #fff6d8 0%, var(--tone) 50%, #8a5a1e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .7)) drop-shadow(0 0 16px var(--glow));
}
.reveal[data-rarity='uncommon'] .reveal-name { background-image: linear-gradient(180deg, #ffffff 0%, #d5dfec 50%, #6f7d8f 100%); }

.reveal-desc {
  margin: 0;
  max-width: 32ch;
  font-family: var(--font-text);
  font-style: italic;
  font-size: 18.5px;
  line-height: 1.24;
  color: #ead9b6;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}
/* The vault's look at an artifact: the details found so far and the search for the next. */
.reveal-exam { display: flex; flex-direction: column; align-items: center; width: 100%; }
.reveal-exam [hidden] { display: none; }
.reveal-details { display: flex; flex-direction: column; gap: 9px; max-width: 30em; font-size: 19px; }
.reveal-details:empty { display: none; }
.reveal-detail {
  margin: 0;
  font-family: var(--font-text);
  line-height: 1.25;
  color: #ead9b6;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}
.reveal-detail.fresh { animation: detail-in 1.6s ease both; }
@keyframes detail-in {
  0% { opacity: 0; transform: translateY(8px); color: #fff3cf; text-shadow: 0 0 14px var(--glow), 0 1px 2px rgba(0, 0, 0, .8); }
  30% { opacity: 1; transform: none; color: #fff3cf; text-shadow: 0 0 14px var(--glow), 0 1px 2px rgba(0, 0, 0, .8); }
}
.reveal-exam-label {
  margin-top: 14px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: .26em;
  padding-left: .26em;
  text-transform: uppercase;
  color: var(--tone);
}
.reveal-exam-bar {
  width: min(220px, 70%);
  height: 4px;
  margin-top: 7px;
  border-radius: 2px;
  background: rgba(234, 214, 166, .15);
  overflow: hidden;
}
.reveal-exam-bar > span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #8a5a1e, var(--tone));
  box-shadow: 0 0 8px var(--glow);
  transition: width .25s ease;
}
.reveal-hint[hidden] { display: none; }
.reveal-hint {
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(234, 214, 166, .45);
}

.btn-brass {
  margin-top: 18px;
  min-width: 200px;
  padding: 13px 30px 12px;
  border: 1px solid #3d2508;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #2b1708;
  text-shadow: 0 1px 0 rgba(255, 240, 200, .6);
  background: linear-gradient(180deg, #fff0bf 0%, #e3b65e 42%, #a8752b 58%, #e9c470 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 -2px 5px rgba(60, 30, 5, .35), 0 0 0 3px rgba(20, 10, 4, .55), 0 8px 18px rgba(0, 0, 0, .55);
  transition: transform .15s ease, filter .2s;
}
.btn-brass:active { transform: scale(.96); filter: brightness(.92); }

.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 36%, rgba(255, 247, 222, .95), rgba(255, 210, 130, .35) 35%, transparent 70%);
  opacity: 0;
}
.flash.go { animation: flash 1.1s ease-out; }
@keyframes flash { 0% { opacity: 0; } 8% { opacity: 1; } 100% { opacity: 0; } }

/* Paper cards: junk notebook page, mission map */
.paper-card {
  position: relative;
  width: min(80%, 320px);
  padding: 22px 24px 24px;
  color: var(--ink);
  background:
    var(--grain-soft),
    radial-gradient(120% 90% at 30% 20%, transparent 50%, rgba(120, 80, 30, .18)),
    repeating-linear-gradient(180deg, transparent 0 27px, rgba(80, 110, 150, .2) 27px 28px),
    linear-gradient(170deg, #f7ebcd, #e8d4a6);
  clip-path: polygon(0 2%, 6% 0, 14% 1.5%, 23% 0, 34% 1%, 46% 0, 58% 1.2%, 71% 0, 83% 1.4%, 94% 0, 100% 1.6%, 99% 30%, 100% 62%, 99% 100%, 0 99%, 1% 60%, 0 30%);
  transform: translateY(-140%) rotate(-12deg);
  opacity: 0;
}
.card-overlay .paper-card:not(.notebook-page),
.reveal[data-kind='tomb'] .paper-card {
  background:
    var(--grain-soft),
    radial-gradient(120% 90% at 30% 20%, transparent 45%, rgba(120, 80, 30, .24)),
    linear-gradient(170deg, #f5e6c2, #e2c993);
}
.paper-card.drop { animation: drop .75s cubic-bezier(.25, 1.35, .45, 1) forwards; }
@keyframes drop {
  0% { transform: translateY(-140%) rotate(-12deg); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateY(0) rotate(-3deg); opacity: 1; }
}
.paper-card.roll { animation: roll .5s cubic-bezier(.6, 0, .8, .4) forwards; }
@keyframes roll {
  from { transform: rotate(-3deg) scaleY(1); opacity: 1; }
  to { transform: rotate(-3deg) translateY(30%) scaleY(.04); opacity: 0; }
}
.paper-card.shake { animation: card-shake .5s ease; }
@keyframes card-shake {
  20%, 60% { transform: translateX(-7px) rotate(-1deg); }
  40%, 80% { transform: translateX(7px) rotate(1deg); }
}
.card-label {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: rgba(139, 30, 30, .78);
}
.card-sketch { margin: 6px -6px 2px; }
/* The mission card: a ruled page of the field notebook with a red margin, the artifact
   sketched on it. */
.notebook-page {
  padding-left: 38px;
  background:
    var(--grain-soft),
    radial-gradient(120% 90% at 30% 20%, transparent 50%, rgba(120, 80, 30, .2)),
    linear-gradient(90deg, transparent 27px, rgba(160, 52, 40, .45) 27px 28.5px, transparent 28.5px 31px, rgba(160, 52, 40, .3) 31px 32px, transparent 32px),
    repeating-linear-gradient(180deg, transparent 0 27px, rgba(80, 110, 150, .2) 27px 28px),
    linear-gradient(170deg, #f7ebcd, #e8d4a6);
}
.notebook-page .card-sketch { width: 150px; height: 150px; margin: 4px auto 0; }
/* A long page scrolls inside the card. */
.notebook-page { max-height: 100%; overflow-y: auto; overscroll-behavior: contain; }
.card-status { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 2px 0 0; font-family: var(--font-text); font-style: italic; font-size: 16px; color: var(--oxblood); }
.card-status svg { flex: none; width: 15px; height: 15px; }
.card-status[hidden], .notebook-active[hidden], .notebook-notes[hidden], .notebook-abandon[hidden] { display: none; }
.notebook-notes { margin-top: 10px; padding-top: 8px; border-top: 1px dashed rgba(59, 36, 20, .35); font-family: var(--font-text); }
.notebook-notes p { margin: 0 0 8px; font-size: 16px; line-height: 1.28; }
.notebook-notes .nb-lore { font-style: italic; color: #4a2e18; }
.notebook-notes .nb-fact { color: #3b2414; }
.notebook-buttons { display: flex; flex-direction: column; align-items: stretch; gap: 2px; width: 100%; }
.notebook-buttons .btn-brass { margin-top: 10px; min-width: 0; padding-left: 10px; padding-right: 10px; font-size: 12px; letter-spacing: .14em; }
.notebook-buttons .btn-link { letter-spacing: .12em; }
.notebook-buttons .btn-brass:disabled { filter: grayscale(.7) brightness(.85); }
.notebook-abandon { margin-top: 14px; }
.notebook-page .card-sketch svg { height: 100%; }
.card-sketch svg { width: 100%; height: auto; display: block; }
.card-title {
  margin-top: 4px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
}
.card-desc {
  margin-top: 6px;
  font-family: var(--font-text);
  font-style: italic;
  font-size: 18px;
  line-height: 1.22;
  color: #4a2e18;
}

/* Wrapped paragraphs balance their lines instead of leaving one word on the last. */
.reveal-desc, .card-desc, .tip-body, .card-msg, .notebook-notes p, .gate-hint, .deposit-hint { text-wrap: pretty; }

.checks {
  margin: 12px 0 0;
  padding: 10px 0 0;
  list-style: none;
  border-top: 1px dashed rgba(59, 36, 20, .35);
  font-family: var(--font-text);
  font-size: 16.5px;
  line-height: 1.2;
}
.checks[hidden] { display: none; }
.checks li { display: flex; align-items: flex-start; gap: 8px; padding: 3px 0; }
.checks li.no { color: #5a3a24; }
.checks li.ok { color: var(--ink); }
.checks .mark { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.checks .mark svg { width: 100%; height: 100%; display: block; }

/* ---------- Mission button & notebook ---------- */
/* Top left corner of the map, just under the top bar. */
.tomb-btn {
  position: absolute;
  z-index: 11;
  left: 12px;
  top: calc(var(--safe-top) + 70px);
  width: 62px;
  height: 62px;
  padding: 4px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background: radial-gradient(circle at 40% 35%, #5a3720, #2a170c 70%);
  box-shadow: 0 0 0 2px #c8973a, 0 0 0 4px #2a160a, 0 6px 14px rgba(0, 0, 0, .55);
  animation: tomb-glow 2.4s ease-in-out infinite;
  transition: transform .15s ease;
}
.tomb-btn[hidden] { display: none; }
.tomb-btn svg { width: 100%; height: 100%; display: block; }
.tomb-btn:active { transform: scale(.92); }
.tomb-btn.arrive { animation: tomb-arrive .7s cubic-bezier(.3, 1.6, .5, 1), tomb-glow 2.4s ease-in-out .7s infinite; }
@keyframes tomb-glow {
  0%, 100% { box-shadow: 0 0 0 2px #c8973a, 0 0 0 4px #2a160a, 0 6px 14px rgba(0, 0, 0, .55); }
  50% { box-shadow: 0 0 0 2px #f6dc95, 0 0 0 4px #2a160a, 0 0 22px 6px rgba(255, 196, 100, .45); }
}
@keyframes tomb-arrive { from { transform: scale(0) rotate(-40deg); } to { transform: none; } }

/* The satchel: what is carried home, mirroring the mission button on the left. */
.satchel-btn {
  position: absolute;
  z-index: 11;
  left: 12px;
  bottom: calc(100px + var(--safe-bottom) + 44px);
  width: 58px;
  height: 58px;
  padding: 5px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background: radial-gradient(circle at 40% 35%, #5a3720, #2a170c 70%);
  box-shadow: 0 0 0 2px #c8973a, 0 0 0 4px #2a160a, 0 6px 14px rgba(0, 0, 0, .55);
}
.satchel-btn[hidden] { display: none; }
.satchel-btn svg { width: 100%; height: 100%; display: block; }
.satchel-btn:active { transform: scale(.92); }
.satchel-count {
  position: absolute;
  right: -5px;
  top: -5px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: linear-gradient(#a82a22, #6e1512);
  box-shadow: 0 0 0 2px #2a160a, 0 2px 4px rgba(0, 0, 0, .5);
  color: #fff1d0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12.5px;
  line-height: 22px;
  text-align: center;
}
.satchel-btn.pop, .tomb-btn.pop { animation: catch-pop .5s cubic-bezier(.3, 1.7, .5, 1); }
@keyframes catch-pop { 35% { transform: scale(1.22); } }
.satchel-fly {
  position: absolute;
  z-index: 60;
  left: 0;
  top: 0;
  width: 84px;
  height: 84px;
  margin: -42px 0 0 -42px;
  pointer-events: none;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .5)) drop-shadow(0 0 10px rgba(255, 210, 120, .5));
}
/* Something to carry home: the vault pointer glows. */
.edge-pointer.laden { animation: laden 1.8s ease-in-out infinite; }
@keyframes laden { 0%, 100% { filter: drop-shadow(0 0 0 rgba(255, 205, 120, 0)); } 50% { filter: drop-shadow(0 0 10px rgba(255, 205, 120, .9)); } }

/* ---------- Back at the vault: the deposit scene ---------- */
.deposit {
  position: absolute;
  inset: 0;
  z-index: 52;
  overflow: hidden;
  --mx: 50%;
  --my: 55%;
  --ty: 70%;
}
.deposit[hidden] { display: none; }
.deposit-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--mx) var(--my), rgba(64, 36, 14, .93) 0%, rgba(24, 11, 5, .96) 45%, rgba(6, 3, 1, .985) 100%);
  opacity: 0;
  transition: opacity .5s ease;
}
.deposit.show .deposit-backdrop { opacity: 1; }
.deposit-stage { position: absolute; inset: 0; transition: transform .6s cubic-bezier(.2, 1, .3, 1); }
/* The summary comes up from below: the chest steps back to make room. */
.deposit.summary .deposit-stage { transform: translateY(-16%) scale(.82); }
.deposit-stage.shake { animation: shake .38s cubic-bezier(.36, .07, .19, .97); }
.deposit-stage.shake-big { animation: shake-big .5s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake-big {
  10%, 90% { transform: translate(-2px, 2px); }
  25%, 75% { transform: translate(6px, -4px); }
  40%, 60% { transform: translate(-7px, 4px); }
  50% { transform: translate(4px, 6px); }
}
.deposit-rays {
  position: absolute;
  left: var(--mx);
  top: var(--my);
  width: 1400px;
  height: 1400px;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, rgba(255, 222, 150, .16) 0deg 3deg, transparent 3deg 9deg, rgba(255, 222, 150, .08) 9deg 13deg, transparent 13deg 22deg);
  -webkit-mask-image: radial-gradient(circle, rgba(0, 0, 0, .95) 3%, transparent 28%);
  mask-image: radial-gradient(circle, rgba(0, 0, 0, .95) 3%, transparent 28%);
  opacity: 0;
  transition: opacity .6s ease;
  animation: spin 40s linear infinite;
  pointer-events: none;
}
.deposit.lit .deposit-rays { opacity: .75; }
.deposit.glare .deposit-rays { opacity: 1; }
.deposit-halo {
  position: absolute;
  left: var(--mx);
  top: var(--my);
  width: 460px;
  height: 460px;
  transform: translate(-50%, -50%) scale(.4);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 200, 110, .55) 0%, rgba(255, 170, 60, .18) 35%, transparent 62%);
  opacity: 0;
  transition: opacity .5s ease, transform .9s cubic-bezier(.2, .8, .2, 1);
  pointer-events: none;
}
.deposit.lit .deposit-halo { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.deposit.glare .deposit-halo { transform: translate(-50%, -50%) scale(1.25); }
.deposit-scene { position: absolute; inset: 0; width: 100%; height: 100%; }
.deposit-particles { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.deposit .flash { background: radial-gradient(circle at var(--mx) var(--my), rgba(255, 247, 222, .95), rgba(255, 210, 130, .35) 35%, transparent 70%); }
.deposit-head {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--safe-top) + 7%);
  text-align: center;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .6s ease .2s, transform .6s ease .2s;
}
.deposit.show .deposit-head { opacity: 1; transform: none; }
.deposit-label { font-family: var(--font-display); font-size: 11px; letter-spacing: .34em; text-transform: uppercase; color: rgba(234, 214, 166, .7); }
.deposit-title {
  margin: 4px 0 0;
  font-family: var(--font-logo);
  font-weight: 900;
  font-size: 30px;
  letter-spacing: .06em;
  background: linear-gradient(180deg, #fff3c9 0%, #f0c86e 40%, #a26f24 58%, #f6dc95 80%, #c08a35 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .85));
}
.deposit-callout {
  position: absolute;
  left: 8%;
  right: 8%;
  top: calc(var(--safe-top) + 20%);
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .08em;
  color: #f3dfaa;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .8), 0 0 14px rgba(255, 190, 90, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .45s ease;
}
.deposit-callout[data-kind='uncommon'] { color: #dbe6f6; }
.deposit-callout[data-kind='rare'] { color: #ffd77a; }
.deposit-callout[data-kind='legendary'] { color: #ffbf4d; }
.deposit-callout[data-kind='artifact'] { font-family: var(--font-logo); font-weight: 900; font-size: 24px; color: #ffe2a0; }
.deposit-callout.go { animation: callout 2.4s ease forwards; }
/* An artifact's name stays up while it hangs over the chest. */
.deposit-callout.hold { opacity: 1; animation: callout-in .5s ease; }
@keyframes callout-in { from { opacity: 0; transform: translateY(12px) scale(.92); } }
@keyframes callout {
  0% { opacity: 0; transform: translateY(12px) scale(.92); }
  12% { opacity: 1; transform: none; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-6px); }
}
.deposit-tally {
  position: absolute;
  left: 50%;
  top: var(--ty);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: opacity .3s ease;
}
.deposit-tally[hidden] { display: none; }
.dt-label { font-family: var(--font-display); font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: rgba(234, 214, 166, .7); }
.dt-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 36px;
  line-height: 1.1;
  color: #ffdf8e;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .85), 0 0 16px rgba(255, 190, 90, .5);
}
.dt-value.pop { animation: tally-pop .28s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes tally-pop { 40% { transform: scale(1.25); } }
.deposit-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + 22px);
  margin: 0;
  text-align: center;
  font-family: var(--font-text);
  font-style: italic;
  font-size: 14px;
  line-height: 1.25;
  color: rgba(234, 214, 166, .45);
  transition: opacity .3s ease;
}
.deposit.summary .deposit-hint, .deposit.summary .deposit-tally { opacity: 0; }
.deposit-summary {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 18px);
  width: min(calc(100% - 28px), 380px);
  padding: 16px 16px 14px;
  border-radius: 8px;
  background: var(--grain-soft), radial-gradient(120% 80% at 50% 0%, #f6ead0, #e6d2a4);
  box-shadow: 0 0 0 1px rgba(59, 36, 20, .5), 0 18px 40px rgba(0, 0, 0, .6);
  color: var(--ink);
  text-align: center;
  transform: translate(-50%, 130%);
  transition: transform .55s cubic-bezier(.2, 1.2, .3, 1);
}
.deposit.summary .deposit-summary { transform: translate(-50%, 0); }
.ds-title { margin: 0 0 10px; font-family: var(--font-display); font-size: 15px; letter-spacing: .22em; text-transform: uppercase; color: #6b4716; }
.ds-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 12px; max-height: 34vh; overflow: auto; padding: 10px 8px 2px; }
.ds-item { position: relative; display: flex; flex-direction: column; align-items: center; width: 58px; font-family: var(--font-text); }
.ds-item img { width: 52px; height: 52px; }
.ds-arts, .sv-arts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 10px; width: 100%; }
.ds-art { width: 104px; text-align: center; }
/* Many artifacts (a holiday's haul): smaller, three to a row. */
.ds-arts.many .ds-art, .sv-arts.many .sv-art { width: 78px; }
.ds-arts.many img, .sv-arts.many img { width: 60px; height: 60px; }
.ds-arts.many .ds-name, .sv-arts.many .sv-name { font-size: 12px; line-height: 1.1; }
.ds-arts.many .ds-note { display: none; }
.ds-items, .satchel-card .sv-items { scrollbar-width: thin; scrollbar-color: rgba(122, 74, 34, .45) transparent; }
.ds-art img { width: 84px; height: 84px; }
.ds-name { font-family: var(--font-display); font-weight: 700; font-size: 14px; }
.ds-note { font-style: italic; font-size: 13px; line-height: 1.2; color: #6b5034; }
.ds-count { font-family: var(--font-display); font-weight: 700; font-size: 12px; color: #7a4a22; }
.ds-actions { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 14px; }
.deposit.closing .deposit-backdrop, .deposit.closing .deposit-stage, .deposit.closing .deposit-head,
.deposit.closing .deposit-summary { opacity: 0; transition: opacity .4s ease; }

/* The mission at a glance: a paper tag pinned beside the mission button. */
.mission-tag {
  position: absolute;
  z-index: 11;
  left: 84px;
  top: calc(var(--safe-top) + 76px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 92px;
  max-width: calc(100% - 84px - 12px);
  padding: 5px 10px 6px;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  background: var(--grain-soft), linear-gradient(#f3e6c6, var(--paper-2));
  box-shadow: 0 0 0 1px rgba(59, 36, 20, .55), 0 4px 10px rgba(0, 0, 0, .45);
  transform: rotate(-1.5deg);
}
.mission-tag[hidden] { display: none; }
.mission-tag:active { transform: rotate(-1.5deg) scale(.95); }
.mt-label { font-family: var(--font-display); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: rgba(59, 36, 20, .75); }
.mt-value { font-family: var(--font-text); font-weight: 600; font-size: 16px; line-height: 1.1; white-space: nowrap; }
.mt-bar { display: block; align-self: stretch; height: 3px; margin-top: 3px; border-radius: 2px; background: rgba(59, 36, 20, .18); overflow: hidden; }
.mt-bar[hidden] { display: none; }
.mt-bar i { display: block; height: 100%; width: 0; background: var(--oxblood); transition: width .4s ease; }
.mission-tag.reached .mt-bar i { background: #3f6b2a; }

.card-overlay {
  position: absolute;
  inset: 0;
  z-index: 48;   /* above the vault journal, so a notebook page can open over it */
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 70px) 0 calc(var(--safe-bottom) + 40px);
}
.card-overlay[hidden] { display: none; }
.card-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(40, 20, 8, .55), rgba(8, 4, 2, .88));
  opacity: 0;
  transition: opacity .35s ease;
}
.card-overlay .paper-card {
  opacity: 0;
  transform: scaleY(.05) rotate(-2deg);
  transform-origin: 50% 50%;
  transition: transform .45s cubic-bezier(.2, 1.2, .4, 1), opacity .25s ease;
}
.card-overlay.show .card-backdrop { opacity: 1; }
.card-overlay.show .paper-card { opacity: 1; transform: rotate(-2deg); }
.card-deadline {
  margin: 4px 0 0;
  font-family: var(--font-text);
  font-style: italic;
  font-size: 14.5px;
  color: #6b5034;
  text-align: center;
}
.card-msg {
  min-height: 1.3em;
  margin: 10px 0 0;
  font-family: var(--font-text);
  font-style: italic;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.25;
  color: var(--oxblood);
  text-align: center;
}
/* The satchel card: what is carried home. */
.satchel-card .sv-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 6px; max-height: 46vh; overflow: auto; margin-top: 10px; padding: 2px; }
.sv-item { display: flex; flex-direction: column; align-items: center; width: 74px; font-family: var(--font-text); text-align: center; }
.sv-item img { width: 52px; height: 52px; }
.sv-art { width: 104px; }
.sv-art img { width: 84px; height: 84px; }
.sv-name { font-size: 12.5px; line-height: 1.12; }
.sv-art .sv-name { font-family: var(--font-display); font-weight: 700; font-size: 14px; }
.sv-count { font-family: var(--font-display); font-weight: 700; font-size: 12px; color: #7a4a22; }
.card-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.card-actions .btn-brass { margin-top: 10px; min-width: 0; width: 100%; }
#notebook-gate:not(.ready) { filter: grayscale(.6) brightness(.85); }
/* The close cross: one button in the top right corner of every screen that can simply be dismissed. */
.btn-x {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(232, 199, 130, .5);
  border-radius: 50%;
  background: rgba(20, 10, 4, .4);
  color: var(--cream);
  cursor: pointer;
}
.btn-x svg { display: block; width: 18px; height: 18px; }
.btn-x:active { color: var(--brass-hi); }
.btn-x[hidden] { display: none; }
/* On paper: inked and pinned in the card's corner. */
.btn-x.ink { border-color: rgba(59, 36, 20, .45); background: rgba(255, 246, 222, .35); color: var(--ink); }
.btn-x.ink:active { color: var(--oxblood); }
.card-x { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; }
.reveal-x { position: absolute; top: calc(var(--safe-top) + 14px); right: 14px; opacity: 0; transition: opacity .5s ease .3s; }
.reveal.info-in .reveal-x { opacity: 1; }
.reveal:not(.info-in) .reveal-x { pointer-events: none; }
.reveal.closing .reveal-x { opacity: 0; transition: opacity .4s ease; }
.btn-link {
  padding: 10px 14px;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(59, 36, 20, .7);
}

/* ---------- Debug panel ---------- */
.debug {
  position: absolute;
  z-index: 35;
  left: 44px;
  top: calc(var(--safe-top) + 6px);
  font-family: system-ui, sans-serif;
  font-size: 12px;
  color: #2a180c;
}
/* Same build as the menu button beside it: a bare brass glyph with a drop shadow. */
.debug-toggle {
  display: block;
  width: 40px;
  height: 40px;
  padding: 7px;
  border: 0;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .5));
  transition: transform .15s ease;
}
.debug-toggle svg { width: 100%; height: 100%; display: block; }
.debug-toggle:active { transform: scale(.9); }
.debug-body {
  display: none;
  margin-top: 6px;
  width: 230px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(245, 232, 200, .96);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}
.debug.open .debug-body { display: block; }
.debug h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.debug label { display: block; margin-bottom: 8px; }
.debug label > span { float: right; font-weight: 600; }
.debug select, .debug input[type=range] { width: 100%; margin-top: 3px; }
.debug .row { display: flex; gap: 6px; margin: 4px 0 6px; }
.debug .row button { flex: 1; padding: 5px; border-radius: 5px; border: 1px solid #8a6a40; background: #f8eed5; cursor: pointer; }
.debug .hint { margin: 4px 0 0; color: #6b5034; line-height: 1.4; }
.debug-body { max-height: min(70vh, 640px); overflow: auto; width: 250px; }
.debug fieldset { margin: 0 0 8px; padding: 6px 8px 4px; border: 1px solid rgba(107, 80, 52, .35); border-radius: 6px; }
.debug legend { padding: 0 4px; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6b5034; }
.debug label.check { display: flex; align-items: center; gap: 6px; }
.debug .seg { display: flex; margin-bottom: 8px; border: 1px solid #8a6a40; border-radius: 6px; overflow: hidden; }
.debug .seg button { flex: 1; padding: 5px 4px; border: 0; background: #f8eed5; cursor: pointer; font-size: 12px; }
.debug .seg button.on { background: #6b4716; color: #fbe9c0; }
.debug .readout { margin: 4px 0 2px; padding: 6px; border-radius: 4px; background: rgba(59, 36, 20, .08); font: 11px/1.45 ui-monospace, Consolas, monospace; white-space: pre-wrap; }
.debug.real .sim-only { display: none; }

.boot-error {
  position: absolute;
  inset: auto 16px 50% 16px;
  z-index: 100;
  padding: 14px;
  border-radius: 8px;
  background: #3a1410;
  color: #ffd9c9;
  font-family: system-ui, sans-serif;
}

@media (prefers-reduced-motion: reduce) {
  .reveal-rays, .medallion.ready .m-sheen, .medallion.ready::after { animation: none; }
}

/* ---------- Key symbols (notebook, gate) ---------- */
.card-symbols,
.gate-shards { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; }
.shards-label {
  margin-right: 4px;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: rgba(59, 36, 20, .7);
}
.shard-chip {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 34px;
  background: linear-gradient(160deg, #e9c9a0, #c99567);
  clip-path: polygon(8% 18%, 34% 0, 58% 8%, 82% 0, 100% 30%, 92% 62%, 100% 86%, 64% 100%, 30% 92%, 0 100%, 6% 60%);
}
.shard-chip svg { width: 25px; height: 25px; display: block; }
.shard-chip.empty {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: rgba(59, 36, 20, .45);
  background: rgba(201, 149, 103, .28);
}
.btn-brass[disabled] { cursor: default; filter: grayscale(.7) brightness(.8); }
.btn-brass[disabled]:active { transform: none; }

/* ---------- Tomb gate ---------- */
.gate {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: calc(var(--safe-top) + 22px) 16px calc(var(--safe-bottom) + 18px);
  overflow: hidden;
}
.gate[hidden] { display: none; }
.gate-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 46%, rgba(70, 44, 20, .94), rgba(10, 5, 2, .985) 72%);
  opacity: 0;
  transition: opacity .4s ease;
}
.gate.show .gate-backdrop { opacity: 1; }
.gate > :not(.gate-backdrop) {
  position: relative;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .5s ease .1s, transform .6s cubic-bezier(.2, .9, .3, 1) .1s;
}
.gate.show > :not(.gate-backdrop) { opacity: 1; transform: none; }
.gate-head { text-align: center; }
.gate-label {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: #d9a85a;
}
.gate-title {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  color: var(--brass-hi);
  text-shadow: 0 2px 6px rgba(0, 0, 0, .7);
}
.gate-stage { width: min(100%, 380px, 52vh); aspect-ratio: 1; }
.gate-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  touch-action: none;
  cursor: grab;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .6));
}
.gate-svg:active { cursor: grabbing; }
.gate-leaf { transition: transform 1.4s cubic-bezier(.55, 0, .2, 1); }
.gate.opening .gate-leaf.left { transform: translateX(-150px); }
.gate.opening .gate-leaf.right { transform: translateX(150px); }
.gate-lock {
  transform-box: view-box;
  transform-origin: 50% 50%;
  transition: opacity .6s ease, transform .9s ease;
}
.gate.solved .gate-ring { filter: drop-shadow(0 0 5px rgba(255, 214, 120, .95)); }
.gate.solved .gate-window { fill-opacity: .45; }
.gate.opening .gate-lock { opacity: 0; transform: scale(1.12); }
.gate-inside { opacity: 0; transition: opacity 1s ease .35s; }
.gate.opening .gate-inside { opacity: 1; }
.gate-foot { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 340px; text-align: center; }
.gate-shards { margin-top: 0; }
.gate-shards .shards-label { color: #d9a85a; }
.gate .shard-chip.empty { color: rgba(240, 210, 160, .6); background: rgba(201, 149, 103, .22); }
.gate-hint {
  min-height: 2.5em;
  margin: 0;
  font-family: var(--font-text);
  font-style: italic;
  font-size: 17px;
  line-height: 1.25;
  color: #ead3a4;
}
.gate > .gate-x { position: absolute; z-index: 1; top: calc(var(--safe-top) + 14px); right: 14px; }
