/* ────────────────────────────────────────────────────────────────
   Heroes of Combat and Magic — Jam Edition stylesheet
   Mobile-first, dark fantasy, no fixed viewport.
   ──────────────────────────────────────────────────────────────── */

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

:root {
  --bg-darkest: #0c0805;
  --bg-dark:    #1a1209;
  --bg-mid:     #2a1d10;
  --wood-dk:    #5c3d1e;
  --wood-md:    #7a5230;
  --wood-lt:    #9a6b3a;
  --gold-dk:    #c9a84c;
  --gold-md:    #dcc05c;
  --gold-lt:    #e8c96d;
  --beige:      #e0d8c0;
  --beige-mute: #b8b09a;
  --red-dk:     #6b2818;
  --red-md:     #a13a1f;
  --grn-md:     #4a8c3f;
  --shadow-deep:  0 6px 24px rgba(0,0,0,0.65);
  --shadow-soft:  0 3px 12px rgba(0,0,0,0.45);
  --font-h:  'Cinzel', 'Trajan Pro', Georgia, serif;
  --font-b:  'Crimson Text', 'Georgia', serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background: var(--bg-darkest);
  color: var(--beige);
  font-family: var(--font-ui);
  overflow-x: hidden;
}

body {
  position: relative;
  min-height: 100dvh;
}

/* ──────────────────────────── Screens ──────────────────────────── */
/* Don't override .screen base rules from style.css — they're tuned for combat.
   For my menu / setup screens (which need block layout) use a more-specific rule. */
#screen-menu, #screen-custom-setup, #screen-pvp, #screen-pvp-wait {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}
#screen-menu.active,
#screen-custom-setup.active,
#screen-pvp.active,
#screen-pvp-wait.active { display: block; }

/* ──────────────────────────── Menu ──────────────────────────── */
#screen-menu {
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}
#screen-menu.active { display: flex; }

.menu-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 0;
  filter: brightness(0.55) saturate(1.15);
}
.menu-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.55) 100%),
    linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(12,8,5,0.7) 100%);
  z-index: 1;
}
.menu-content {
  position: relative;
  z-index: 2;
  padding: 40px 20px;
  max-width: 600px;
  width: 100%;
}

.game-title {
  font-family: var(--font-h);
  font-size: clamp(34px, 8vw, 64px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 2px;
  color: var(--gold-lt);
  text-shadow:
    0 2px 0 #000,
    0 4px 0 #000,
    0 6px 24px rgba(232, 201, 109, 0.4),
    0 0 40px rgba(232, 201, 109, 0.2);
  margin-bottom: 12px;
}
.game-subtitle {
  font-family: var(--font-b);
  font-style: italic;
  color: var(--beige-mute);
  font-size: clamp(13px, 3vw, 16px);
  margin-bottom: 36px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 340px;
  margin: 0 auto;
}

.menu-hint {
  margin-top: 32px;
  font-family: var(--font-b);
  font-style: italic;
  color: var(--beige-mute);
  font-size: 13px;
}

/* ──────────────────────────── Buttons ──────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-family: var(--font-h);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--beige);
  background: linear-gradient(180deg, var(--wood-md) 0%, var(--wood-dk) 100%);
  border: 2px solid var(--gold-dk);
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: var(--shadow-soft);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.btn:hover {
  background: linear-gradient(180deg, var(--wood-lt) 0%, var(--wood-md) 100%);
  box-shadow: var(--shadow-deep), 0 0 0 1px var(--gold-md) inset;
  transform: translateY(-1px);
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--gold-md) 0%, var(--gold-dk) 100%);
  color: var(--bg-darkest);
  border-color: var(--gold-lt);
  text-shadow: 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--gold-lt) 0%, var(--gold-md) 100%);
}
.btn-fight {
  margin: 28px auto 0;
  display: block;
  font-size: 22px;
  padding: 16px 48px;
  letter-spacing: 3px;
}
.btn-mini {
  padding: 6px 12px;
  font-size: 13px;
  letter-spacing: 0.5px;
}
.btn-back {
  position: fixed;
  top: 12px; left: 12px;
  z-index: 100;
  background: rgba(26,18,9,0.85);
  border: 1px solid var(--gold-dk);
  color: var(--beige);
  font-family: var(--font-h);
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.btn-back:hover { background: rgba(60,40,20,0.95); }

/* ──────────────────────────── Setup screens ──────────────────────────── */
#screen-custom-setup, #screen-pvp, #screen-pvp-wait {
  background:
    linear-gradient(180deg, rgba(12,8,5,0.85) 0%, rgba(26,18,9,0.95) 100%),
    url('images/bg/city4.webm') center/cover;
  background-color: var(--bg-darkest);
}

.setup-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 60px 16px 40px;
}
.setup-wrap h2 {
  font-family: var(--font-h);
  font-size: clamp(24px, 5vw, 36px);
  color: var(--gold-lt);
  text-align: center;
  margin-bottom: 6px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
}
.setup-sub {
  text-align: center;
  font-family: var(--font-b);
  font-style: italic;
  color: var(--beige-mute);
  margin-bottom: 24px;
  font-size: 14px;
}

.setup-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-bottom: 24px;
  padding: 16px;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--wood-dk);
  border-radius: 6px;
}
.setup-controls label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-family: var(--font-b);
  color: var(--beige);
}
.setup-controls input[type="range"] {
  width: 200px;
  accent-color: var(--gold-md);
}
.setup-controls input[type="text"] {
  background: var(--bg-mid);
  border: 1px solid var(--wood-md);
  color: var(--beige);
  padding: 6px 10px;
  border-radius: 4px;
  font-family: var(--font-b);
  font-size: 14px;
}
.setup-controls span {
  font-family: var(--font-h);
  color: var(--gold-lt);
  font-weight: 600;
  min-width: 40px;
  text-align: right;
}

/* ──────────────────────────── Army builder ──────────────────────────── */
.armies-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.armies-grid-single { grid-template-columns: 1fr; max-width: 700px; margin: 0 auto; }

.army-col {
  background: rgba(0,0,0,0.45);
  border: 1px solid var(--wood-md);
  border-radius: 6px;
  padding: 14px;
}
.army-col h3 {
  font-family: var(--font-h);
  font-size: 18px;
  color: var(--gold-lt);
  margin-bottom: 10px;
  text-align: center;
  letter-spacing: 1px;
}

.faction-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.faction-tab {
  padding: 5px 12px;
  font-family: var(--font-h);
  font-size: 12px;
  background: var(--bg-mid);
  color: var(--beige-mute);
  border: 1px solid var(--wood-dk);
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.5px;
}
.faction-tab:hover { color: var(--beige); border-color: var(--wood-lt); }
.faction-tab.active {
  background: var(--wood-md);
  color: var(--gold-lt);
  border-color: var(--gold-md);
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 6px;
  margin-bottom: 10px;
  min-height: 240px;
  max-height: 380px;
  overflow-y: auto;
  padding: 4px;
}
.unit-card {
  background: var(--bg-mid);
  border: 1px solid var(--wood-dk);
  border-radius: 4px;
  padding: 4px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, transform 0.1s;
  user-select: none;
}
.unit-card:hover { border-color: var(--gold-md); transform: translateY(-1px); }
.unit-card.selected { border-color: var(--gold-lt); background: linear-gradient(180deg, var(--bg-mid) 0%, var(--wood-dk) 100%); }
.unit-card .portrait {
  width: 100%;
  aspect-ratio: 1;
  background: #000;
  border-radius: 3px;
  background-size: cover;
  background-position: center;
  margin-bottom: 3px;
}
.unit-card .name {
  font-size: 10px;
  font-family: var(--font-h);
  color: var(--beige);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.unit-card .cost {
  font-size: 9px;
  color: var(--gold-md);
  font-family: var(--font-ui);
  font-weight: 600;
}
.unit-card .count {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--red-md);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 18px;
  text-align: center;
  font-family: var(--font-ui);
  display: none;
}
.unit-card.selected .count { display: block; }

.army-summary {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-family: var(--font-h);
  font-size: 14px;
  color: var(--beige);
  border-top: 1px solid var(--wood-dk);
  padding-top: 8px;
  flex-wrap: wrap;
}
.army-summary .pts-used { color: var(--gold-lt); font-weight: 700; }
.army-summary .pts-budget { color: var(--beige-mute); }
.army-summary.over .pts-used { color: var(--red-md); }

/* ──────────────────────────── PvP ──────────────────────────── */
.pvp-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 24px 0 12px;
  flex-wrap: wrap;
}
.rooms-header {
  text-align: center;
  font-family: var(--font-h);
  color: var(--gold-lt);
  font-size: 20px;
  margin: 24px 0 12px;
  letter-spacing: 1px;
}
.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 700px;
  margin: 0 auto;
}
.rooms-empty {
  text-align: center;
  font-family: var(--font-b);
  font-style: italic;
  color: var(--beige-mute);
  padding: 24px;
}
.room-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--wood-md);
  border-radius: 4px;
  padding: 10px 14px;
  font-family: var(--font-b);
  flex-wrap: wrap;
  gap: 10px;
}
.room-item .room-info {
  flex: 1;
  min-width: 200px;
}
.room-item .room-host {
  font-weight: 700;
  color: var(--gold-md);
  font-family: var(--font-h);
}
.room-item .room-meta {
  font-size: 12px;
  color: var(--beige-mute);
  margin-top: 2px;
}

.wait-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 20px;
}
.wait-wrap h2 {
  font-family: var(--font-h);
  color: var(--gold-lt);
  margin: 24px 0 8px;
  font-size: 24px;
}
.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--wood-dk);
  border-top-color: var(--gold-lt);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Combat-screen styling is handled entirely by style.css (the same combat
   pipeline as the main game). The legacy block here was a leftover from
   the discarded jam-specific CombatRunner — its `.combat-grid` /
   `.unit-token` / `.cell` rules collided with style.css and pushed the
   battlefield 47.72 px down via `margin-top: 4vh`. Removed 2026-04-27. */

/* ──────────────────────────── Toast ──────────────────────────── */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dark);
  border: 1px solid var(--gold-md);
  color: var(--beige);
  padding: 10px 18px;
  border-radius: 4px;
  font-family: var(--font-b);
  z-index: 1000;
  box-shadow: var(--shadow-deep);
  max-width: 90vw;
  text-align: center;
}
.toast.hidden { display: none; }

/* ──────────────────────────── Responsive ──────────────────────────── */
@media (max-width: 768px) {
  .armies-grid { grid-template-columns: 1fr; }
  .setup-wrap { padding-top: 56px; }
  .menu-content { padding: 30px 14px; }
  .game-title { letter-spacing: 1px; }
}

/* ──────────────── JAM 2026-04-27: hero panel as <video> ────────────────
   Hero idle/attack are now <video> elements (vp9 alpha) instead of
   <div background-image + @keyframes steps()>. The legacy CSS rules in
   style.css (background-image, background-size, animation) do nothing on
   <video> — these new rules ensure the video plays correctly inline. */
video.hero-panel-sprite,
video.hero-shadow-sprite {
  display: block;
  /* `fill` mirrors the legacy CSS background-size: <fixed-W>px <fixed-H>px
     behaviour — the sprite was drawn STRETCHED to the panel's box (138×138
     ignoring the 189:168 source aspect). Using `contain` would letterbox
     the video and shrink the hero, breaking the locked panel position. */
  object-fit: fill;
  pointer-events: none;
}
/* The shadow video plays the same source as the main hero video; the
   .hero-shadow-sprite CSS class in style.css already applies brightness(0)
   filter + opacity 0.25, turning the colour video frames into a flat black
   silhouette. Same trick the canvas-based sprite-sheet shadow uses. */
