:root {
  --pe-bg: #0c0d12;
  --pe-panel: #12141d;
  --pe-panel-soft: #191c28;
  --pe-text: #f5f1e8;
  --pe-muted: #b7b1a5;
  --pe-gold: #d4b15a;
  --pe-gold-soft: rgba(212, 177, 90, .24);
  --pe-line: rgba(255,255,255,.08);
  --pe-focus: #ffffff;
}

html.pe-is-open,
html.pe-is-open body {
  overflow: hidden !important;
  overscroll-behavior: none;
}

.pe-overlay[hidden] { display: none !important; }
.pe-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: 20px;
  font-family: inherit;
  color: var(--pe-text);
}
.pe-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 9, .94);
  backdrop-filter: blur(7px);
}
.pe-dialog {
  position: relative;
  width: min(960px, 100%);
  max-height: min(860px, calc(100vh - 28px));
  overflow: auto;
  border: 1px solid rgba(212,177,90,.18);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(20,22,31,.98), rgba(11,12,18,.99));
  box-shadow: 0 22px 80px rgba(0,0,0,.5);
  padding: clamp(18px, 3vw, 34px);
}
.pe-topline,
.pe-heading-row,
.pe-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.pe-topline { margin-bottom: 18px; }
.pe-status-wrap,
.pe-progress { display: inline-flex; align-items: center; gap: 8px; }
.pe-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--pe-gold);
  box-shadow: 0 0 18px rgba(212,177,90,.75);
}
.pe-status,
.pe-progress-label,
.pe-progress-number {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
}
.pe-progress-label { color: var(--pe-muted); }
.pe-progress-number { color: var(--pe-gold); min-width: 44px; text-align: right; }
.pe-kicker {
  margin: 0 0 6px;
  color: var(--pe-gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
}
.pe-title {
  margin: 0;
  color: var(--pe-text);
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.05;
}
.pe-counter {
  display: grid;
  justify-items: end;
  min-width: 120px;
}
.pe-counter-value {
  color: var(--pe-gold);
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 800;
  line-height: 1;
}
.pe-counter-label {
  color: var(--pe-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.pe-game-shell {
  margin-top: 26px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(220px, .72fr);
  gap: 20px;
}
.pe-game {
  position: relative;
  min-height: 390px;
  overflow: hidden;
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 50%, rgba(212,177,90,.035), transparent 34%),
    #0a0c13;
  border: 1px solid rgba(255,255,255,.07);
  touch-action: none;
  outline: none;
}
.pe-game:focus-visible {
  outline: 2px solid var(--pe-focus);
  outline-offset: 3px;
}
.pe-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, transparent 0, black 9%, black 91%, transparent 100%);
}
.pe-light {
  position: absolute;
  width: 170px;
  height: 170px;
  margin: -85px 0 0 -85px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(224,194,113,.22) 0, rgba(212,177,90,.11) 32%, rgba(212,177,90,.03) 58%, transparent 72%);
  filter: blur(1px);
  transition: opacity .18s ease;
}
.pe-player {
  position: absolute;
  z-index: 4;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #fff8d8 0, #f2d67e 34%, #b88d2c 100%);
  box-shadow: 0 0 0 5px rgba(212,177,90,.09), 0 0 30px rgba(212,177,90,.5);
  user-select: none;
  pointer-events: none;
}
.pe-player span {
  position: absolute;
  top: 45px;
  color: #f4e8c4;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
  white-space: nowrap;
}
.pe-target {
  position: absolute;
  z-index: 3;
  width: 70px;
  height: 70px;
  margin: -35px 0 0 -35px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: default;
}
.pe-frame {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border: 3px solid #b48d3d;
  background: linear-gradient(135deg, #24291f, #6e5e2d 43%, #1b2433);
  box-shadow: 0 0 0 2px #5f461d, 0 0 28px rgba(212,177,90,.32);
  transform: rotate(-2deg);
}
.pe-art-symbol {
  display: grid;
  place-items: center;
  width: 80%;
  height: 80%;
  background: rgba(255,255,255,.88);
  color: #171922;
  font-size: 26px;
  font-weight: 900;
  overflow: hidden;
}
.pe-target[data-accent="blue"] .pe-art-symbol { background: linear-gradient(135deg, #edf5ff, #456a96); }
.pe-target[data-accent="orange"] .pe-art-symbol { background: linear-gradient(135deg, #ffe9b1, #dc6f3d); }
.pe-target[data-accent="red"] .pe-art-symbol { background: linear-gradient(135deg, #f3d7c7, #9b2f32); }
.pe-target[data-accent="cyan"] .pe-art-symbol { background: linear-gradient(135deg, #d9ffff, #3d8a9c); }
.pe-target[data-accent="violet"] .pe-art-symbol { background: linear-gradient(135deg, #ede0ff, #5c467e); }
.pe-target[data-accent="green"] .pe-art-symbol { background: linear-gradient(135deg, #ecf7d8, #4f7241); }
.pe-target[data-accent="yellow"] .pe-art-symbol { background: linear-gradient(135deg, #fff8c9, #d2a53d); }
.pe-target[data-accent="bronze"] .pe-art-symbol { background: linear-gradient(135deg, #e4c5a3, #8f5b35); }
.pe-target[data-accent="gold"] .pe-art-symbol { background: linear-gradient(135deg, #fff4c5, #af8b31); }
.pe-target.pe-discovered { animation: pe-discover .48s ease both; pointer-events: none; }
@keyframes pe-discover {
  0% { transform: scale(1); opacity: 1; }
  55% { transform: scale(1.18); opacity: .96; }
  100% { transform: scale(.82); opacity: 0; }
}
.pe-card {
  min-height: 220px;
  align-self: stretch;
  border-radius: 20px;
  padding: 24px;
  border: 1px solid rgba(212,177,90,.17);
  background: linear-gradient(180deg, rgba(212,177,90,.08), rgba(255,255,255,.025));
}
.pe-card-eyebrow {
  margin: 0 0 18px;
  color: var(--pe-gold);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 10px;
  font-weight: 800;
}
.pe-card h3 {
  margin: 0 0 12px;
  color: var(--pe-text);
  font-size: 24px;
  line-height: 1.12;
}
.pe-card-meta,
.pe-card-place {
  color: var(--pe-muted);
  line-height: 1.55;
}
.pe-card-meta { margin: 0 0 8px; }
.pe-card-place { margin: 0; font-size: 13px; }
.pe-footer-row { margin-top: 20px; }
.pe-footer-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pe-demo-close { background: rgba(255,255,255,.06); }
.pe-instruction { margin: 0; color: var(--pe-muted); font-size: 13px; }
.pe-minimise,
.pe-demo-close,
.pe-demo-button {
  appearance: none;
  border: 1px solid rgba(212,177,90,.36);
  border-radius: 999px;
  background: rgba(212,177,90,.08);
  color: var(--pe-text);
  padding: 9px 14px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.pe-minimise:hover,
.pe-minimise:focus-visible,
.pe-demo-close:hover,
.pe-demo-close:focus-visible,
.pe-demo-button:hover,
.pe-demo-button:focus-visible {
  border-color: var(--pe-gold);
  outline: none;
}
.pe-overlay.pe-minimised .pe-heading-row,
.pe-overlay.pe-minimised .pe-game-shell,
.pe-overlay.pe-minimised .pe-instruction {
  display: none;
}
.pe-overlay.pe-minimised .pe-dialog {
  width: min(520px, 100%);
}
.pe-overlay.pe-minimised .pe-topline { margin-bottom: 0; }
.pe-overlay.pe-success .pe-status-dot {
  background: #9bd3a5;
  box-shadow: 0 0 18px rgba(155,211,165,.6);
}
.pe-overlay.pe-success .pe-progress-number { color: #9bd3a5; }
.pe-overlay.pe-error .pe-status-dot { background: #efb1a9; }

/* Admin */
.pe-admin-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  max-width: 1200px;
  margin-top: 22px;
}
.pe-admin-panel {
  background: #fff;
  border: 1px solid #dcdcde;
  border-radius: 8px;
  padding: 20px;
}
.pe-admin-code { grid-column: 1 / -1; }
.pe-admin-code pre {
  overflow: auto;
  padding: 16px;
  border-radius: 8px;
  background: #111827;
  color: #f9fafb;
}

@media (max-width: 780px) {
  .pe-overlay { padding: 8px; }
  .pe-dialog { max-height: calc(100vh - 16px); border-radius: 18px; padding: 16px; }
  .pe-heading-row { align-items: flex-start; }
  .pe-counter { min-width: 84px; }
  .pe-counter-label { max-width: 84px; text-align: right; }
  .pe-game-shell { grid-template-columns: 1fr; gap: 12px; }
  .pe-game { min-height: min(52vh, 410px); }
  .pe-card { min-height: 0; padding: 16px; }
  .pe-card h3 { font-size: 19px; }
  .pe-footer-row { align-items: flex-end; }
  .pe-admin-columns { grid-template-columns: 1fr; }
  .pe-admin-code { grid-column: auto; }
}

@media (max-width: 430px) {
  .pe-topline { align-items: flex-start; }
  .pe-progress { display: grid; gap: 0; justify-items: end; }
  .pe-title { font-size: 27px; }
  .pe-game { min-height: 390px; }
  .pe-target { width: 58px; height: 58px; margin: -29px 0 0 -29px; }
  .pe-player { width: 32px; height: 32px; margin: -16px 0 0 -16px; }
}

@media (prefers-reduced-motion: reduce) {
  .pe-target.pe-discovered { animation: none; opacity: 0; }
  .pe-light { transition: none; }
  .pe-dialog { scroll-behavior: auto; }
}

.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}
