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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #2c3e50;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  cursor: crosshair;
}

/* 3D character overlay (js/character3D.js) - kept a fully separate canvas
   from #game-canvas (Canvas2D and WebGL can't share one canvas element).
   position/size are set in JS (Game.resize()) to exactly match
   #game-canvas's own rendered box, since that box is letterboxed by
   flexbox/max-width/max-height rather than filling #game-container. Never
   intercepts input (pointer-events: none) and sits above the 2D canvas but
   below the DOM HUD buttons (z-index 10) and modals. */
#game-canvas-3d {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 5;
  display: none; /* toggled on only when the DEV "3D Model" character visual is selected */
}

#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#ui-overlay .game-modal {
  pointer-events: auto;
}

/* A very light paper/white tint over the world while a modal is open -
   never a dark web-modal backdrop. Toggled by UIManager (ui.js) alongside
   showing/hiding the modal, not tied to any specific modal's markup. */
#ui-overlay.overlay-dim {
  background: rgba(255, 253, 245, 0.5);
  transition: background 0.15s ease;
}

/* ============================================================
   Shared notebook / hand-drawn modal system - reused by mode
   select, difficulty select, round-end, and (later) the shop.
   Deliberately static/deterministic irregularity (asymmetric
   border-radius, a fixed-angle retraced outline) - never
   randomized per frame, so nothing ever "shakes".
   ============================================================ */

.game-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(clamp(380px, 30vw, 460px), calc(100vw - 32px));
  padding: 26px 28px 24px;
  text-align: center;

  background-color: #fffef5;
  background-image:
    linear-gradient(rgba(100, 149, 237, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 149, 237, 0.12) 1px, transparent 1px);
  background-size: 24px 24px;

  border: 2.5px solid #2b2b2b;
  border-radius: 9px 11px 8px 10px / 8px 10px 9px 11px;
  box-shadow:
    3px 3px 0 rgba(60, 60, 60, 0.18),
    5px 5px 0 rgba(60, 60, 60, 0.08);
}

/* A second, slightly rotated/offset outline - reads as "traced twice with
   a pen", the hand-drawn stand-in for a soft drop-shadow. */
.game-modal::before {
  content: '';
  position: absolute;
  inset: -5px;
  border: 1.4px solid rgba(43, 43, 43, 0.3);
  border-radius: inherit;
  transform: rotate(-0.4deg);
  pointer-events: none;
  z-index: -1;
}

.game-modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #222;
  margin-bottom: 6px;
  line-height: 1.25;
}

.game-modal-title .winner-name {
  display: block;
  font-size: 1.4em;
}

.game-modal-title .winner-suffix {
  display: block;
  font-size: 0.62em;
  font-weight: 600;
  color: #222;
  margin-top: 4px;
  letter-spacing: 0.02em;
}

.winner-p1 { color: #1d4e8f; }
.winner-p2 { color: #9b2c22; }

.game-modal-content {
  margin: 16px 0 20px;
}

.game-modal-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: #555;
  margin-bottom: 4px;
}

.game-modal-score {
  font-size: 1.9rem;
  font-weight: 700;
}

.game-modal-score .score-p1 { color: #1d4e8f; }
.game-modal-score .score-sep { color: #222; margin: 0 6px; }
.game-modal-score .score-p2 { color: #9b2c22; }

.game-modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}

.game-modal-buttons.vertical {
  flex-direction: column;
}

.game-modal-buttons.vertical .game-button {
  width: 100%;
}

.game-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 20px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #222;
  background: rgba(255, 255, 255, 0.4);
  border: 2px solid #2b2b2b;
  border-radius: 7px 9px 8px 10px / 7px 8px 9px 7px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease;
}

.game-button:hover {
  background: rgba(100, 149, 237, 0.1);
  box-shadow: 2px 2px 0 rgba(43, 43, 43, 0.18);
  transform: translate(-1px, -1px);
}

.game-button:active {
  transform: translate(1px, 1px);
  box-shadow: none;
}

/* The one accent color for a modal's primary action - matches the same
   blue used for Player 1 in the HUD (renderer.js's PLAYER1_COLOR), not a
   solid modern-web button fill. */
.game-button-primary {
  border-color: #1d4e8f;
  background: rgba(29, 78, 143, 0.07);
}

.game-button-primary::after {
  content: '';
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 6px;
  height: 2px;
  background: rgba(29, 78, 143, 0.5);
  border-radius: 2px;
  transform: rotate(-0.6deg);
}

.game-button-primary:hover {
  background: rgba(29, 78, 143, 0.14);
}

.game-icon {
  display: inline-flex;
  color: #2b2b2b;
  flex-shrink: 0;
}

/* ============================================================
   Arsenal weapon cards - lives inside the same .game-modal as
   every other modal, no separate visual system.
   ============================================================ */

.weapon-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin: 16px 0 18px;
}

.weapon-card {
  position: relative;
  flex: 1 1 150px;
  min-width: 140px;
  max-width: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 14px 10px 12px;
  border: 2px solid #2b2b2b;
  border-radius: 8px 10px 7px 9px / 7px 9px 8px 10px;
  background: rgba(255, 255, 255, 0.35);
}

/* The current weapon's card - a light accent outline/fill, never a glow. */
.weapon-card-selected {
  border-color: #1d4e8f;
  background: rgba(29, 78, 143, 0.08);
}

/* Unaffordable (and not already selected) - dimmed, not hidden, so the
   player still sees what exists and why it's out of reach. */
.weapon-card-disabled {
  opacity: 0.55;
}

.weapon-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
}

.weapon-card-check {
  color: #1d4e8f;
}

.weapon-card-name {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  color: #222;
}

.weapon-card-stat {
  font-size: 0.8rem;
  color: #333;
}

.weapon-card-desc {
  font-size: 0.72rem;
  line-height: 1.3;
  color: #555;
  min-height: 30px;
}

.weapon-card-price {
  font-size: 0.82rem;
  font-weight: 700;
  color: #8a6d1f;
  margin-top: 2px;
}

.weapon-card-warning {
  font-size: 0.68rem;
  font-weight: 600;
  color: #9b2c22;
}

.weapon-card-btn {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.85rem;
  margin-top: 6px;
}

.weapon-card-btn:disabled {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

/* ============================================================
   HUD weapon control - a compact DOM button (same corner-button
   pattern as #btn-restart) showing the active human player's
   current weapon and opening the Arsenal. Shown/hidden and
   relabeled every frame by main.js's updateArsenalButton() -
   only while it's actually safe to open (see canOpenArsenal()).
   ============================================================ */

#btn-arsenal {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 18px;
  font-family: inherit;
  border: 1.8px solid #333;
  border-radius: 6px 8px 7px 9px / 6px 7px 8px 6px;
  background: rgba(255, 255, 250, 0.92);
  color: #222;
  cursor: pointer;
  z-index: 10;
  transition: background 0.15s;
}

#btn-arsenal:hover {
  background: #f0f0e8;
}

#btn-arsenal .hud-arsenal-weapon {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #444;
}

#btn-arsenal .hud-arsenal-label {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #222;
}

#btn-restart {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 1.8px solid #333;
  border-radius: 3px;
  background: rgba(255, 255, 250, 0.92);
  font-size: 1.3rem;
  color: #333;
  cursor: pointer;
  z-index: 10;
  transition: background 0.15s;
}

#btn-restart:hover {
  background: #f0f0e8;
}
