/* Bonus Missions: night-mission look with gold accents. Unit colour comes in as --accent. */
:root {
  --bg0: #060a17;
  --bg1: #0d1530;
  --bg2: #15204a;
  --panel: rgba(15, 23, 51, 0.84);
  --panel2: rgba(22, 33, 72, 0.92);
  --line: rgba(255, 210, 110, 0.32);
  --line2: rgba(150, 180, 255, 0.18);
  --ink: #eef2ff;
  --muted: #a9b6db;
  --dim: #7a87b0;
  --gold: #ffd25e;
  --gold2: #ffad1f;
  --ok: #38e0a0;
  --bad: #ff5c74;
  --accent: #3fd1b5;
  --paper: #fbf6e9;
  --paper-ink: #1c2036;
  --radius: 16px;
  --font-head: 'Bebas Neue', 'Oswald', Impact, 'Arial Narrow', sans-serif;
  --font-body: 'Atkinson Hyperlegible', 'Segoe UI', Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.45;
  background:
    radial-gradient(1100px 560px at 12% -8%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 62%),
    radial-gradient(900px 520px at 108% 6%, rgba(255, 173, 31, 0.13), transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 75%);
  background-color: var(--bg0);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before { /* manga screentone */
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.06;
  background-image: radial-gradient(#fff 1px, transparent 1.4px);
  background-size: 7px 7px;
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 75%);
  mask-image: linear-gradient(180deg, #000, transparent 75%);
}
button { font: inherit; }
.fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 90; }

/* ------------------------------------------------------------ top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: linear-gradient(180deg, rgba(6, 10, 23, 0.96), rgba(6, 10, 23, 0.82));
  border-bottom: 1px solid var(--line2);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-head); font-size: 23px; letter-spacing: 0.08em; color: var(--gold); white-space: nowrap; }
.brand-star { width: 24px; height: 24px; display: inline-flex; filter: drop-shadow(0 0 6px rgba(255, 210, 94, 0.6)); animation: twinkle 3s ease-in-out infinite; }
.brand-star svg { width: 100%; height: 100%; }
.top-mid { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.chip {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.chip { min-width: 0; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; }
.top-title { font-family: var(--font-head); font-size: 25px; letter-spacing: 0.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 10px; }
.clock {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 18px;
  min-width: 72px;
  text-align: center;
  padding: 5px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line2);
}
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line2);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.1); }
.icon-btn:focus-visible, .btn:focus-visible, .card:focus-visible, .lock:focus-visible, .opt:focus-visible,
.tile:focus-visible, .slot:focus-visible, .wchip:focus-visible, .def:focus-visible, .key:focus-visible,
.mkey:focus-visible, .ord:focus-visible, .cx-letter:focus-visible, .cx-btn:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.screen { max-width: 1200px; margin: 0 auto; padding: 18px 18px 48px; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
  border-radius: 12px;
  padding: 11px 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line2);
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease, background 0.2s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn.gold {
  color: #2b1700;
  border: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: linear-gradient(180deg, #ffe596, var(--gold) 45%, var(--gold2));
  box-shadow: 0 5px 0 #b46a00, 0 10px 26px rgba(255, 173, 31, 0.33);
}
.btn.gold:active { transform: translateY(4px); box-shadow: 0 1px 0 #b46a00, 0 4px 12px rgba(255, 173, 31, 0.3); }
.btn.big { font-size: 20px; padding: 15px 30px; }
.btn.small { font-size: 15px; padding: 8px 13px; border-radius: 10px; }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-ico { width: 20px; height: 20px; display: inline-flex; }
.btn-ico svg { width: 100%; height: 100%; }

/* ------------------------------------------------------------ panels */
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.32);
}
.panel::before, .panel::after { /* HUD corner brackets */
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: var(--radius); }
.panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: var(--radius); }
.panel.slim { padding: 10px 16px; }
.side-title { font-family: var(--font-head); font-weight: 400; letter-spacing: 0.06em; font-size: 26px; margin: 0 0 10px; color: var(--gold); }
.phase-kicker { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 13px; }
.phase-title { font-family: var(--font-head); font-weight: 400; letter-spacing: 0.04em; font-size: 34px; margin: 0; line-height: 1; }
.phase-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 14px; }
.phase-right { display: flex; align-items: center; gap: 12px; }
.phase-help { margin: 0; color: var(--muted); }
.feedback { min-height: 1.5em; margin: 10px 0 0; color: var(--muted); font-weight: 700; text-align: center; }
.feedback.good { color: var(--ok); }
.feedback.bad { color: var(--bad); }

/* ------------------------------------------------------------ mission file (intro) */
.file {
  max-width: 940px;
  margin: 8px auto;
  border-radius: 22px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5), 0 0 60px color-mix(in srgb, var(--accent) 10%, transparent);
  animation: rise 0.55s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
/* banner drawn in code: no pictures (George: no AI images) */
.banner {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 78% 48%, color-mix(in srgb, var(--accent) 42%, transparent), transparent 55%),
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 26%, #101a3c), #0b1020 72%);
}
.banner::before { /* screentone */
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.2) 1.3px, transparent 1.7px);
  background-size: 9px 9px;
  -webkit-mask-image: radial-gradient(circle at 78% 48%, #000 0, transparent 62%);
  mask-image: radial-gradient(circle at 78% 48%, #000 0, transparent 62%);
}
.banner-rays {
  position: absolute;
  left: 78%;
  top: 48%;
  width: 260%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.07) 0deg 5deg, transparent 5deg 15deg);
  -webkit-mask-image: radial-gradient(circle, #000 0, transparent 45%);
  mask-image: radial-gradient(circle, #000 0, transparent 45%);
  animation: spin 90s linear infinite;
}
.banner-word {
  position: absolute;
  z-index: 1;
  left: 3%;
  bottom: 7%;
  font-family: var(--font-head);
  font-size: clamp(64px, 12vw, 150px);
  line-height: 0.82;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: transparent;
  -webkit-text-stroke: 2px color-mix(in srgb, var(--accent) 60%, transparent);
  opacity: 0.5;
}
.banner-emblem {
  position: absolute;
  z-index: 1;
  right: 9%;
  top: 50%;
  width: min(24%, 190px);
  aspect-ratio: 1;
  transform: translateY(-50%);
  color: var(--accent);
  filter: drop-shadow(0 0 24px color-mix(in srgb, var(--accent) 75%, transparent));
  animation: bob 5s ease-in-out infinite;
}
.banner-emblem svg { width: 100%; height: 100%; display: block; }
.file-art { aspect-ratio: 1100 / 360; }
.file-art::after { content: ''; position: absolute; z-index: 1; inset: 0; background: linear-gradient(180deg, rgba(6, 10, 23, 0) 35%, rgba(15, 23, 51, 0.97) 100%); }
.file-stamp {
  position: absolute;
  z-index: 2;
  top: 16px;
  left: 16px;
  font-family: var(--font-head);
  font-size: 19px;
  letter-spacing: 0.14em;
  padding: 5px 12px;
  color: var(--gold);
  border: 2px solid var(--gold);
  border-radius: 6px;
  background: rgba(6, 10, 23, 0.72);
  transform: rotate(-3deg);
  box-shadow: 0 0 18px rgba(255, 210, 94, 0.25);
}
.file-body { position: relative; z-index: 2; margin-top: -54px; padding: 0 34px 30px; }
.kicker { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 14px; }
.file-title { font-family: var(--font-head); font-weight: 400; font-size: clamp(42px, 6.4vw, 70px); line-height: 0.95; letter-spacing: 0.03em; margin: 6px 0 10px; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45); }
.brief { font-size: 18.5px; color: #e2e8ff; max-width: 70ch; margin: 0; }
.how { list-style: none; padding: 0; margin: 16px 0 24px; display: grid; gap: 7px; }
.how li { display: flex; gap: 10px; color: var(--muted); }
.how li::before { content: '◆'; color: var(--gold); font-size: 11px; margin-top: 6px; }
.file-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.done-note { margin: 14px 0 0; color: var(--ok); font-weight: 700; }

/* ------------------------------------------------------------ win overlay */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: auto;
  background: radial-gradient(circle at 50% 38%, rgba(255, 210, 94, 0.2), rgba(3, 6, 15, 0.9) 62%);
  animation: fade 0.3s ease both;
}
.win {
  width: min(560px, 100%);
  text-align: center;
  padding: 26px 26px 20px;
  border-radius: 22px;
  background: linear-gradient(180deg, var(--bg2), var(--bg1));
  border: 1px solid var(--line);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.6), 0 0 70px rgba(255, 210, 94, 0.16);
  animation: pop 0.55s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.stamp {
  display: inline-block;
  font-family: var(--font-head);
  font-size: 44px;
  letter-spacing: 0.08em;
  line-height: 1;
  padding: 6px 18px 4px;
  color: var(--gold);
  border: 4px solid var(--gold);
  border-radius: 10px;
  transform: rotate(-4deg);
  text-shadow: 0 0 20px rgba(255, 210, 94, 0.5);
  animation: stamp 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) 0.15s both;
}
.rank {
  font-family: var(--font-head);
  font-size: 120px;
  line-height: 1;
  margin: 12px 0 0;
  background: linear-gradient(180deg, #fff6d0, var(--gold) 50%, var(--gold2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 20px rgba(255, 173, 31, 0.45));
  animation: pop 0.6s cubic-bezier(0.2, 1.5, 0.4, 1) 0.35s both;
}
.rank-A { background-image: linear-gradient(180deg, #e8fff6, #6ff0c3 50%, #20b07c); filter: drop-shadow(0 6px 20px rgba(56, 224, 160, 0.4)); }
.rank-B { background-image: linear-gradient(180deg, #eaf6ff, #8fd3ff 50%, #3b8fd6); filter: drop-shadow(0 6px 20px rgba(76, 201, 240, 0.4)); }
.rank-C { background-image: linear-gradient(180deg, #ffffff, #c9d2ee 50%, #8f9bc4); filter: drop-shadow(0 6px 20px rgba(200, 210, 240, 0.3)); }
.rank-label { font-weight: 800; letter-spacing: 0.04em; color: var(--ink); }
.win-stats { color: var(--muted); margin: 6px 0 4px; font-size: 15px; }
.code-box { margin: 14px auto 16px; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.05); border: 1px dashed var(--line); display: grid; gap: 2px; }
.code-box span { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.code-box b { font-family: ui-monospace, 'Cascadia Mono', 'Courier New', monospace; font-size: 30px; letter-spacing: 0.14em; }
.win-note { color: var(--muted); font-size: 14.5px; margin: 10px auto 0; max-width: 44ch; }
.win-note.strong { color: var(--gold); font-weight: 800; font-size: 17px; }
.win-actions { display: flex; justify-content: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.claim { animation: glow 1.8s ease-in-out infinite; }

/* ------------------------------------------------------------ toasts */
.toasts { position: fixed; z-index: 80; left: 50%; bottom: 22px; transform: translateX(-50%); display: grid; gap: 8px; width: min(560px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(13, 21, 48, 0.96);
  border: 1px solid var(--line2);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  font-weight: 700;
  text-align: center;
  animation: rise 0.3s ease both;
  transition: opacity 0.4s, transform 0.4s;
}
.toast.gold { border-color: var(--gold); color: var(--gold); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ------------------------------------------------------------ word search */
.ws { display: grid; grid-template-columns: auto minmax(280px, 1fr); gap: 18px; align-items: start; }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.prog { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--muted); }
.prog b { color: var(--ink); font-variant-numeric: tabular-nums; }
.meter { width: 130px; height: 9px; border-radius: 99px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width 0.5s ease; }
.ws-grid-wrap {
  position: relative;
  width: min(660px, calc(100vh - 196px));
  min-width: 300px;
  aspect-ratio: 1;
  margin: 0 auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    rgba(255, 255, 255, 0.025);
  box-shadow: inset 0 0 0 1px var(--line2);
}
.ws-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ws-temp { stroke: transparent; transition: stroke 0.15s; }
.ws-temp.on { stroke: color-mix(in srgb, var(--accent) 55%, transparent); }
.ws-temp.on.miss { stroke: rgba(255, 92, 116, 0.55); }
.ws-found { opacity: 0.55; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 0.45s ease forwards; }
.ws-found.bonus { opacity: 0.7; }
.ws-grid { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr); }
.ws-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--fs, 22px);
  line-height: 1;
  color: #dfe6ff;
  border-radius: 50%;
  transition: color 0.2s, transform 0.12s;
  pointer-events: none;
}
.ws-cell.found { color: #ffffff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.ws-cell.hot { color: #ffffff; transform: scale(1.14); }
.ws-cell.anchor { box-shadow: 0 0 0 3px var(--gold) inset; color: var(--gold); animation: pulse 1s ease-in-out infinite; }
.ws-cell.hint { animation: hintPulse 0.7s ease-in-out 5; }
.ws-side { min-width: 0; }
.bank { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); align-items: start; }
.bank-item { padding: 9px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line2); transition: background 0.4s, border-color 0.4s; }
.bank-word { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; font-size: 16px; }
.bank-clue { font-size: 14px; color: var(--dim); margin-top: 2px; line-height: 1.35; }
.check { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid var(--line2); display: inline-grid; place-items: center; color: transparent; }
.check svg { width: 14px; height: 14px; }
.bank-item.found { border-color: color-mix(in srgb, var(--c) 70%, transparent); background: color-mix(in srgb, var(--c) 15%, transparent); }
.bank-item.found .bank-word span { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--c); }
.bank-item.found .bank-clue { color: var(--ink); }
.bank-item.found .check { background: var(--ok); border-color: var(--ok); color: #03281b; }
.bank-item.flash { animation: flash 0.7s ease; }
.secret { margin: 12px 0 0; font-size: 14px; color: var(--muted); font-style: italic; }
.secret.got { color: var(--gold); font-style: normal; font-weight: 700; }

/* ------------------------------------------------------------ memory match */
.mm { max-width: 1040px; margin: 0 auto; }
.mm-head { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; margin-bottom: 14px; color: var(--muted); }
.mm-head b { color: var(--ink); font-variant-numeric: tabular-nums; }
.mm-legend { margin-left: auto; display: flex; align-items: center; gap: 7px; font-size: 14px; }
.lg { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.lg0 { background: var(--gold); }
.lg1 { background: #5cc8ff; }
.lg-arrow { margin: 0 4px; }
.mm-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 12px;
  width: min(100%, calc((100vh - 190px) * 1.62 * var(--cols) / var(--rows)));
  margin: 0 auto;
}
.card { position: relative; aspect-ratio: 16 / 10; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; border-radius: 14px; }
/* 2D flip: the back shrinks to a line, then the front grows out of it (no 3D needed) */
.card-inner { position: absolute; inset: 0; }
.face { position: absolute; inset: 0; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; overflow: hidden; }
.back-side {
  background:
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 62%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 6px, transparent 6px 12px),
    linear-gradient(160deg, #1d2a5e, #0e1638);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 5px rgba(6, 10, 23, 0.45), 0 8px 18px rgba(0, 0, 0, 0.3);
}
.back-side { transform: scaleX(1); transition: transform 0.15s ease-in 0.15s; }
.card:hover .back-side { filter: brightness(1.18); }
.card.flipped .back-side, .card.matched .back-side { transform: scaleX(0); transition: transform 0.15s ease-in; }
.card-emblem { width: 38%; max-width: 54px; color: var(--gold); opacity: 0.85; filter: drop-shadow(0 0 8px rgba(255, 210, 94, 0.5)); }
.card-emblem svg { width: 100%; height: auto; display: block; }
.front-side { transform: scaleX(0); transition: transform 0.15s ease-out; background: var(--paper); color: var(--paper-ink); padding: 26px 10px 10px; box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3); }
.side-0 .front-side { border: 3px solid var(--gold); }
.side-1 .front-side { border: 3px solid #5cc8ff; background: #eef8ff; }
.card-tag { position: absolute; top: 0; left: 0; right: 0; padding: 3px 0; font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.side-0 .card-tag { background: var(--gold); color: #3a2400; }
.side-1 .card-tag { background: #5cc8ff; color: #04263a; }
.card-text { font-weight: 700; line-height: 1.22; }
.card-text.f1 { font-size: 19px; }
.card-text.f2 { font-size: 16px; }
.card-text.f3 { font-size: 14px; }
.card-text.f4 { font-size: 12.5px; }
.card.matched .front-side { box-shadow: 0 0 0 3px var(--ok), 0 0 24px rgba(56, 224, 160, 0.55); }
.card.matched .front-side::after { content: '✓'; position: absolute; right: 7px; bottom: 3px; font-weight: 900; color: #11a36d; font-size: 18px; }
.card.miss .front-side { box-shadow: 0 0 0 3px var(--bad); }
.card.flipped .front-side, .card.matched .front-side { transform: scaleX(1); transition: transform 0.15s ease-out 0.15s; }
.card.miss { animation: shakeX 0.4s ease; }

/* ------------------------------------------------------------ unscramble & match */
.us { max-width: 980px; margin: 0 auto; }
.us-count { color: var(--muted); font-weight: 700; font-size: 15px; }
.dots { display: flex; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: rgba(255, 255, 255, 0.12); transition: background 0.3s; }
.dot.done { background: var(--ok); }
.dot.cur { box-shadow: 0 0 0 2px var(--gold); }
.us-card { text-align: center; padding: 26px 18px 22px; }
.us-num { font-family: var(--font-head); letter-spacing: 0.1em; font-size: 20px; color: var(--muted); }
.slots, .tiles { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.slot, .tile {
  width: var(--tile, 54px);
  height: calc(var(--tile, 54px) * 1.16);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: calc(var(--tile, 54px) * 0.56);
  line-height: 1;
  padding: 0;
}
.slot { border: 2px dashed rgba(170, 190, 255, 0.35); background: rgba(255, 255, 255, 0.03); color: var(--ink); cursor: default; }
.slot.filled { border-style: solid; border-color: rgba(170, 190, 255, 0.55); background: rgba(255, 255, 255, 0.09); cursor: pointer; }
.slot.locked { border-color: var(--gold); color: var(--gold); cursor: default; }
.us-card.solved .slot { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 22%, transparent); color: #fff; animation: popSmall 0.4s ease both; }
.tile {
  border: 0;
  cursor: pointer;
  color: #2a1a00;
  background: linear-gradient(180deg, #fff7dc, #f2d685);
  box-shadow: 0 5px 0 #b5862a, 0 8px 14px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s, opacity 0.2s;
}
.tile:hover { transform: translateY(-2px); }
.tile:active { transform: translateY(3px); box-shadow: 0 2px 0 #b5862a; }
.tile.used { opacity: 0; pointer-events: none; transform: scale(0.6); }
.us-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.match { display: grid; grid-template-columns: minmax(200px, 300px) 1fr; gap: 16px; align-items: start; }
.match-words, .defs { display: grid; gap: 10px; }
.wchip, .def {
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line2);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, opacity 0.3s, transform 0.12s;
}
.wchip { font-weight: 800; letter-spacing: 0.07em; font-size: 17px; }
.def { font-size: 16px; line-height: 1.35; display: flex; flex-direction: column; gap: 3px; }
.wchip:hover, .def:hover { background: rgba(255, 255, 255, 0.1); }
.wchip.sel, .def.sel { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 210, 94, 0.25); background: rgba(255, 210, 94, 0.1); }
.wchip.done { opacity: 0.3; cursor: default; text-decoration: line-through; }
.def.done { cursor: default; border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.def-tag { font-weight: 800; color: var(--ok); letter-spacing: 0.06em; font-size: 14px; }
.def-tag:empty { display: none; }

/* ------------------------------------------------------------ escape room */
.er { max-width: 1100px; margin: 0 auto; display: grid; gap: 16px; }
.er-story { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: center; padding: 12px; }
.er-art { align-self: stretch; min-height: 140px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line2); }
.er-art .banner-word { font-size: 72px; bottom: 6%; }
.er-art .banner-emblem { left: 0; right: 0; margin: 0 auto; width: 92px; }
.er-art .banner-rays, .er-art.banner::before { left: 50%; }
.er-art.banner { background: radial-gradient(circle at 50% 48%, color-mix(in srgb, var(--accent) 42%, transparent), transparent 60%), linear-gradient(135deg, color-mix(in srgb, var(--accent) 26%, #101a3c), #0b1020 72%); }
.er-text p { margin: 4px 0 0; font-size: 17.5px; }
.locks { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.lock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 14px 14px;
  border-radius: 16px;
  color: var(--ink);
  background: var(--panel2);
  border: 1px solid var(--line2);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.3s, background 0.3s, box-shadow 0.3s;
}
.lock:hover { transform: translateY(-3px); border-color: var(--line); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35); }
.lock-num { font-family: var(--font-head); letter-spacing: 0.14em; color: var(--muted); font-size: 17px; }
.lock-ico { width: 46px; height: 54px; color: #c9a24a; display: inline-flex; }
.lock-ico svg { width: 100%; height: 100%; overflow: visible; }
.lock-ico .shackle { transition: transform 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); transform-origin: 35px 26px; }
.lock-ico.open { color: var(--ok); }
.lock-ico.open .shackle { transform: translateY(-7px) rotate(28deg); }
.lock-name { font-family: var(--font-head); font-size: 27px; letter-spacing: 0.04em; line-height: 1; text-align: center; }
.lock-state { font-size: 14px; color: var(--muted); }
.lock.open { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 9%, var(--panel2)); }
.lock .digit { font-family: var(--font-head); font-size: 30px; color: var(--gold); vertical-align: middle; margin-left: 4px; }
.door { display: grid; grid-template-columns: 220px 1fr; gap: 22px; align-items: center; }
.door-art { position: relative; height: 270px; border-radius: 110px 110px 10px 10px; overflow: hidden; background: #050812; box-shadow: inset 0 0 0 6px #5b4426, 0 0 0 2px #2b1f10; perspective: 600px; }
.door-light { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 60%, #fff7c4, #ffd25e 35%, #ff9f1c 65%, #3a2208); }
.door-light span { font-family: var(--font-head); font-size: 34px; color: #4a2a00; letter-spacing: 0.08em; opacity: 0; transition: opacity 0.6s 0.6s; }
.leaf { position: absolute; top: 0; bottom: 0; width: 50%; background: repeating-linear-gradient(90deg, #6b4a26 0 18px, #5c3f20 18px 20px), linear-gradient(#6b4a26, #3d2912); box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.35); transition: transform 1.1s cubic-bezier(0.5, 0, 0.2, 1); }
.leaf.left { left: 0; transform-origin: left center; }
.leaf.right { right: 0; transform-origin: right center; }
.leaf.left::after, .leaf.right::after { content: ''; position: absolute; top: 52%; width: 10px; height: 10px; border-radius: 50%; background: #e9c46a; box-shadow: 0 0 6px #ffd25e; }
.leaf.left::after { right: 10px; }
.leaf.right::after { left: 10px; }
.door.opening .leaf.left { transform: rotateY(-105deg); }
.door.opening .leaf.right { transform: rotateY(105deg); }
.door.opening .door-light span { opacity: 1; }
.door-prompt { margin: 0 0 6px; color: var(--muted); }
.door.ready { border-color: var(--gold); box-shadow: 0 0 40px rgba(255, 210, 94, 0.18), 0 16px 40px rgba(0, 0, 0, 0.32); }
.code-slots { display: flex; gap: 10px; margin: 12px 0 14px; }
.code-slot {
  position: relative;
  width: 54px;
  height: 66px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--font-head);
  font-size: 40px;
  color: var(--gold);
  background: #0a0f22;
  border: 2px solid var(--line2);
}
.code-slot::after { content: attr(data-l); position: absolute; bottom: -19px; font-family: var(--font-body); font-size: 11px; color: var(--dim); letter-spacing: 0.08em; }
.code-slot.filled { border-color: var(--gold); }
.keypad { display: grid; grid-template-columns: repeat(3, 62px); gap: 9px; margin-top: 22px; }
.key {
  height: 52px;
  border-radius: 12px;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  background: linear-gradient(180deg, #24336c, #172350);
  border: 1px solid var(--line2);
  box-shadow: 0 4px 0 #0b1230;
  cursor: pointer;
}
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 #0b1230; }
.key.k-ok { background: linear-gradient(180deg, #2fd897, #18a56f); color: #032417; }
.door.locked .key { opacity: 0.5; }
.door-status { margin: 12px 0 0; font-weight: 700; color: var(--muted); }
.door.ready .door-status { color: var(--gold); }

/* lock modal */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(3, 6, 15, 0.74); backdrop-filter: blur(3px); animation: fade 0.2s ease both; overflow: auto; }
.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 20px 22px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--bg2), var(--bg1));
  border: 1px solid var(--line);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  animation: pop 0.35s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.puz-prompt { font-size: 19px; font-weight: 700; margin: 12px 0 14px; }
.puz-help { text-align: center; color: var(--dim); font-size: 14px; margin: 8px 0 0; }
.puz-actions { display: flex; justify-content: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.modal-foot { display: flex; justify-content: flex-end; margin-top: 8px; }
.hint-box { margin: 12px 0 0; padding: 10px 14px; border-radius: 12px; background: rgba(255, 210, 94, 0.1); border: 1px solid var(--line); color: #ffe7a6; }
.hint-box[hidden] { display: none; }
.mcq { display: grid; gap: 10px; }
.opt { text-align: left; padding: 13px 16px; border-radius: 12px; color: var(--ink); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line2); cursor: pointer; font-size: 17px; transition: background 0.2s, border-color 0.2s; }
.opt:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--line); }
.opt.wrong, .opt[disabled] { border-color: var(--bad); color: #ffb3bf; text-decoration: line-through; cursor: not-allowed; opacity: 0.7; }
.cryptex { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; padding: 14px; border-radius: 16px; background: linear-gradient(180deg, #3a2a12, #1c1308); border: 2px solid #8a6a2a; box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.6); }
.cx-wheel { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.cx-btn { background: none; border: 0; color: #e9c46a; font-size: 18px; cursor: pointer; padding: 2px 10px; border-radius: 8px; }
.cx-btn:hover { background: rgba(255, 255, 255, 0.08); }
.cx-letter {
  width: 48px;
  height: 58px;
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 800;
  color: #2a1a00;
  border-radius: 6px;
  background: linear-gradient(180deg, #c9a75a, #f8e7b5 30%, #f8e7b5 70%, #c9a75a);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  cursor: text;
}
.legend { display: grid; gap: 6px; margin-bottom: 14px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line2); }
.legend-row { display: flex; gap: 10px; align-items: baseline; }
.legend-row b { font-family: var(--font-head); font-size: 24px; color: var(--gold); width: 22px; text-align: center; flex: none; }
.mrows { display: grid; gap: 8px; }
.mrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.03); flex-wrap: wrap; }
.mtext { font-weight: 700; }
.mkeys { display: flex; gap: 6px; }
.mkey { width: 44px; height: 40px; border-radius: 10px; font-weight: 800; font-size: 18px; color: var(--ink); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line2); cursor: pointer; }
.mkey.sel { background: var(--gold); color: #2b1700; border-color: var(--gold); }
.ord-list { display: grid; gap: 9px; }
.ord { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border-radius: 12px; color: var(--ink); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line2); cursor: pointer; font-size: 17px; }
.ord-n { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; border: 2px dashed var(--line2); }
.ord.picked { border-color: var(--gold); background: rgba(255, 210, 94, 0.08); }
.ord.picked .ord-n { background: var(--gold); color: #2b1700; border: 0; }
.ord-built { min-height: 1.4em; text-align: center; font-style: italic; color: #ffe7a6; margin: 12px 0 0; }
.txt { width: 100%; font: inherit; font-size: 20px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line2); background: #0a0f22; color: var(--ink); }
.txt:focus { outline: none; border-color: var(--gold); }
.unlocked { display: flex; align-items: center; gap: 18px; justify-content: center; padding: 8px 0; }
.unlocked .lock-ico { width: 64px; height: 76px; }
.unlocked-title { font-family: var(--font-head); font-size: 34px; letter-spacing: 0.04em; color: var(--ok); line-height: 1; }
.unlocked-digit { font-size: 18px; color: var(--muted); }
.unlocked-digit b { font-family: var(--font-head); font-size: 54px; color: var(--gold); vertical-align: middle; margin-left: 6px; }
.solved-text { margin: 10px 0 0; padding: 12px 14px; border-radius: 12px; background: rgba(56, 224, 160, 0.08); border: 1px solid rgba(56, 224, 160, 0.35); }

/* ------------------------------------------------------------ hub and splash pages */
.page { max-width: 1120px; margin: 0 auto; padding: 22px 18px 60px; }
.hero { text-align: center; padding: 40px 10px 20px; }
.hero h1 { font-family: var(--font-head); font-weight: 400; font-size: clamp(48px, 8vw, 92px); letter-spacing: 0.04em; margin: 0; line-height: 0.95; color: var(--gold); text-shadow: 0 0 30px rgba(255, 210, 94, 0.35); }
.hero p { color: var(--muted); font-size: 19px; max-width: 60ch; margin: 12px auto 0; }
.unit { margin-top: 26px; border-radius: 20px; overflow: hidden; background: var(--panel); border: 1px solid var(--line2); }
.unit-head {
  position: relative;
  min-height: 120px;
  display: flex;
  align-items: flex-end;
  padding: 16px 20px;
  overflow: hidden;
  background:
    radial-gradient(circle at 88% 50%, color-mix(in srgb, var(--accent) 38%, transparent), transparent 45%),
    linear-gradient(120deg, color-mix(in srgb, var(--accent) 22%, #101a3c), #0b1020 70%);
}
.unit-head .unit-emblem { position: absolute; right: 24px; top: 50%; transform: translateY(-50%); width: 84px; height: 84px; color: var(--accent); filter: drop-shadow(0 0 16px color-mix(in srgb, var(--accent) 70%, transparent)); }
.unit-head .unit-emblem svg { width: 100%; height: 100%; display: block; }
.unit-head h2 { position: relative; margin: 0; font-family: var(--font-head); font-weight: 400; font-size: 40px; letter-spacing: 0.05em; line-height: 1; }
.unit-head span { position: relative; display: block; color: var(--muted); font-size: 15px; margin-top: 4px; }
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; padding: 16px; }
.day { display: grid; gap: 4px; padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line2); color: var(--ink); text-decoration: none; transition: transform 0.15s, border-color 0.2s, background 0.2s; }
a.day:hover { transform: translateY(-2px); border-color: var(--line); background: rgba(255, 255, 255, 0.08); }
.day-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.day-num { font-family: var(--font-head); font-size: 26px; letter-spacing: 0.06em; color: var(--accent); }
.day-type { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.day-title { font-weight: 700; }
.day-url { font-size: 12.5px; color: var(--dim); word-break: break-all; }
.day.soon { opacity: 0.45; }
.copy { justify-self: start; margin-top: 4px; font-size: 13px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line2); background: rgba(255, 255, 255, 0.05); color: var(--ink); cursor: pointer; }
.copy.done { border-color: var(--ok); color: var(--ok); }
.note { color: var(--muted); font-size: 15px; }

/* ------------------------------------------------------------ animation */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { opacity: 0; transform: scale(0.82); } 100% { opacity: 1; transform: none; } }
@keyframes popSmall { 0% { transform: scale(0.85); } 60% { transform: scale(1.08); } 100% { transform: none; } }
@keyframes stamp { 0% { opacity: 0; transform: rotate(-4deg) scale(2.2); } 70% { opacity: 1; transform: rotate(-4deg) scale(0.94); } 100% { transform: rotate(-4deg) scale(1); } }
@keyframes glow { 0%, 100% { box-shadow: 0 5px 0 #b46a00, 0 10px 26px rgba(255, 173, 31, 0.33); } 50% { box-shadow: 0 5px 0 #b46a00, 0 10px 40px rgba(255, 210, 94, 0.75); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
@keyframes hintPulse { 0%, 100% { background: transparent; color: #dfe6ff; } 50% { background: rgba(255, 210, 94, 0.45); color: #fff; transform: scale(1.2); } }
@keyframes flash { 0% { transform: scale(1); } 40% { transform: scale(1.04); } 100% { transform: none; } }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes bob { 0%, 100% { transform: translateY(-50%); } 50% { transform: translateY(-56%); } }
@keyframes twinkle { 0%, 100% { transform: rotate(0) scale(1); } 50% { transform: rotate(18deg) scale(1.12); } }
@keyframes shakeX { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
.shake { animation: shakeX 0.42s ease; }

/* ------------------------------------------------------------ small screens */
@media (max-width: 900px) {
  .ws { grid-template-columns: 1fr; }
  .ws-grid-wrap { width: min(100%, 640px); min-width: 0; }
  .door { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .door-art { width: 200px; height: 220px; }
  .code-slots, .keypad { justify-content: center; }
  .er-story { grid-template-columns: 1fr; }
  .er-art { min-height: 150px; }
  .match { grid-template-columns: 1fr; }
  .match-words { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .match > section:first-child { position: sticky; top: 58px; z-index: 5; padding: 10px; }
  .match-words { gap: 6px; }
  .wchip { padding: 9px 10px; font-size: 15px; }
  .wchip.done { display: none; }
  .mm-grid { width: 100%; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .brand span:last-child { display: none; }
  .top-title { display: none; }
  .chip-unit { display: none; }
  .topbar { gap: 8px; padding: 8px 12px; }
  .screen { padding: 12px 12px 40px; }
  .file-body { padding: 4px 18px 22px; margin-top: 0; }
  .file-art { aspect-ratio: auto; height: 150px; }
  .file-art::after { background: linear-gradient(180deg, rgba(6, 10, 23, 0) 55%, rgba(15, 23, 51, 0.9) 100%); }
  .file-stamp { font-size: 15px; top: 12px; left: 12px; }
  .banner-word { font-size: 64px; }
  .banner-emblem { width: 92px; right: 7%; }
  .locks { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .lock-name { font-size: 22px; }
  .mm-grid { --cols: 3 !important; gap: 8px; }
  .card { aspect-ratio: 3 / 4; }
  .card-text.f3 { font-size: 12.5px; }
  .card-text.f4 { font-size: 11px; }
  .mm-legend { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* saving the finish (win screen) and practice note (mission file) */
.save-box { margin: 14px auto 6px; padding: 12px 14px; border-radius: 14px; font-size: 16px; line-height: 1.4; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line2); display: grid; gap: 8px; justify-items: center; }
.save-box.saving { color: var(--muted); }
.save-box.saved { color: #b9ffe3; background: rgba(56, 224, 160, 0.12); border-color: var(--ok); }
.save-box.saved b { color: var(--ok); font-size: 18px; }
.save-box.failed { color: #ffd1d8; background: rgba(255, 92, 116, 0.1); border-color: var(--bad); }
.save-box.practice { color: #ffe7a6; border-color: var(--line); }
.save-help { font-size: 14px; color: var(--muted); }
.spin { display: inline-block; width: 16px; height: 16px; margin-right: 8px; vertical-align: -3px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: var(--gold); animation: spin360 0.8s linear infinite; }
@keyframes spin360 { to { transform: rotate(360deg); } }
.code-line { color: var(--dim); font-size: 13px; margin-top: 6px; }
.code-line b { font-family: ui-monospace, 'Cascadia Mono', 'Courier New', monospace; letter-spacing: 0.1em; color: var(--muted); }
.warn-note { margin: 14px 0 0; color: #ffe7a6; font-size: 15px; }
.big-check { width: 96px; height: 96px; margin: 14px auto 4px; border-radius: 50%; display: grid; place-items: center; color: #03281b; background: radial-gradient(circle at 35% 30%, #8affd0, var(--ok) 60%, #15a36c); box-shadow: 0 0 40px rgba(56, 224, 160, 0.45); animation: pop 0.6s cubic-bezier(0.2, 1.5, 0.4, 1) 0.3s both; }
.big-check svg { width: 58px; height: 58px; }
.feedback.clue { max-width: 60ch; margin-left: auto; margin-right: auto; font-weight: 700; line-height: 1.4; }
