/* PERJUANGAN style.css v2.2 — mode select + learn + i18n */
/* ==========================================================================
   PERJUANGAN — style.css
   Design tokens
   Color   : --ink #0A0908 (near-black), --panel #17130F, --red #C8102E,
             --red-deep #7A0A1E, --parch #F3EEE1 (warm white), --gold #C9A227,
             --gold-bright #EAC873
   Type    : "Cinzel" (display serif, cinematic titles) · "Special Elite"
             (typewriter mono, tracked eyebrow labels — echoes the
             Proklamasi manuscript) · "Inter" (UI/body sans)
   Signature: the hand-simulated cloth flag (see flag.js) is the one bold
              gesture; everything else stays quiet, dark and disciplined.
   ========================================================================== */

:root {
  --ink: #0a0908;
  --ink-2: #120f0c;
  --panel: #18140f;
  --panel-2: #1f1a14;
  --red: #c8102e;
  --red-deep: #7a0a1e;
  --parch: #f3eee1;
  --parch-dim: rgba(243, 238, 225, 0.62);
  --parch-faint: rgba(243, 238, 225, 0.36);
  --gold: #c9a227;
  --gold-bright: #eac873;
  --line: rgba(201, 162, 39, 0.22);
  --shadow-black: rgba(0, 0, 0, 0.55);

  --font-display: "Cinzel", "Georgia", serif;
  --font-mono: "Special Elite", "Courier New", monospace;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;

  --ease-cinema: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ink);
  color: var(--parch);
  font-family: var(--font-ui);
  overflow: hidden;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* -------------------------------------------------------------------- */
/* Ambient grain texture, applied subtly to dark surfaces                */
/* -------------------------------------------------------------------- */
.grain::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* -------------------------------------------------------------------- */
/* Screens                                                                */
/* -------------------------------------------------------------------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 100% at 50% 30%, var(--ink-2) 0%, var(--ink) 65%, #000 100%);
  opacity: 0;
  transition: opacity 0.6s var(--ease-cinema), filter 0.6s var(--ease-cinema);
}

.screen.is-active {
  opacity: 1;
}

.screen.is-leaving {
  opacity: 0;
  filter: blur(10px);
  transition: opacity 0.7s var(--ease-cinema), filter 0.7s var(--ease-cinema);
}

/* -------------------------------------------------------------------- */
/* Entrance 1 — Flag splash                                               */
/* -------------------------------------------------------------------- */
#entrance1 {
  cursor: pointer;
  touch-action: manipulation;
  opacity: 1; /* controlled via .bg-in for the guideline-timed fade */
  transition: opacity 0.9s ease, filter 0.7s var(--ease-cinema);
}
#entrance1:not(.bg-in) {
  opacity: 0;
}
#entrance1.bg-in {
  opacity: 1;
}
#entrance1.is-leaving,
#entrance1.bg-in.is-leaving {
  opacity: 0;
  filter: blur(12px) brightness(0.7);
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 35%, rgba(0, 0, 0, 0.75) 100%);
}

.flag-wrap {
  pointer-events: none;
  position: relative;
  flex-shrink: 0;
  width: min(70vw, 520px);
  height: min(52vw, 390px);
  max-width: 520px;
  max-height: 390px;
  min-width: 220px;
  min-height: 165px;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.9s ease, transform 0.9s ease;
  margin-bottom: 0.25rem;
}
.flag-wrap.is-in {
  opacity: 1 !important;
  transform: scale(1);
}
#flagCanvas {
  pointer-events: none;
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.e1-text {
  margin-top: 2.4rem;
  text-align: center;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.9s var(--ease-cinema), transform 0.9s var(--ease-cinema);
}
.e1-text.is-in {
  opacity: 1;
  transform: translateY(0);
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--parch-dim);
  margin: 0 0 0.9rem;
}
.title-display {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.8rem, 5vw, 3.4rem);
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--parch);
  text-shadow: 0 6px 40px rgba(0, 0, 0, 0.6);
}
.title-accent {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1rem, 2.4vw, 1.5rem);
  letter-spacing: 0.14em;
  color: var(--red);
  margin: 0.6rem 0 0;
  text-transform: uppercase;
}

.e1-hint {
  position: fixed; /* viewport bottom — never overlaps title */
  left: 0;
  right: 0;
  bottom: 28px;
  top: auto;
  width: 100%;
  margin: 0;
  padding: 0 1rem;
  text-align: center;
  z-index: 20;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--parch-faint);
  opacity: 0;
  transition: opacity 1s ease;
  animation: none;
}
.e1-hint.is-in {
  opacity: 0.75;
  animation: hintPulse 2.6s ease-in-out infinite;
}
/* Hide hint when not on entrance 1 */
#entrance1:not(.is-active) .e1-hint,
#entrance1[hidden] .e1-hint {
  display: none !important;
  opacity: 0 !important;
}
@keyframes hintPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* Keep title block clear of the bottom hint */
.e1-text {
  position: relative;
  z-index: 2;
  padding-bottom: 0.5rem;
}
.title-accent {
  margin-bottom: 0.25rem;
}

/* -------------------------------------------------------------------- */
/* Entrance 2 — Credits                                                   */
/* -------------------------------------------------------------------- */
.credits {
  text-align: center;
  max-width: 560px;
  padding: 0 1.5rem;
}
.credits .eyebrow {
  margin-bottom: 1.1rem;
}
.credits h2 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: 0 0 0.4rem;
}
.credits .maker {
  font-family: var(--font-mono);
  color: var(--gold-bright);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  margin: 0 0 2.6rem;
}
.credits-divider {
  width: 64px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 0 auto 2.2rem;
}

/* -------------------------------------------------------------------- */
/* Buttons                                                                */
/* -------------------------------------------------------------------- */
.btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--parch);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.95rem 2.1rem;
  border-radius: 2px;
  transition: all 0.25s ease;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn--primary {
  background: linear-gradient(180deg, var(--red) 0%, var(--red-deep) 100%);
  border-color: transparent;
  color: var(--parch);
  box-shadow: 0 8px 30px rgba(200, 16, 46, 0.35);
}
.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 36px rgba(200, 16, 46, 0.5);
}
.btn--primary:disabled {
  background: #2a2622;
  color: var(--parch-faint);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}
.btn--ghost {
  color: var(--parch-dim);
  border-color: var(--line);
}
.btn--ghost:hover {
  border-color: var(--gold);
  color: var(--parch);
}
.btn--danger {
  border-color: var(--red);
  color: var(--red);
}
.btn--danger:hover {
  background: var(--red);
  color: var(--parch);
}

/* -------------------------------------------------------------------- */
/* Main Map — header                                                      */
/* -------------------------------------------------------------------- */
#mainMap {
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}
#mainMap.is-active {
  opacity: 1;
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.6rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent);
  z-index: 5;
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.brand-mark {
  display: inline-block;
  width: 26px;
  height: 18px;
  border-radius: 1px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}
.brand-mark span {
  display: block;
  height: 50%;
}
.brand-mark .top { background: var(--red); }
.brand-mark .bottom { background: var(--parch); }
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.06em;
}
.brand-version {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--parch-faint);
  letter-spacing: 0.05em;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}
.progress-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}
.progress-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--gold-bright);
  border: 1px solid var(--line);
  padding: 0.42rem 0.8rem;
  border-radius: 999px;
}
.progress-track {
  width: 100px;
  height: 3px;
  border-radius: 999px;
  background: rgba(243, 238, 225, 0.12);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4caf6a, var(--gold-bright));
  box-shadow: 0 0 8px rgba(234, 200, 115, 0.6);
  transition: width 0.5s var(--ease-cinema);
}
.dev-badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: var(--ink);
  background: var(--gold-bright);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
}

/* -------------------------------------------------------------------- */
/* Main Map — map area                                                    */
/* -------------------------------------------------------------------- */
.map-body {
  position: relative;
  flex: 1;
  overflow: hidden;
}
#mapWrap {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Abstract archipelago silhouette + fog layers, ambient only */
.map-silhouette {
  position: absolute;
  inset: 0;
  opacity: 0.9;
}
.fog-layer {
  position: absolute;
  inset: -10%;
  background: radial-gradient(ellipse 60% 40% at 20% 85%, rgba(122, 10, 30, 0.16), transparent 60%),
    radial-gradient(ellipse 50% 35% at 85% 20%, rgba(201, 162, 39, 0.08), transparent 60%);
  animation: fogDrift 24s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes fogDrift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-1.5%, 1%) scale(1.03); }
}

/* Frame the composition and pull focus toward the center of the map,
   matching the vignette language already used on the entrance screens. */
.map-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, transparent 40%, rgba(0, 0, 0, 0.65) 100%);
}

/* Drifting embers — small ambient motes for atmosphere, purely decorative. */
.embers-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.ember {
  position: absolute;
  bottom: -4%;
  width: var(--ember-size, 3px);
  height: var(--ember-size, 3px);
  border-radius: 50%;
  background: var(--gold-bright);
  opacity: 0;
  filter: blur(0.3px);
  box-shadow: 0 0 6px 1px rgba(234, 200, 115, 0.7);
  animation: emberRise var(--ember-duration, 14s) linear infinite;
  animation-delay: var(--ember-delay, 0s);
}
@keyframes emberRise {
  0% { transform: translate(0, 0); opacity: 0; }
  8% { opacity: 0.75; }
  85% { opacity: 0.4; }
  100% { transform: translate(var(--ember-drift, 4vw), -112vh); opacity: 0; }
}

#routeSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.route-base {
  fill: none;
  stroke: rgba(243, 238, 225, 0.2);
  stroke-width: 0.35;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.route-next {
  fill: none;
  stroke: var(--gold-bright);
  stroke-width: 0.45;
  stroke-linecap: round;
  stroke-dasharray: 2.2 2.2;
  vector-effect: non-scaling-stroke;
  opacity: 0;
  transition: opacity 0.5s ease;
  filter: drop-shadow(0 0 3px rgba(234, 200, 115, 0.6));
  animation: routeNextFlow 1.4s linear infinite;
}
@keyframes routeNextFlow {
  to { stroke-dashoffset: -4.4; }
}
.route-progress {
  fill: none;
  stroke: url(#routeGradient);
  stroke-width: 0.45;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  transition: opacity 0.5s ease;
  filter: drop-shadow(0 0 4px rgba(201, 162, 39, 0.5));
}

#nodesLayer {
  position: absolute;
  inset: 0;
}

.node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: none;
  color: var(--parch);
  padding: 0;
  width: 84px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s ease;
}
.node:hover:not(.node--locked) {
  transform: translate(-50%, -50%) scale(1.06);
}
.node__shadow {
  position: absolute;
  bottom: -6px;
  left: 50%;
  width: 34px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.55), transparent 70%);
  transform: translateX(-50%);
  z-index: -1;
}
.node__orbit {
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 1px dashed transparent;
  pointer-events: none;
}
.node--available .node__orbit {
  border-color: rgba(234, 200, 115, 0.55);
  animation: nodeOrbitSpin 9s linear infinite;
}
@keyframes nodeOrbitSpin {
  to { transform: rotate(360deg); }
}
.node__ring {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: radial-gradient(circle at 40% 35%, var(--panel-2), var(--panel));
  display: flex;
  align-items: center;
  justify-content: center;
}
.node__icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--parch-dim);
}
.node__icon svg {
  width: 20px;
  height: 20px;
}
.node__order {
  position: absolute;
  top: -6px;
  right: -4px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--ink);
  background: var(--parch-faint);
  padding: 0.05rem 0.3rem;
  border-radius: 999px;
}
.node__label {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--parch-dim);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

.node--locked .node__ring {
  opacity: 0.45;
  filter: grayscale(0.6);
}
.node--locked .node__label {
  opacity: 0.45;
}
.node--locked { cursor: not-allowed; }

.node--available .node__ring {
  border-color: var(--gold);
  box-shadow: 0 0 0 0 rgba(201, 162, 39, 0.5);
  animation: nodePulse 2.2s ease-out infinite;
}
.node--available .node__icon {
  color: var(--gold-bright);
}
.node--available .node__order {
  background: var(--gold-bright);
}
@keyframes nodePulse {
  0% { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0.45); }
  70% { box-shadow: 0 0 0 14px rgba(201, 162, 39, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0); }
}

.node--completed .node__ring {
  border-color: #4caf6a;
  background: radial-gradient(circle at 40% 35%, #1c2b1f, var(--panel));
}
.node--completed .node__icon {
  color: #7ee0a0;
}
.node--completed .node__order {
  background: #4caf6a;
  color: #0a1a0f;
}
.node--completed .node__ring::after {
  content: "✓";
  position: absolute;
  bottom: -4px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #4caf6a;
  color: #0a1a0f;
  font-size: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.node:focus-visible .node__ring {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

/* -------------------------------------------------------------------- */
/* Detail panel — desktop right rail / mobile bottom sheet                */
/* -------------------------------------------------------------------- */
.detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(380px, 90vw);
  background: linear-gradient(180deg, var(--panel), var(--ink-2));
  border-left: 1px solid var(--line);
  padding: 2.2rem 1.8rem;
  transform: translateX(100%);
  transition: transform 0.4s var(--ease-cinema);
  overflow-y: auto;
  z-index: 20;
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.4);
}
.detail-panel.is-open {
  transform: translateX(0);
}
.panel__close {
  position: absolute;
  top: 1.2rem;
  right: 1.4rem;
  background: none;
  border: none;
  color: var(--parch-dim);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.panel__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  color: var(--gold-bright);
  margin-bottom: 1.1rem;
}
.panel__icon {
  width: 44px;
  height: 44px;
  color: var(--gold-bright);
  margin-bottom: 0.9rem;
}
.panel__icon svg { width: 100%; height: 100%; }
.panel__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0 0 0.15rem;
}
.panel__subtitle {
  font-family: var(--font-ui);
  font-style: italic;
  color: var(--parch-faint);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}
.panel__date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--red);
  margin-bottom: 1.2rem;
}
.panel__blurb {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--parch-dim);
  margin-bottom: 1.8rem;
}
.panel__cta {
  width: 100%;
  margin-bottom: 0.7rem;
}
.panel__dev {
  width: 100%;
  font-size: 0.66rem;
  padding: 0.6rem 1rem;
}

@media (max-width: 720px) {
  .detail-panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: 78vh;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    padding: 1.6rem 1.4rem 2rem;
  }
  .detail-panel.is-open {
    transform: translateY(0);
  }
  .node { width: 68px; }
  .node__ring { width: 42px; height: 42px; }
  .node__label { font-size: 0.62rem; }
}

/* -------------------------------------------------------------------- */
/* Modal                                                                  */
/* -------------------------------------------------------------------- */
#modalRoot {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}
#modalRoot.is-open {
  pointer-events: auto;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
#modalRoot.is-open .modal__backdrop {
  opacity: 1;
}
.modal__box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%);
  width: min(420px, 88vw);
  background: linear-gradient(180deg, var(--panel), var(--ink-2));
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2rem 1.9rem;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s var(--ease-cinema);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
#modalRoot.is-open .modal__box {
  opacity: 1;
  transform: translate(-50%, -50%);
}
.modal__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  color: var(--gold-bright);
  margin-bottom: 0.8rem;
}
.modal__title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0 0 0.7rem;
}
.modal__body {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--parch-dim);
  margin: 0 0 1.6rem;
}
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
}

/* -------------------------------------------------------------------- */
/* Stage overlay — mini-game shell (e.g. Sumpah Pemuda "Satukan Suara")  */
/* -------------------------------------------------------------------- */
.stage-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: radial-gradient(120% 100% at 50% 20%, var(--ink-2) 0%, var(--ink) 60%, #000 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-cinema);
}
.stage-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}
.stage-overlay__topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.6rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.stage-overlay__heading .eyebrow {
  margin: 0 0 0.3rem;
}
.stage-overlay__hint {
  font-family: var(--font-ui);
  font-style: italic;
  font-size: 0.82rem;
  color: var(--parch-dim);
  margin: 0;
}
.stage-overlay__right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stage-overlay__close {
  background: none;
  border: 1px solid var(--line);
  color: var(--parch-dim);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.stage-overlay__close:hover {
  border-color: var(--gold);
  color: var(--parch);
}

#stageCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* purely decorative now — orbs are real buttons above it */
}

.stage-play-area {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
}

.stage-orbs-layer {
  position: absolute;
  inset: 0;
}

.orb {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1.5px solid rgba(243, 238, 225, 0.18);
  background: radial-gradient(circle at 38% 34%, var(--orb-color), var(--panel) 145%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--orb-color);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 0 0 0 rgba(234, 200, 115, 0.3);
  animation: orbInvite 2.4s ease-in-out infinite;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.4s ease, border-color 0.4s ease;
}
.orb__ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px dashed var(--orb-color);
  opacity: 0.4;
}
.orb__icon {
  width: 24px;
  height: 24px;
  display: flex;
}
.orb__icon svg {
  width: 100%;
  height: 100%;
}
.orb:hover,
.orb:focus-visible {
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow: 0 0 22px 2px rgba(234, 200, 115, 0.4);
}
.orb:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 4px;
}
@keyframes orbInvite {
  0%, 100% { box-shadow: 0 0 0 0 rgba(234, 200, 115, 0.22); }
  50% { box-shadow: 0 0 16px 2px rgba(234, 200, 115, 0.32); }
}
.orb--connected {
  animation: none;
  cursor: default;
  pointer-events: none; /* inert once connected — also stops :hover from re-triggering the invite state */
  border-color: var(--gold);
  background: radial-gradient(circle at 38% 34%, #2a230f, var(--panel));
  color: var(--gold-bright);
  box-shadow: 0 0 24px 4px rgba(234, 200, 115, 0.45);
  transform: translate(-50%, -50%) scale(0.94);
}
.orb--connected .orb__ring {
  border-style: solid;
  border-color: var(--gold-bright);
  opacity: 0.8;
}

@media (max-width: 480px) {
  .orb { width: 52px; height: 52px; }
  .orb__icon { width: 20px; height: 20px; }
}

.stage-complete {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%);
  width: min(420px, 88vw);
  text-align: center;
  background: linear-gradient(180deg, var(--panel), var(--ink-2));
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2.2rem 1.9rem;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s var(--ease-cinema);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}
.stage-complete.is-in {
  opacity: 1;
  transform: translate(-50%, -50%);
}
.stage-complete .eyebrow {
  color: var(--gold-bright);
  font-size: 0.9rem;
  letter-spacing: 0.3em;
}
.stage-complete__title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0.4rem 0 0.8rem;
}
.stage-complete__body {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--parch-dim);
  margin: 0 0 1.6rem;
}

@media (max-width: 480px) {
  .stage-overlay__topbar {
    padding: 0.9rem 1rem;
    flex-wrap: wrap;
    gap: 0.6rem;
  }
}


/* -------------------------------------------------------------------- */
/* Solemn orbs (Sumpah Pemuda stage)                                      */
/* -------------------------------------------------------------------- */
.orb--solemn {
  width: 72px;
  height: 72px;
  border: 1px solid rgba(243, 238, 225, 0.14);
  background: radial-gradient(circle at 38% 32%, #1f1a14 0%, #12100c 100%);
  box-shadow: 0 0 0 0 rgba(201, 162, 39, 0.15);
  animation: orbInviteSolemn 3.2s ease-in-out infinite;
  color: var(--parch-dim);
}
.orb--solemn .orb__core {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, var(--orb-color), #0a0908 120%);
  box-shadow: 0 0 10px 1px color-mix(in srgb, var(--orb-color) 50%, transparent);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}
.orb--solemn .orb__label {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--parch-faint);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0.75;
}
.orb--solemn .orb__ring {
  border: 1px solid rgba(201, 162, 39, 0.22);
  opacity: 0.55;
  border-style: solid;
}
.orb--solemn:hover,
.orb--solemn:focus-visible {
  border-color: rgba(201, 162, 39, 0.45);
  box-shadow: 0 0 20px 2px rgba(201, 162, 39, 0.22);
}
.orb--solemn.orb--connected {
  animation: none;
  border-color: var(--gold);
  background: radial-gradient(circle at 38% 32%, #1a1610, #0e0c09);
  box-shadow: 0 0 22px 3px rgba(234, 200, 115, 0.35);
  transform: translate(-50%, -50%) scale(0.96);
}
.orb--solemn.orb--connected .orb__core {
  background: radial-gradient(circle at 40% 35%, var(--gold-bright), #2a230f);
  box-shadow: 0 0 14px 2px rgba(234, 200, 115, 0.55);
  transform: scale(1.15);
}
.orb--solemn.orb--connected .orb__label {
  color: var(--gold-bright);
  opacity: 1;
}
.orb--solemn.orb--connected .orb__ring {
  border-color: var(--gold-bright);
  opacity: 0.85;
}
@keyframes orbInviteSolemn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0.12); }
  50% { box-shadow: 0 0 14px 1px rgba(201, 162, 39, 0.22); }
}

@media (max-width: 480px) {
  .orb--solemn { width: 58px; height: 58px; }
  .orb--solemn .orb__core { width: 14px; height: 14px; }
  .orb--solemn .orb__label { font-size: 0.52rem; top: calc(100% + 6px); }
}


/* Full-screen hit target for Entrance 1 — always on top of decorative layers */
.e1-hit {
  position: absolute;
  inset: 0;
  z-index: 50;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  pointer-events: auto;
}
/* Decorative layers must never steal clicks */
#entrance1 .vignette,
#entrance1 .flag-wrap,
#entrance1 #flagCanvas,
#entrance1 .e1-text,
#entrance1 .e1-hint {
  pointer-events: none !important;
}
#entrance1 {
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
}

/* -------------------------------------------------------------------- */
/* Reduced motion                                                         */
/* -------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .node--available .node__ring,
  .node--available .node__orbit,
  .orb,
  .ember,
  .route-next,
  .e1-hint,
  .fog-layer {
    animation: none !important;
  }
  .screen,
  .flag-wrap,
  .e1-text,
  .detail-panel,
  .modal__box,
  .stage-overlay,
  .stage-complete {
    transition-duration: 0.15s !important;
  }
}

/* -------------------------------------------------------------------- */
/* Small screens — entrance text scaling                                  */
/* -------------------------------------------------------------------- */
@media (max-width: 480px) {
  .flag-wrap { width: min(88vw, 420px); height: min(66vw, 315px); }
  .map-header { padding: 0.8rem 1rem; }
  .brand-title { font-size: 0.92rem; }
  .header-right { gap: 0.6rem; }
  .progress-track { display: none; }
  .btn--ghost#resetBtn { padding: 0.6rem 0.9rem; font-size: 0.66rem; }
}

/* -------------------------------------------------------------------- */
/* Language switcher                                                      */
/* -------------------------------------------------------------------- */
.lang-switch {
  position: absolute;
  top: 1.1rem;
  right: 1.2rem;
  z-index: 30;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--parch-dim);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  padding: 0.45rem 0.75rem;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.lang-switch:hover {
  border-color: var(--gold);
  color: var(--parch);
}
.lang-switch--inline {
  position: static;
  padding: 0.4rem 0.65rem;
}

/* -------------------------------------------------------------------- */
/* Mode select                                                            */
/* -------------------------------------------------------------------- */
.mode-select {
  text-align: center;
  max-width: 820px;
  padding: 1.5rem;
  width: 100%;
}
.mode-sub {
  font-size: 0.95rem;
  color: var(--parch-dim);
  margin: 0 0 2.2rem;
}
.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
}
@media (max-width: 640px) {
  .mode-cards { grid-template-columns: 1fr; }
}
.mode-card {
  all: unset;
  box-sizing: border-box;
  text-align: left;
  background: linear-gradient(180deg, #18140f, #120f0c) !important;
  border: 1px solid rgba(201, 162, 39, 0.22) !important;
  border-radius: 4px;
  padding: 1.6rem 1.4rem 1.4rem !important;
  color: #f3eee1 !important;
  cursor: pointer;
  transition: border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.55rem;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  width: 100%;
  font-family: inherit;
}
.mode-card:hover {
  border-color: #c9a227 !important;
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
}
.mode-card--game:hover {
  border-color: #c8102e !important;
}
.mode-card__tag {
  display: block;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  color: #eac873;
}
.mode-card__title {
  display: block;
  font-family: "Cinzel", Georgia, serif;
  font-size: 1.35rem;
  color: #f3eee1;
  line-height: 1.25;
}
.mode-card__desc {
  display: block;
  font-size: 0.88rem;
  line-height: 1.55;
  color: rgba(243, 238, 225, 0.62);
  flex: 1;
  white-space: normal;
}
.mode-card__cta {
  display: block;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #eac873;
  margin-top: 0.6rem;
}
.mode-card--game .mode-card__cta { color: #c8102e; }

#modeSelect .mode-select {
  position: relative;
  z-index: 2;
}
#modeSelect .mode-cards {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  width: 100%;
}
@media (max-width: 640px) {
  #modeSelect .mode-cards { grid-template-columns: 1fr !important; }
}

/* -------------------------------------------------------------------- */
/* Learn mode                                                             */
/* -------------------------------------------------------------------- */
#learnMode {
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}
.learn-body {
  position: relative;
  flex: 1;
  display: flex;
  overflow: hidden;
}
.learn-list-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.6rem 2rem;
}
.learn-list {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.learn-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  text-align: left;
  background: linear-gradient(180deg, var(--panel), var(--ink-2));
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1rem 1.1rem;
  color: var(--parch);
  cursor: pointer;
  transition: all 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
.learn-item:hover,
.learn-item.is-active {
  border-color: var(--gold);
}
.learn-item.is-read {
  border-color: rgba(76, 175, 106, 0.35);
}
.learn-item__order {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--gold-bright);
  min-width: 1.8rem;
}
.learn-item__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.learn-item__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
}
.learn-item__date {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--parch-faint);
}
.learn-item__status {
  color: #4caf6a;
  font-size: 1rem;
  min-width: 1.2rem;
  text-align: center;
}

.learn-article-wrap {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(520px, 100%);
  background: linear-gradient(180deg, var(--panel), var(--ink-2));
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform 0.4s var(--ease-cinema);
  z-index: 20;
  overflow: hidden;
  box-shadow: -20px 0 60px rgba(0,0,0,0.4);
}
.learn-article-wrap.is-open {
  transform: translateX(0);
}
.learn-article {
  height: 100%;
  overflow-y: auto;
  padding: 2rem 1.7rem 3rem;
}
.learn-lead {
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--parch);
  margin: 0 0 1.6rem;
  font-style: italic;
  border-left: 2px solid var(--gold);
  padding-left: 1rem;
}
.learn-sec {
  margin-bottom: 1.5rem;
}
.learn-sec h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--gold-bright);
  margin: 0 0 0.5rem;
}
.learn-sec p {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--parch-dim);
  margin: 0;
}
.learn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}
.learn-actions .btn {
  flex: 1;
  min-width: 120px;
  text-align: center;
  justify-content: center;
}

@media (max-width: 720px) {
  .learn-article-wrap {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    top: auto;
    height: 82vh;
    transform: translateY(100%);
  }
  .learn-article-wrap.is-open {
    transform: translateY(0);
  }
  .header-right {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
  }
}


/* Mode select — ensure visible & interactive when active */
#modeSelect.is-active {
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}
#modeSelect .mode-select {
  max-width: 860px;
  width: min(860px, 94vw);
  margin: 0 auto;
}
#modeSelect .mode-cards {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  width: 100%;
}
@media (max-width: 640px) {
  #modeSelect .mode-cards {
    grid-template-columns: 1fr !important;
  }
}


/* ==========================================================================
   CRITICAL: inactive screens must never steal clicks
   ========================================================================== */
.screen[hidden],
.screen:not(.is-active) {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}
.screen.is-active {
  display: flex !important;
  pointer-events: auto !important;
  visibility: visible !important;
  opacity: 1;
}
/* entrance1 opacity overrides must not keep it interactive when inactive */
#entrance1:not(.is-active) {
  opacity: 0 !important;
  pointer-events: none !important;
  display: none !important;
}
#entrance1.is-active {
  display: flex !important;
  pointer-events: auto !important;
}
#e1Hit:disabled,
#entrance1:not(.is-active) #e1Hit {
  pointer-events: none !important;
  display: none !important;
}
/* CTA on entrance 2 must be clickable */
#entrance2 .credits,
#entrance2 #ctaContinue {
  position: relative;
  z-index: 5;
  pointer-events: auto !important;
}
#ctaContinue {
  cursor: pointer;
}


/* Force interactive controls */
#ctaContinue,
#btnModeLearn,
#btnModeGame,
.btn.btn--primary {
  pointer-events: auto !important;
  cursor: pointer !important;
  position: relative;
  z-index: 40 !important;
}
#entrance2.is-active,
#modeSelect.is-active {
  z-index: 20 !important;
  pointer-events: auto !important;
}
#entrance2 .credits {
  position: relative;
  z-index: 30;
  pointer-events: auto !important;
}
/* Hide e1-hit if leftover in old caches */
.e1-hit { display: none !important; pointer-events: none !important; }
