/* Operation Wiki — Espionage theme: classified intelligence network */

/* ---------------------------------------------------------------------------
   Reset & base
--------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #09090b;
  --bg-card: #0f0f14;
  --bg-input: #070709;
  --border: #27272a;
  --accent: #dc2626;
  --accent-hover: #ef4444;
  --accent-dim: #3b0a0a;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --text: #f0ede8;
  --text-muted: #b8b7c4;
  --text-dim: #72728a;
  --wiki-link: #60a5fa;
  --wiki-link-hover: #93c5fd;
  --radius: 2px;
  --radius-sm: 2px;
  --shadow: 0 4px 32px rgba(0, 0, 0, 0.8);
  --font-mono: "Courier New", Courier, monospace;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

/* Subtle scanline texture for atmosphere */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.025) 2px,
    rgba(0, 0, 0, 0.025) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ---------------------------------------------------------------------------
   Typography
--------------------------------------------------------------------------- */

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.03em;
}

h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
}
h2 {
  font-size: clamp(1.3rem, 3vw, 1.8rem);
}
h3 {
  font-size: 1.1rem;
}

p {
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
}

/* Tactical label style — used for all form labels and section headings */
.tac-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------------------
   Layout utilities
--------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
}

.container--narrow {
  max-width: 480px;
}
.container--md {
  max-width: 680px;
}
.container--wide {
  max-width: 1200px;
}

.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-center {
  justify-content: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-1 {
  gap: 0.5rem;
}
.gap-2 {
  gap: 1rem;
}
.gap-3 {
  gap: 1.5rem;
}

.mt-1 {
  margin-top: 0.5rem;
}
.mt-2 {
  margin-top: 1rem;
}
.mt-3 {
  margin-top: 1.5rem;
}
.mb-1 {
  margin-bottom: 0.5rem;
}
.mb-2 {
  margin-bottom: 1rem;
}

.text-center {
  text-align: center;
}
.text-sm {
  font-size: 0.875rem;
}
.text-xs {
  font-size: 0.75rem;
}
.text-muted {
  color: var(--text-muted);
}
.text-success {
  color: var(--success);
}
.text-warning {
  color: var(--warning);
}
.text-danger {
  color: var(--danger);
}
.text-accent {
  color: var(--accent);
}
.font-mono {
  font-family: var(--font-mono);
}

/* ---------------------------------------------------------------------------
   Card — with corner-bracket reticle
--------------------------------------------------------------------------- */

.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* Top-left corner bracket */
.card::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 5px;
  width: 12px;
  height: 12px;
  border-top: 2px solid var(--accent);
  border-left: 2px solid var(--accent);
  opacity: 0.6;
  pointer-events: none;
}

/* Bottom-right corner bracket */
.card::after {
  content: "";
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 12px;
  height: 12px;
  border-bottom: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  opacity: 0.6;
  pointer-events: none;
}

.card--sm {
  padding: 1rem;
}

/* ---------------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background 0.12s,
    transform 0.08s,
    opacity 0.12s,
    box-shadow 0.12s;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 0 16px rgba(220, 38, 38, 0.35);
}

.btn--secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn--secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn--danger {
  background: var(--danger);
  color: #fff;
}
.btn--danger:hover:not(:disabled) {
  opacity: 0.85;
}

.btn--success {
  background: var(--success);
  color: #fff;
}
.btn--success:hover:not(:disabled) {
  opacity: 0.85;
}

.btn--full {
  width: 100%;
}

.btn--lg {
  padding: 0.85rem 2rem;
  font-size: 0.85rem;
}

.btn--sm {
  padding: 0.4rem 1rem;
  font-size: 0.72rem;
}

.btn--return-lobby {
  padding: 0.4rem 0.9rem;
  font-size: 0.7rem;
  margin-left: 0.5rem;
}

/* Volume controls */
.vol-controls {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-left: auto;
}

.vol-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.vol-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  width: 2.4rem;
  text-align: right;
  flex-shrink: 0;
}

.vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 70px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: background 0.15s;
}

.vol-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

.vol-slider:hover::-webkit-slider-thumb {
  background: var(--accent-hover);
}

.vol-slider:hover::-moz-range-thumb {
  background: var(--accent-hover);
}

/* ---------------------------------------------------------------------------
   Form elements
--------------------------------------------------------------------------- */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition:
    border-color 0.12s,
    box-shadow 0.12s;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

input::placeholder {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------------------
   Alert
--------------------------------------------------------------------------- */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.alert--error {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.4);
  color: #fca5a5;
}

.alert--info {
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.25);
  color: #f0ede8;
}

.alert--success {
  background: rgba(22, 163, 74, 0.12);
  border: 1px solid rgba(22, 163, 74, 0.4);
  color: #86efac;
}

/* ---------------------------------------------------------------------------
   Page header
--------------------------------------------------------------------------- */

.page-header {
  text-align: center;
  padding: 3rem 1rem 2rem;
}

/* Compact header used on sub-pages (lobby, game, results) */
.page-header--sm {
  padding-top: 2rem;
  padding-bottom: 1rem;
}

/* Smaller logo variant for sub-pages */
.logo--sm {
  font-size: clamp(1rem, 3vw, 1.4rem);
}

/* Monospace status line (e.g. "Awaiting mission briefing…") */
.tac-status {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

/* Monospace tactical link (e.g. abandon / leave) */
.tac-link {
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.tac-link:hover {
  color: var(--accent);
}

.logo {
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 4vw, 2.1rem);
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
}

.logo .logo-r {
  color: var(--accent);
}

.logo-sub {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.page-header .tagline {
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-size: 0.9rem;
  font-style: italic;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
}

/* ---------------------------------------------------------------------------
   Operation code badge
--------------------------------------------------------------------------- */

.room-code {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.25em;
  color: var(--accent);
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.5);
  border-radius: var(--radius-sm);
  padding: 0.4rem 1.2rem;
  text-shadow: 0 0 20px rgba(220, 38, 38, 0.4);
}

/* ---------------------------------------------------------------------------
   Player / Operative list
--------------------------------------------------------------------------- */

.player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  font-size: 0.9rem;
}

.btn-kick {
  margin-left: auto;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.btn-kick:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(220, 38, 38, 0.08);
}

.player-item .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  color: #ffffff;
  border: 1px solid #f3f3f3;
  flex-shrink: 0;
}

.player-item .badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 1px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.badge--host {
  padding: 2px 12px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.badge--you {
  background: rgba(22, 163, 74, 0.15);
  color: var(--success);
  border: 1px solid var(--success);
}
.badge--done {
  background: rgba(22, 163, 74, 0.15);
  color: var(--success);
  border: 1px solid var(--success);
}

/* ---------------------------------------------------------------------------
   Game: sticky header / mission HUD
--------------------------------------------------------------------------- */

.game-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(9, 9, 11, 0.97);
  border-bottom: 1px solid var(--border);
  border-bottom-color: var(--accent);
  padding: 0.55rem 1rem;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.game-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.game-stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.game-stat__label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #a0a0b8;
  line-height: 1;
}

.game-stat__value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  letter-spacing: 0.04em;
}

.game-stat__value--target {
  color: var(--accent);
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.35);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  animation: target-pulse 2.5s ease-in-out infinite;
  text-shadow: 0 0 18px rgba(220, 38, 38, 0.5);
}

@keyframes target-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.65;
  }
}

.game-stat__value--accent {
  color: var(--accent);
}

.game-stat__value--page {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 1.05rem;
  color: #d4a96a;
  letter-spacing: 0.04em;
}

/* Push this stat group to the far right of the HUD flex row */
.game-stat--right {
  margin-left: auto;
}

/* ---------------------------------------------------------------------------
   Game banners (fixed overlays)
--------------------------------------------------------------------------- */

/* Finish-window countdown — shown to operatives still racing */
.finish-window-banner {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--warning);
  color: #000;
  padding: 0.6rem 1.6rem;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: var(--shadow);
  z-index: 150;
  white-space: nowrap;
}

/* Mission accomplished — shown to the player who reaches the target */
.finish-banner {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: #fff;
  padding: 0.75rem 2rem;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  box-shadow: var(--shadow);
  z-index: 150;
  text-align: center;
}

/* ---------------------------------------------------------------------------
   Game: layout
--------------------------------------------------------------------------- */

.game-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  align-items: start;
}

@media (max-width: 768px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
  .game-sidebar {
    order: -1;
  }
}

/* ---------------------------------------------------------------------------
   Game: intelligence file display
--------------------------------------------------------------------------- */

.article-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius);
  min-height: 400px;
  overflow: hidden;
}

/* Classified file header bar above article title */
.article-container::before {
  content: "// INTELLIGENCE FILE — CLASSIFIED";
  display: block;
  background: rgba(220, 38, 38, 0.07);
  border-bottom: 1px solid var(--border);
  padding: 0.35rem 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.85;
}

.article-container h1.article-title {
  padding: 1rem 1.5rem 0.75rem;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.article-container h1.article-title::before {
  content: "FILE // ";
  color: var(--accent);
  opacity: 0.7;
  font-size: 0.8em;
}

/* Wikipedia article content */
.article-body {
  padding: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text);
}

.article-body h2,
.article-body h3,
.article-body h4 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

.article-body h2::before {
  content: "// ";
  color: var(--accent);
  opacity: 0.5;
}

.article-body p {
  color: var(--text);
  margin-bottom: 0.75rem;
}

.article-body ul,
.article-body ol {
  margin-left: 1.5rem;
  margin-bottom: 0.75rem;
}

.article-body li {
  margin-bottom: 0.25rem;
}

/* Clickable intel links */
.article-body .wiki-link {
  color: var(--wiki-link);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid rgba(96, 165, 250, 0.25);
  transition:
    color 0.1s,
    border-color 0.1s,
    background 0.1s;
  padding: 0 1px;
}

.article-body .wiki-link:hover {
  color: var(--wiki-link-hover);
  border-bottom-color: var(--wiki-link-hover);
  background: rgba(96, 165, 250, 0.08);
}

/* Images */
.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Math formula SVGs — Wikipedia marks these with mw-invert/skin-invert for
   dark skins. We apply the same invert so they read as light-on-dark. */
.article-body .mw-invert,
.article-body .skin-invert,
.article-body .mwe-math-fallback-image-inline,
.article-body .mwe-math-fallback-image-display {
  filter: invert(1);
  border: none;
  background: transparent;
  border-radius: 0;
}

/* Single thumb images — default float right, matching Wikipedia's default.
   Wikipedia uses mw-halign-left / tleft for left-floated figures.
   Do NOT add clear: right/left to the floats themselves — that causes each
   image to stack below the previous one, leaving large blank gaps when
   there isn't enough text to fill beside the stacked column of images. */
.article-body .thumb,
.article-body .thumbinner,
.article-body figure {
  float: right;
  margin: 0 0 1rem 1.5rem;
  max-width: 320px;
}

/* Left-floated figures (Parsoid: mw-halign-left; classic: tleft) */
.article-body figure.mw-halign-left,
.article-body .thumb.tleft,
.article-body .thumbinner.tleft {
  float: left !important;
  margin: 0 1.5rem 1rem 0 !important;
}

/* Right-floated — explicit class, same as default */
.article-body figure.mw-halign-right,
.article-body .thumb.tright,
.article-body .thumbinner.tright {
  float: right !important;
  margin: 0 0 1rem 1.5rem !important;
}

/* Centered / non-floated figures */
.article-body figure.mw-halign-center,
.article-body figure.mw-halign-none,
.article-body .thumb.tnone {
  float: none !important;
  margin: 0 auto 1rem !important;
  display: block;
  clear: both;
}

/* Clear floats at every section boundary so floats from one section
   never bleed into the next. Covers both old <h2> and Parsoid <div class="mw-heading"> wrappers. */
.article-body h2,
.article-body h3,
.article-body h4,
.article-body .mw-heading {
  clear: both;
}

/* Clearfix on the article body itself so the container grows to contain
   all floated children and avoids overflow into the sidebar. */
.article-body::after {
  content: '';
  display: table;
  clear: both;
}

/* Multi-image gallery rows (.trow / .tsingle)
   Wikipedia sets width/height as inline styles — !important overrides them. */
.article-body .trow {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0.75rem !important;
  float: none !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 0 1rem !important;
  clear: both;
}

.article-body .tsingle {
  flex: 1 1 160px !important;
  width: auto !important;
  max-width: 260px !important;
  display: flex !important;
  flex-direction: column;
}

.article-body .thumbimage {
  height: auto !important;
  overflow: visible !important;
  flex: 1;
}

.article-body .thumbimage img,
.article-body .tsingle img,
.article-body .mw-file-element {
  width: 100% !important;
  height: auto !important;
  max-width: 100%;
  display: block;
  object-fit: cover;
}

.article-body .thumbcaption {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.3rem 0.1rem 0;
  line-height: 1.4;
}

@media (max-width: 600px) {
  .article-body .thumb,
  .article-body .thumbinner,
  .article-body figure,
  .article-body figure.mw-halign-left,
  .article-body figure.mw-halign-right,
  .article-body .thumb.tleft,
  .article-body .thumb.tright {
    float: none !important;
    max-width: 100% !important;
    margin: 0 0 1rem !important;
    clear: both !important;
  }
  .article-body .tsingle {
    flex: 1 1 120px !important;
    max-width: 100% !important;
  }
}

/* Wikipedia traditional gallery (ul.mw-gallery-traditional)
   Each item is li.gallerybox with an inner .thumb and .gallerytext */
.article-body ul.gallery,
.article-body ul.mw-gallery-traditional,
.article-body ul.mw-gallery-packed,
.article-body ul.mw-gallery-packed-hover {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0.6rem !important;
  list-style: none !important;
  padding: 0 !important;
  margin: 0 0 1.5rem !important;
}

.article-body .gallerybox {
  width: auto !important;
  flex: 0 0 130px !important;
  display: flex !important;
  flex-direction: column;
}

.article-body .gallerybox .thumb {
  width: 130px !important;
  height: 130px !important;
  overflow: hidden !important;
  border: 1px solid var(--border) !important;
  border-top: 2px solid rgba(220, 38, 38, 0.4) !important;
  border-radius: var(--radius-sm);
  background: var(--bg-input) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
}

.article-body .gallerybox .thumb img {
  width: 130px !important;
  height: 130px !important;
  object-fit: cover !important;
  border: none !important;
  border-radius: 0 !important;
  display: block !important;
}

.article-body .gallerytext {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.25rem 0.1rem 0;
  line-height: 1.35;
  max-width: 130px;
}

/* Tables */
.article-body table {
  border-collapse: collapse;
  margin-bottom: 1rem;
  width: 100%;
  font-size: 0.875rem;
}

.article-body th,
.article-body td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
}

.article-body th {
  background: rgba(220, 38, 38, 0.07);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.article-body tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

/* ---------------------------------------------------------------------------
   Wikipedia sidebar / navbox / TOC overrides
   Wikipedia sets background colours via inline styles so !important is needed
--------------------------------------------------------------------------- */

/* Sidebar navigation tables (e.g. "Psychology" topic sidebar) */
.article-body .sidebar,
.article-body table.sidebar {
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  border-top: 2px solid var(--accent) !important;
  border-radius: var(--radius-sm);
  float: right;
  margin: 0 0 1rem 1.5rem !important;
  max-width: 220px;
  width: auto !important;
  font-size: 0.78rem;
}

/* Reset all child backgrounds to transparent */
.article-body .sidebar *,
.article-body table.sidebar * {
  background: transparent !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}

/* Sidebar header / title cells */
.article-body .sidebar .sidebar-title,
.article-body .sidebar .sidebar-title-with-pretitle,
.article-body .sidebar th:first-child,
.article-body .sidebar > tbody > tr:first-child th,
.article-body .sidebar > tbody > tr:first-child td {
  background: rgba(220, 38, 38, 0.1) !important;
  color: var(--accent) !important;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid rgba(220, 38, 38, 0.3) !important;
}

/* Sidebar links — keep them navigable and styled */
.article-body .sidebar a,
.article-body table.sidebar a {
  color: var(--wiki-link) !important;
  border-bottom: none;
}

.article-body .sidebar a:hover,
.article-body table.sidebar a:hover {
  color: var(--wiki-link-hover) !important;
}

/* TOC (table of contents) */
.article-body .toc,
.article-body #toc {
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  border-top: 2px solid var(--accent) !important;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem !important;
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.82rem;
}

.article-body .toc *,
.article-body #toc * {
  background: transparent !important;
  color: var(--text-muted) !important;
  border-color: var(--border) !important;
}

.article-body .toc .toctitle,
.article-body #toc .toctitle {
  color: var(--accent) !important;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.article-body .toc a,
.article-body #toc a {
  color: var(--wiki-link) !important;
}

/* Wikitable (standard data tables) — keep themed but unfloated */
.article-body .wikitable {
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  width: 100% !important;
  float: none !important;
}

.article-body .wikitable th {
  background: rgba(220, 38, 38, 0.08) !important;
  color: var(--text) !important;
}

.article-body .wikitable td {
  background: transparent !important;
  color: var(--text) !important;
}

/* Strip any residual white/light backgrounds on any table inside article */
.article-body table[style*="background"],
.article-body td[style*="background"],
.article-body th[style*="background"] {
  background: var(--bg-input) !important;
}

@media (max-width: 600px) {
  .article-body .sidebar,
  .article-body table.sidebar {
    float: none;
    max-width: 100%;
    margin: 0 0 1rem !important;
  }
}

/* Loading state */
.article-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  gap: 0.75rem;
}

/* ---------------------------------------------------------------------------
   Game: sidebar / operative status
--------------------------------------------------------------------------- */

.game-sidebar {
  position: sticky;
  top: 70px;
}

.sidebar-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-bottom: 0.75rem;
}

.sidebar-section h3 {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin-bottom: 0.65rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.leaderboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
}

.leaderboard-item.is-you {
  background: rgba(220, 38, 38, 0.07);
  border-left-color: var(--accent);
}

.leaderboard-item.is-finished {
  color: var(--success);
}

.leaderboard-rank {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-dim);
  min-width: 16px;
  font-size: 0.7rem;
}

.leaderboard-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.leaderboard-clicks {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--accent);
}

/* Path trail */
.path-list {
  list-style: none;
  font-size: 0.75rem;
  max-height: 160px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.path-list li {
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 0.12rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.path-list li::before {
  content: "> ";
  color: var(--accent);
  opacity: 0.5;
}

.path-list li:last-child {
  color: var(--text);
  font-weight: 700;
}

.path-list li:last-child::before {
  opacity: 1;
}

/* ---------------------------------------------------------------------------
   Countdown overlay
--------------------------------------------------------------------------- */

.countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  flex-direction: column;
  gap: 0.75rem;
}

.countdown-number {
  font-family: var(--font-mono);
  font-size: clamp(6rem, 22vw, 12rem);
  font-weight: 900;
  color: var(--accent);
  text-shadow:
    0 0 40px rgba(220, 38, 38, 0.9),
    0 0 80px rgba(220, 38, 38, 0.4);
  animation: pulse-scale 0.9s ease-in-out;
  line-height: 1;
  will-change: transform, opacity;
}

.countdown-text {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--text-muted);
}

@keyframes pulse-scale {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  60% {
    transform: scale(1.08);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

/* ---------------------------------------------------------------------------
   Results / mission debrief
--------------------------------------------------------------------------- */

.results-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.results-table th {
  background: rgba(220, 38, 38, 0.08);
  padding: 0.65rem 1rem;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

.results-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.results-table tr:last-child td {
  border-bottom: none;
}

.results-table tr.rank-1 td:first-child {
  color: #fbbf24;
  font-size: 1.1rem;
}
.results-table tr.rank-2 td:first-child {
  color: #94a3b8;
}
.results-table tr.rank-3 td:first-child {
  color: #cd7f32;
}

.result-name {
  font-weight: 600;
}

.path-collapse {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  margin-top: 0.25rem;
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.path-collapse:hover {
  text-decoration: underline;
}

.path-detail {
  display: none;
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.path-detail.open {
  display: block;
}

/* ---------------------------------------------------------------------------
   Winner route — mission debrief
--------------------------------------------------------------------------- */

.route-header {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.7;
  margin-bottom: 1rem;
}

.route-scroll {
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
}

/* ---------------------------------------------------------------------------
   Match config panel
--------------------------------------------------------------------------- */

.match-config {
  border-color: var(--border);
}

.match-config__header {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}

.match-config__row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.match-config__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-width: 160px;
}

/* Time limit HUD value */
.game-stat__value--timelimit {
  color: var(--text-muted);
}

.game-stat__value--urgent {
  color: var(--accent) !important;
  animation: urgentPulse 1s ease-in-out infinite;
  will-change: opacity;
}

@keyframes urgentPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ---------------------------------------------------------------------------
   Dev panel
--------------------------------------------------------------------------- */

.dev-panel {
  border-color: #2a1a00;
  background: #0d0900;
}

.dev-panel__header {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--warning);
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}

.dev-panel__row {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}

.dev-panel__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-width: 160px;
}

.dev-select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid #2a1a00;
  border-radius: var(--radius);
  padding: 0.3rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  outline: none;
}

.dev-select:focus {
  border-color: var(--warning);
}

.dev-panel__note {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.route-display {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: max-content;
  padding: 0.5rem 0;
}

@keyframes routeReveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.route-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  min-width: 90px;
  max-width: 140px;
  text-align: center;
  opacity: 0;
  animation: routeReveal 0.35s ease forwards;
  will-change: opacity, transform;
  position: relative;
}

.route-node--start {
  border-color: rgba(22, 163, 74, 0.6);
  background: rgba(22, 163, 74, 0.07);
}

.route-node--target {
  border-color: var(--accent);
  background: rgba(220, 38, 38, 0.1);
  box-shadow: 0 0 16px rgba(220, 38, 38, 0.25);
}

.route-node__label {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--success);
  margin-bottom: 0.25rem;
  line-height: 1;
}

.route-node--target .route-node__label {
  color: var(--accent);
}

.route-node__step {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  color: #6060780;
  letter-spacing: 0.12em;
  margin-bottom: 0.2rem;
  line-height: 1;
}

.route-node__title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 118px;
  display: block;
  line-height: 1.3;
}

.route-node--start .route-node__title {
  color: #86efac;
}
.route-node--target .route-node__title {
  color: var(--accent);
}

.route-connector {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0;
  animation: routeReveal 0.25s ease forwards;
  will-change: opacity, transform;
  padding: 0 2px;
}

.route-connector-line {
  width: 18px;
  height: 1px;
  background: repeating-linear-gradient(
    90deg,
    var(--accent) 0px,
    var(--accent) 4px,
    transparent 4px,
    transparent 8px
  );
  opacity: 0.45;
}

.route-connector-arrow {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent);
  opacity: 0.5;
  margin-left: 1px;
}

/* ---------------------------------------------------------------------------
   Secure comms / chat
--------------------------------------------------------------------------- */

.chat-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  height: 220px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.65rem;
  font-size: 0.78rem;
  scrollbar-width: thin;
}

.chat-message {
  margin-bottom: 0.3rem;
  line-height: 1.4;
  font-family: var(--font-mono);
}

.chat-message .chat-name {
  font-weight: 700;
  margin-right: 0.4rem;
}

.chat-message .chat-text {
  color: var(--text);
}

.chat-message.system .chat-text {
  color: var(--text-muted);
  font-style: normal;
  letter-spacing: 0.04em;
}

.chat-message.system .chat-text::before {
  content: "// ";
  color: var(--accent);
  opacity: 0.5;
}

.chat-input-row {
  display: flex;
  border-top: 1px solid var(--border);
}

.chat-input-row input {
  border: none;
  border-radius: 0;
  background: var(--bg-input);
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.chat-input-row input:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.chat-send-btn {
  padding: 0.5rem 0.9rem;
  background: var(--accent-dim);
  border: none;
  border-left: 1px solid var(--border);
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  transition: background 0.12s;
}

.chat-send-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ---------------------------------------------------------------------------
   Spinner
--------------------------------------------------------------------------- */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
  will-change: transform;
}

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

/* ---------------------------------------------------------------------------
   Divider
--------------------------------------------------------------------------- */

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin: 1.25rem 0;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------------------
   Utility: hidden
--------------------------------------------------------------------------- */

.hidden {
  display: none !important;
}

.page-main {
  padding-bottom: 3rem;
}

/* Operation / room code input */
.input--code {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-family: var(--font-mono);
  font-size: 1.3rem;
}

/* ---------------------------------------------------------------------------
   Scrollbar (webkit)
--------------------------------------------------------------------------- */

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--accent-dim);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ---------------------------------------------------------------------------
   Responsive
--------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .card {
    padding: 1rem;
  }
  .room-code {
    font-size: 1.6rem;
  }
  .game-header-inner {
    gap: 0.75rem;
  }
  .game-stat__label {
    display: none;
  }
}
