/* ==========================================================
   War Times — Tactical Atlas & War Room Design Tokens
   ========================================================== */
:root {
  --font-serif: 'Cinzel', Georgia, serif;
  --font-display: 'Bricolage Grotesque', 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Surfaces (Warm Cartographic Parchment Light) */
  --bg: #efe9dc;
  --bg-glow: radial-gradient(1200px 640px at 12% -10%, rgba(164, 121, 48, 0.14), transparent 60%),
    radial-gradient(960px 540px at 105% 0%, rgba(34, 85, 164, 0.09), transparent 60%);
  --surface: #fbf8f1;
  --surface-2: #f3ede0;
  --surface-3: #e7dfd0;
  --overlay: rgba(16, 14, 18, 0.64);

  /* Sea & Map Surfaces */
  --sea-bg: #1e3547;
  --sea-grid: rgba(255, 245, 220, 0.07);
  --sea-route: rgba(250, 224, 152, 0.72);
  --territory-stroke: rgba(20, 17, 15, 0.78);

  /* Ink */
  --ink: #1e1915;
  --ink-2: #574e44;
  --ink-3: #877c6e;
  --line: rgba(38, 30, 20, 0.11);
  --line-strong: rgba(38, 30, 20, 0.2);

  /* Brand (Imperial Brass / Tactical Indigo) */
  --brand: #274472;
  --brand-strong: #192f52;
  --brand-ink: #ffffff;
  --brand-soft: rgba(39, 68, 114, 0.11);
  --brand-text: #1f3a66;

  /* Call to action (Antique Brass Gold) */
  --cta: #d99b26;
  --cta-edge: #9e6a0b;
  --cta-ink: #17120c;
  --cta-soft: rgba(217, 155, 38, 0.18);
  --cta-text: #855606;

  /* Status */
  --success: #1f7a4c;
  --success-soft: rgba(31, 122, 76, 0.13);
  --success-text: #155c38;
  --danger: #b92b27;
  --danger-soft: rgba(185, 43, 39, 0.12);
  --danger-text: #961d1a;
  --warn: #c78312;

  /* Shape & depth */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 24px;
  --shadow-1: 0 1px 3px rgba(24, 18, 12, 0.08), 0 1px 1px rgba(24, 18, 12, 0.04);
  --shadow-2: 0 12px 32px -12px rgba(24, 18, 12, 0.25), 0 2px 6px rgba(24, 18, 12, 0.06);
  --shadow-3: 0 32px 84px -18px rgba(10, 8, 6, 0.58);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme='dark'] {
  --bg: #0e131b;
  --bg-glow: radial-gradient(1200px 620px at 12% -10%, rgba(217, 155, 38, 0.11), transparent 58%),
    radial-gradient(960px 540px at 105% 0%, rgba(56, 114, 196, 0.14), transparent 58%);
  --surface: #151c27;
  --surface-2: #1c2533;
  --surface-3: #253042;
  --overlay: rgba(4, 7, 12, 0.8);

  --sea-bg: #112230;
  --sea-grid: rgba(255, 240, 200, 0.06);
  --sea-route: rgba(245, 208, 118, 0.68);
  --territory-stroke: rgba(7, 10, 15, 0.88);

  --ink: #f3efe6;
  --ink-2: #a9b2c2;
  --ink-3: #758196;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.17);

  --brand: #3c69b5;
  --brand-strong: #294c8a;
  --brand-soft: rgba(60, 105, 181, 0.2);
  --brand-text: #8bb4f7;

  --cta: #e0a734;
  --cta-edge: #9c6c10;
  --cta-soft: rgba(224, 167, 52, 0.18);
  --cta-text: #f5cd70;

  --success: #2ea063;
  --success-soft: rgba(46, 160, 99, 0.16);
  --success-text: #6de0a3;
  --danger: #d9413d;
  --danger-soft: rgba(217, 65, 61, 0.16);
  --danger-text: #ff8e8b;

  --shadow-1: 0 2px 4px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 16px 40px -14px rgba(0, 0, 0, 0.72), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-3: 0 36px 90px -18px rgba(0, 0, 0, 0.9);
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-image: var(--bg-glow);
  background-attachment: fixed;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
:focus-visible { outline: 3px solid var(--cta); outline-offset: 2px; }

h1, h2, h3 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.hidden { display: none !important; }
.ico { width: 1.15em; height: 1.15em; flex-shrink: 0; display: inline-block; vertical-align: -0.2em; }
.muted { color: var(--ink-2); }

.eyebrow {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.logo-mark { width: 42px; height: 42px; flex-shrink: 0; }

.wordmark {
  font-family: var(--font-serif);
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
}

.wordmark .amp { color: var(--cta-text); }

/* Commander Portrait Frames */
.commander-portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.portrait-frame {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 2.5px solid var(--pc, var(--cta));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  background: #141820;
  flex-shrink: 0;
}

.portrait-frame.round { border-radius: 50%; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  display: inline-block;
  flex-shrink: 0;
}

.dot.on {
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

.dot.wait { animation: dotPulse 1.2s ease-in-out infinite; }
@keyframes dotPulse { 50% { opacity: 0.35; } }

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

/* ==========================================================
   In-app confirmation dialog
   ========================================================== */
.app-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: dlgFade 0.16s ease-out;
}
.app-dialog-backdrop.closing { opacity: 0; transition: opacity 0.15s; }
.app-dialog {
  --tone: var(--brand);
  --tone-edge: var(--brand-strong);
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  padding: 26px 24px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  animation: dlgPop 0.22s var(--ease);
}
.app-dialog.tone-danger { --tone: var(--danger); --tone-edge: #6f1512; }
.app-dialog-icon {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 14%, var(--surface));
}
.app-dialog-icon .ico { width: 28px; height: 28px; }
.app-dialog h2 { font-size: 1.4rem; }
.app-dialog p { color: var(--ink-2); line-height: 1.45; font-size: 0.95rem; }
.app-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 8px; }
.app-dialog-btn { border: none; border-radius: var(--r-md); padding: 13px 12px; font-weight: 800; font-size: 0.96rem; }
.app-dialog-btn.cancel { background: var(--surface-3); color: var(--ink); }
.app-dialog-btn.ok { background: var(--tone); color: #fff; box-shadow: 0 4px 0 var(--tone-edge); }
@keyframes dlgFade { from { opacity: 0; } }
@keyframes dlgPop { from { transform: translateY(10px) scale(0.96); opacity: 0; } }
