:root {
  color-scheme: dark;
  --bg: #0c0a08;
  --bg-soft: #17120d;
  --panel: rgba(28, 21, 14, 0.94);
  --panel-light: #ead8aa;
  --ink: #f6ecd2;
  --ink-dark: #261b10;
  --muted: #bcae91;
  --gold: #d6a94b;
  --gold-light: #f1d58b;
  --line: rgba(214, 169, 75, 0.34);
  --danger: #d9695f;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.44);
  --station-color: var(--gold);
  --red: #ef5350;
  --orange: #ff922b;
  --yellow: #ffd43b;
  --green: #51cf66;
  --blue: #4dabf7;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -15%, rgba(215, 169, 74, 0.2), transparent 42rem),
    linear-gradient(180deg, #13100c 0%, var(--bg) 62%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  pointer-events: none;
  opacity: 0.16;
  background-image:
    repeating-linear-gradient(45deg, transparent 0 22px, rgba(255, 235, 180, 0.035) 23px 24px),
    repeating-linear-gradient(-45deg, transparent 0 31px, rgba(255, 235, 180, 0.025) 32px 33px);
}

button,
a,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid #fff4c7;
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 1000;
  padding: 0.75rem 1.1rem;
  color: #111;
  background: #fff4c7;
  border-radius: 0 0 0.7rem 0.7rem;
  transform: translate(-50%, -120%);
}

.skip-link:focus {
  transform: translate(-50%, 0);
}

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--gold-light);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.centered {
  text-align: center;
}

.outline-button,
.text-button,
.danger-button,
.reveal-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.68rem 1rem;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.outline-button:hover,
.text-button:hover,
.reveal-link:hover {
  color: #171008;
  background: var(--gold-light);
  border-color: var(--gold-light);
}

.text-button:disabled,
.outline-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.danger-button {
  color: #ffd8d2;
  border-color: rgba(217, 105, 95, 0.55);
}

.danger-button:hover:not(:disabled) {
  color: #fff;
  background: #8e332c;
}

.toast {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: max(1rem, env(safe-area-inset-left));
  z-index: 100;
  width: max-content;
  max-width: min(34rem, calc(100% - 2rem));
  margin-inline: auto;
  padding: 0.85rem 1.1rem;
  color: #1d140b;
  text-align: center;
  background: #f6e8bd;
  border: 1px solid #fff4d0;
  border-radius: 0.8rem;
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.45);
}

.clipboard-fallback {
  position: fixed;
  top: -100vh;
  left: -100vw;
}

/* Shared five-station progress */

.team-progress {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 1rem;
}

.team-progress__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.team-progress__heading h2 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
}

.team-progress__heading strong {
  color: var(--gold-light);
  font-size: 1.35rem;
}

.team-progress__heading small {
  margin-left: 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.team-progress__list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.station-progress {
  --item-color: var(--gold);
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 76px;
  place-items: center;
  align-content: center;
  gap: 0.28rem;
  padding: 0.55rem 0.2rem;
  overflow: hidden;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(214, 169, 75, 0.4);
  border-color: color-mix(in srgb, var(--item-color) 44%, transparent);
  border-radius: 0.7rem;
}

.station-1 { --item-color: var(--red); }
.station-2 { --item-color: var(--orange); }
.station-3 { --item-color: var(--yellow); }
.station-4 { --item-color: var(--green); }
.station-5 { --item-color: var(--blue); }

.station-progress i {
  display: block;
  width: 0.78rem;
  height: 0.78rem;
  background: transparent;
  border: 2px solid var(--item-color);
  border-radius: 50%;
}

.station-progress span {
  overflow: hidden;
  font-size: 0.72rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-progress b {
  font-size: 0.62rem;
  font-weight: 700;
  color: #91866f;
  white-space: nowrap;
}

.station-progress.is-holding {
  color: var(--ink);
  background: rgba(214, 169, 75, 0.14);
  background: color-mix(in srgb, var(--item-color) 14%, transparent);
  box-shadow: inset 0 0 0 1px var(--item-color), 0 0 18px rgba(214, 169, 75, 0.35);
  box-shadow: inset 0 0 0 1px var(--item-color), 0 0 18px color-mix(in srgb, var(--item-color) 40%, transparent);
  animation: live-hold-pulse 0.72s ease-in-out infinite alternate;
}

.station-progress.is-holding i {
  background: var(--item-color);
  box-shadow: 0 0 16px var(--item-color);
}

.station-progress.is-holding b {
  color: var(--item-color);
}

.station-progress.is-complete {
  color: #160f08;
  background: var(--item-color);
  border-color: var(--item-color);
  box-shadow: 0 0 18px rgba(214, 169, 75, 0.35);
  box-shadow: 0 0 18px color-mix(in srgb, var(--item-color) 38%, transparent);
}

.station-progress.is-complete i {
  background: #160f08;
  border-color: #160f08;
  box-shadow: none;
}

.station-progress.is-complete b {
  color: #160f08;
}

@keyframes live-hold-pulse {
  from { opacity: 0.62; transform: translateY(0); }
  to { opacity: 1; transform: translateY(-2px); }
}

/* Participant */

.participant-page {
  --station-color: var(--gold);
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

.participant-page[data-station="1"] { --station-color: var(--red); }
.participant-page[data-station="2"] { --station-color: var(--orange); }
.participant-page[data-station="3"] { --station-color: var(--yellow); }
.participant-page[data-station="4"] { --station-color: var(--green); }
.participant-page[data-station="5"] { --station-color: var(--blue); }

.participant-shell {
  width: min(620px, 100%);
}

.seal-panel {
  position: relative;
  padding: clamp(1.25rem, 4vw, 2.2rem);
  overflow: hidden;
  background:
    linear-gradient(155deg, rgba(44, 32, 20, 0.98), rgba(20, 15, 10, 0.98));
  border: 1px solid rgba(214, 169, 75, 0.58);
  border-color: color-mix(in srgb, var(--station-color) 58%, #5e492a);
  border-radius: 1.5rem;
  box-shadow: var(--shadow), inset 0 0 38px rgba(214, 169, 75, 0.055);
}

.seal-panel::before,
.seal-panel::after {
  position: absolute;
  width: 7rem;
  height: 7rem;
  content: "";
  pointer-events: none;
  border: 1px solid rgba(214, 169, 75, 0.28);
  border-color: color-mix(in srgb, var(--station-color) 34%, transparent);
  transform: rotate(45deg);
}

.seal-panel::before { top: -5.4rem; left: -5.4rem; }
.seal-panel::after { right: -5.4rem; bottom: -5.4rem; }

.seal-halo {
  position: relative;
  display: grid;
  width: 86px;
  height: 86px;
  margin: 0 auto 1rem;
  place-items: center;
  color: var(--station-color);
  border: 1px solid rgba(214, 169, 75, 0.48);
  border-color: color-mix(in srgb, var(--station-color) 48%, transparent);
  box-shadow: 0 0 36px rgba(214, 169, 75, 0.18);
  border-radius: 50%;
  box-shadow: 0 0 36px color-mix(in srgb, var(--station-color) 20%, transparent);
}

.seal-halo__orbit {
  position: absolute;
  inset: 7px;
  border: 1px dashed rgba(214, 169, 75, 0.55);
  border-color: color-mix(in srgb, var(--station-color) 55%, transparent);
  border-radius: 50%;
  animation: orbit 16s linear infinite;
}

.seal-halo__symbol {
  font-family: Georgia, serif;
  font-size: 2.2rem;
  line-height: 1;
}

@keyframes orbit {
  to { transform: rotate(360deg); }
}

.participant-copy {
  text-align: center;
}

.seal-kicker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin: 0 0 0.55rem;
  color: var(--station-color);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.color-swatch {
  width: 0.72rem;
  height: 0.72rem;
  background: var(--station-color);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--station-color);
}

.seal-panel h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.7rem, 6vw, 2.55rem);
  line-height: 1.18;
  letter-spacing: -0.035em;
}

.participant-copy > p:last-child {
  max-width: 34rem;
  margin: 0.8rem auto 0;
  color: var(--muted);
  font-size: 0.91rem;
  line-height: 1.65;
}

.team-status {
  min-height: 1.5em;
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

.countdown {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.8rem;
  padding: 0.7rem 0.9rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.24);
  border-radius: 0.75rem;
}

.countdown strong {
  color: var(--station-color);
  font-variant-numeric: tabular-nums;
}

.seal-button {
  position: relative;
  isolation: isolate;
  display: flex;
  width: 100%;
  min-height: 74px;
  align-items: center;
  justify-content: center;
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  overflow: hidden;
  color: #fff8e8;
  font-size: 1rem;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  background: #15110d;
  border: 3px solid var(--station-color);
  border-radius: 1rem;
  box-shadow: 0 9px 28px rgba(0, 0, 0, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.seal-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 13px 34px rgba(0, 0, 0, 0.4), 0 0 22px rgba(214, 169, 75, 0.24);
  box-shadow: 0 13px 34px rgba(0, 0, 0, 0.4), 0 0 22px color-mix(in srgb, var(--station-color) 25%, transparent);
}

.seal-button:active:not(:disabled),
.seal-button.is-holding {
  transform: translateY(1px) scale(0.995);
}

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

.seal-button.is-pressed,
.seal-button.is-hold-complete {
  opacity: 1;
}

.hold-fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.hold-fill::-webkit-progress-bar {
  background: transparent;
}

.hold-fill::-webkit-progress-value {
  background: var(--station-color);
  transition: width 40ms linear;
}

.hold-fill::-moz-progress-bar {
  background: var(--station-color);
  transition: width 40ms linear;
}

.seal-button__content {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.45rem 0.9rem;
  background: rgba(10, 8, 6, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
}

.seal-button.is-holding {
  box-shadow: 0 0 30px rgba(214, 169, 75, 0.45);
  box-shadow: 0 0 30px color-mix(in srgb, var(--station-color) 48%, transparent);
}

.participant-footnote {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
  text-align: center;
}

.success-panel {
  margin-top: 1.2rem;
  text-align: center;
}

.success-mark {
  display: grid;
  width: 3.2rem;
  height: 3.2rem;
  margin: 0 auto 0.7rem;
  place-items: center;
  color: #171008;
  background: var(--gold-light);
  border-radius: 50%;
  box-shadow: 0 0 32px rgba(241, 213, 139, 0.42);
}

.success-panel h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 1.55rem;
}

.success-panel p {
  margin: 0.5rem 0;
  color: var(--muted);
}

.seal-button--link {
  --station-color: var(--gold-light);
}

.success-panel .text-button {
  margin-top: 0.65rem;
}

.participant-page.has-all-live-holds .seal-panel,
.participant-page.is-unlocked .seal-panel {
  box-shadow: var(--shadow), 0 0 44px rgba(214, 169, 75, 0.34);
}

.participant-page.is-offline .seal-halo {
  filter: grayscale(1);
  opacity: 0.52;
}

/* Admin */

.admin-page,
.gallery-page {
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
}

.admin-hero {
  padding-top: max(2.4rem, env(safe-area-inset-top));
}

.admin-hero__copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 2rem;
}

.admin-hero h1,
.gallery-hero h1,
.locked-shell h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.25rem, 7vw, 4.7rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.admin-hero__copy p {
  max-width: 42rem;
  margin: 0.9rem 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.admin-hero__copy strong {
  color: var(--gold-light);
}

.live-counter {
  min-width: 130px;
  padding: 0.9rem 1rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 1rem;
}

.live-counter > span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.live-counter strong {
  display: block;
  color: var(--gold-light);
  font-size: 2.2rem;
  font-variant-numeric: tabular-nums;
}

.live-counter small {
  margin-left: 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.team-progress__list--admin {
  margin-top: 1.4rem;
}

.team-progress__list--admin .station-progress {
  min-height: 88px;
}

.round-status {
  min-height: 1.6em;
  margin-top: 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.reveal-link {
  width: max-content;
  margin: 0.9rem auto 0;
  color: #161008;
  font-weight: 900;
  background: var(--gold-light);
}

.instruction-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  margin: 2.5rem 0;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.025);
  border-block: 1px solid var(--line);
}

.instruction-strip div {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.instruction-strip b {
  display: grid;
  width: 1.8rem;
  height: 1.8rem;
  place-items: center;
  color: #171008;
  background: var(--gold-light);
  border-radius: 50%;
}

.instruction-strip > i {
  width: 2.5rem;
  height: 1px;
  background: var(--line);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.section-heading h2,
.control-panel h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: clamp(1.45rem, 4vw, 2.2rem);
}

.section-heading .eyebrow,
.control-panel .eyebrow {
  margin-bottom: 0.3rem;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.loading-copy {
  grid-column: 1 / -1;
  color: var(--muted);
  text-align: center;
}

.qr-card {
  --station-color: var(--gold);
  position: relative;
  padding: 1rem;
  overflow: hidden;
  background: linear-gradient(155deg, #eadcb7, #caae72);
  border: 4px solid var(--station-color);
  border-radius: 1rem;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.3);
}

.qr-card.is-holding {
  animation: qr-live-hold 0.72s ease-in-out infinite alternate;
}

.qr-card.is-active {
  box-shadow: 0 0 0 2px #fff4c7, 0 0 32px rgba(214, 169, 75, 0.5);
  box-shadow: 0 0 0 2px #fff4c7, 0 0 32px color-mix(in srgb, var(--station-color) 54%, transparent);
}

@keyframes qr-live-hold {
  from { box-shadow: 0 0 6px color-mix(in srgb, var(--station-color) 24%, transparent); }
  to { box-shadow: 0 0 34px color-mix(in srgb, var(--station-color) 70%, transparent); }
}

.qr-card__heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink-dark);
}

.seal-symbol {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  color: #f9efcf;
  background: #2c2114;
  border-radius: 50%;
}

.qr-card__heading p,
.qr-card__heading h2 {
  margin: 0;
}

.qr-card__heading p {
  font-size: 0.65rem;
  font-weight: 800;
  opacity: 0.7;
}

.qr-card__heading h2 {
  overflow: hidden;
  font-family: Georgia, serif;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-state {
  padding: 0.28rem 0.5rem;
  color: #51422c;
  font-size: 0.62rem;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.36);
  border-radius: 999px;
}

.qr-card.is-holding .station-state,
.qr-card.is-active .station-state {
  color: #140e08;
  background: var(--station-color);
}

.qr-frame {
  position: relative;
  display: grid;
  width: min(100%, 270px);
  aspect-ratio: 1;
  margin: 1rem auto;
  place-items: center;
  overflow: hidden;
  background: #fffdf4;
  border: 1px solid rgba(45, 32, 16, 0.24);
  border-radius: 0.55rem;
}

.qr-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  align-content: center;
  gap: 0.4rem;
  padding: 1rem;
  color: #725d36;
  text-align: center;
  background:
    repeating-linear-gradient(45deg, #fffaf0 0 12px, #f4ead4 12px 24px);
}

.qr-placeholder__symbol {
  display: grid;
  width: 3.3rem;
  height: 3.3rem;
  place-items: center;
  color: #fff6dd;
  font-size: 1.45rem;
  background: #3a2b1a;
  border-radius: 50%;
}

.qr-placeholder small {
  max-width: 12rem;
  font-size: 0.68rem;
  line-height: 1.45;
}

.short-url {
  display: block;
  overflow: hidden;
  color: #352719;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.66rem;
  text-align: center;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qr-card__actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.qr-card .text-button {
  min-height: 40px;
  padding: 0.45rem 0.7rem;
  color: #2b2013;
  font-size: 0.7rem;
  font-weight: 800;
  border-color: rgba(43, 32, 19, 0.34);
}

.control-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 2rem;
  padding: 1.25rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 1rem;
}

.control-panel h2 {
  overflow-wrap: anywhere;
}

.control-panel p:last-child {
  max-width: 42rem;
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.control-panel__actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
}

/* Gallery */

.gallery-hero {
  padding-top: max(2.4rem, env(safe-area-inset-top));
  text-align: center;
}

.gallery-hero__seal {
  display: grid;
  width: 4.4rem;
  height: 4.4rem;
  margin: 0 auto 0.9rem;
  place-items: center;
  color: var(--gold-light);
  font-family: Georgia, serif;
  font-size: 2.1rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: 0 0 38px rgba(214, 169, 75, 0.16);
}

.gallery-hero > p:not(.eyebrow) {
  margin: 0.9rem 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.discovery-count {
  width: max-content;
  margin: 1rem auto 0;
  padding: 0.55rem 0.9rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.discovery-count strong {
  margin-left: 0.35rem;
  color: var(--gold-light);
  font-size: 1.2rem;
}

.gallery-main {
  margin-top: 2rem;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 1rem;
}

.character-card {
  grid-column: span 2;
  min-width: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 0.9rem;
  perspective: 1000px;
  -webkit-perspective: 1000px;
}

.character-card:nth-child(6) { grid-column: 2 / span 2; }
.character-card:nth-child(7) { grid-column: 4 / span 2; }
.character-card:nth-child(8) { grid-column: 6 / span 2; }
.character-card:nth-child(9) { grid-column: 8 / span 2; }

.character-card__inner {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 0.72;
  transition: transform 620ms cubic-bezier(0.2, 0.75, 0.2, 1);
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

.character-card:hover .character-card__inner {
  transform: translateY(-4px);
}

.character-card.is-flipped .character-card__inner,
.character-card.is-flipped:hover .character-card__inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: hidden;
  border: 4px double #6c4e22;
  border-radius: 0.8rem;
  box-shadow: 0 13px 30px rgba(0, 0, 0, 0.36);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.card-face::after {
  position: absolute;
  inset: 8px;
  content: "";
  pointer-events: none;
  border: 1px solid rgba(91, 61, 24, 0.3);
  border-radius: 0.45rem;
}

.card-front {
  flex-direction: column;
  color: var(--ink-dark);
  background: #d9c28c;
}

.portrait {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  background-color: #bf9e62;
  background-image: url("/assets/egyptian-cast-sprite.jpg");
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 300% 300%;
  filter: saturate(0.9) contrast(1.03);
}

.portrait-0 .portrait { background-position: 0% 0%; }
.portrait-1 .portrait { background-position: 50% 0%; }
.portrait-2 .portrait { background-position: 100% 0%; }
.portrait-3 .portrait { background-position: 0% 50%; }
.portrait-4 .portrait { background-position: 50% 50%; }
.portrait-5 .portrait { background-position: 100% 50%; }
.portrait-6 .portrait { background-position: 0% 100%; }
.portrait-7 .portrait { background-position: 50% 100%; }
.portrait-8 .portrait { background-position: 100% 100%; }

.card-front__copy {
  position: relative;
  z-index: 1;
  display: grid;
  flex: 0 0 29%;
  place-items: center;
  align-content: center;
  padding: 0.6rem 0.4rem;
  background:
    linear-gradient(180deg, rgba(255, 245, 214, 0.75), rgba(207, 177, 113, 0.92));
}

.character-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.88rem, 1.8vw, 1.15rem);
  font-weight: 800;
}

.character-meta {
  display: grid;
  width: 1.45rem;
  height: 1.45rem;
  margin-top: 0.22rem;
  place-items: center;
  color: #f9edca;
  font-size: 0.65rem;
  background: #4a351b;
  border-radius: 50%;
}

.card-hint {
  margin-top: 0.28rem;
  font-size: clamp(0.52rem, 1.15vw, 0.67rem);
  opacity: 0.67;
}

.card-back {
  display: grid;
  place-items: center;
  align-content: center;
  padding: 1rem;
  color: #291c0e;
  text-align: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 248, 218, 0.9), transparent 12rem),
    linear-gradient(145deg, #e8d29c, #c19a55);
  transform: rotateY(180deg);
}

.back-ornament {
  color: #7a5828;
  font-size: 1.5rem;
}

.back-name {
  margin-top: 0.55rem;
  font-family: Georgia, serif;
  font-size: clamp(0.8rem, 1.6vw, 1rem);
  font-weight: 800;
}

.relationship {
  display: block;
  margin-top: 1rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.95rem, 2vw, 1.25rem);
  font-weight: 900;
  line-height: 1.45;
  word-break: keep-all;
}

.card-back .card-hint {
  position: absolute;
  right: 0;
  bottom: 1.25rem;
  left: 0;
}

.gallery-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 2.2rem;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

.gallery-footer span {
  color: var(--gold);
}

/* Locked, landing, and error pages */

.locked-page {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding:
    max(1.25rem, env(safe-area-inset-top))
    max(1.25rem, env(safe-area-inset-right))
    max(1.25rem, env(safe-area-inset-bottom))
    max(1.25rem, env(safe-area-inset-left));
}

.locked-shell {
  width: min(640px, 100%);
  padding: clamp(1.4rem, 6vw, 3rem);
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  box-shadow: var(--shadow);
}

.locked-symbol {
  display: grid;
  width: 5rem;
  height: 5rem;
  margin: 0 auto 1rem;
  place-items: center;
  color: var(--gold-light);
  font-family: Georgia, serif;
  font-size: 2.2rem;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.locked-shell h1 {
  font-size: clamp(2rem, 8vw, 3.4rem);
}

.locked-shell > p:not(.eyebrow) {
  margin: 1rem auto;
  color: var(--muted);
  line-height: 1.65;
}

.locked-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 20rem;
  margin: 1.3rem auto 0;
  padding: 0.8rem 1rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
}

.locked-progress strong {
  color: var(--gold-light);
  font-size: 1.3rem;
}

.connection-state {
  min-height: 1.5em;
  font-size: 0.78rem;
}

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

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

  .character-card,
  .character-card:nth-child(n) {
    grid-column: auto;
  }

  .character-card:last-child {
    grid-column: 2;
  }
}

@media (max-width: 700px) {
  .page-shell {
    width: min(calc(100% - 24px), 1180px);
  }

  .admin-hero__copy {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 1rem;
  }

  .live-counter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
  }

  .live-counter > span,
  .live-counter strong {
    display: initial;
  }

  .team-progress__list {
    gap: 0.3rem;
  }

  .station-progress,
  .team-progress__list--admin .station-progress {
    min-height: 70px;
    padding-inline: 0.1rem;
  }

  .station-progress span {
    font-size: 0.66rem;
  }

  .station-progress b {
    font-size: 0.54rem;
  }

  .instruction-strip {
    grid-template-columns: 1fr;
    gap: 0.65rem;
    padding-inline: 0.5rem;
  }

  .instruction-strip > i {
    width: 1px;
    height: 0.8rem;
    margin-inline: auto;
  }

  .section-heading {
    align-items: center;
  }

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

  .control-panel {
    align-items: stretch;
    flex-direction: column;
    gap: 1rem;
  }

  .control-panel__actions {
    justify-content: flex-start;
  }

  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .character-card:last-child {
    grid-column: 1 / -1;
    width: calc(50% - 0.375rem);
    margin-inline: auto;
  }
}

@media (max-width: 420px) {
  .participant-page {
    align-items: start;
    padding-inline: max(0.7rem, env(safe-area-inset-left), env(safe-area-inset-right));
  }

  .participant-shell {
    padding-top: 0.3rem;
  }

  .seal-panel {
    padding: 1rem 0.85rem;
    border-radius: 1.15rem;
  }

  .seal-halo {
    width: 70px;
    height: 70px;
    margin-bottom: 0.75rem;
  }

  .seal-halo__symbol {
    font-size: 1.75rem;
  }

  .team-progress {
    padding: 0.7rem 0.55rem;
  }

  .team-progress__heading {
    margin-bottom: 0.6rem;
  }

  .station-progress {
    min-height: 64px;
  }

  .station-progress span {
    font-size: 0.6rem;
  }

  .station-progress b {
    font-size: 0.49rem;
  }

  .seal-button {
    min-height: 68px;
  }

  .gallery-hero h1 {
    font-size: 2.3rem;
  }

  .card-face {
    border-width: 3px;
  }

  .relationship {
    font-size: 0.88rem;
  }
}

@supports not (aspect-ratio: 1 / 1) {
  .qr-frame {
    height: 0;
    padding-bottom: 100%;
  }

  .qr-frame > * {
    position: absolute;
    inset: 0;
  }

  .character-card__inner {
    height: 0;
    padding-bottom: 138.9%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  :root {
    color-scheme: light;
  }

  body {
    color: #1e160d;
    background: #fff;
  }

  body::before,
  .no-print,
  .toast,
  .round-status,
  .team-progress__list--admin,
  .control-panel {
    display: none !important;
  }

  .admin-hero {
    padding-top: 0;
  }

  .admin-hero__copy p,
  .live-counter {
    display: none;
  }

  .qr-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8mm;
  }

  .qr-card {
    break-inside: avoid;
    box-shadow: none;
  }
}
