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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0a14;
  color: #f4f1ea;
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

.hidden { display: none !important; }

.comic-panel {
  background: rgba(14, 15, 28, 0.92);
  border: 3px solid #06060a;
  box-shadow: 0 0 0 2px #f6c431, 6px 6px 0 #06060a;
  padding: 12px 14px;
}

.comic-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  background: #232a3e;
  color: #ffffff;
  border: 3px solid #06060a;
  box-shadow: 0 0 0 2px #6b7aa0, 4px 4px 0 #06060a;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, filter 0.1s ease;
}

.comic-btn:hover {
  transform: translate(-1px, -1px);
  filter: brightness(1.16);
  box-shadow: 0 0 0 2px #f6c431, 5px 5px 0 #06060a;
}

.comic-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 2px #f6c431, 2px 2px 0 #06060a;
}

.comic-btn small {
  font-weight: 500;
  font-size: 11px;
  color: #d6deee;
}

.small-btn {
  padding: 6px 10px;
  font-size: 12px;
  align-items: center;
}

.primary-btn { background: #b4321c; }
.blue-btn { background: #1e5b8e; }
.purple-btn { background: #5a277e; }
.green-btn { background: #1f7640; }
.danger-btn { background: #7f2424; }
.dark-btn { background: #1c2233; }

.gold-text { color: #ffd646; font-weight: 800; }
.cyan-text { color: #67e6ff; font-weight: 800; }
.danger-text { color: #ff564a; font-weight: 800; }

.overlay-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(16, 12, 28, 0.56), rgba(6, 5, 12, 0.88));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 18px;
}

.menu-hero {
  width: min(680px, 95vw);
  text-align: center;
  padding: 24px;
}

.menu-hero h1 {
  font-size: clamp(34px, 5vw, 54px);
  letter-spacing: 3px;
  color: #ffd646;
  text-shadow: 4px 4px 0 #06060a;
  margin-top: 8px;
}

.subtitle {
  color: #e6e0f5;
  font-size: 13px;
  letter-spacing: 1px;
  margin-bottom: 14px;
}

.menu-badge-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.comic-tag {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 9px;
  border: 2px solid #06060a;
  transform: skewX(-8deg);
}

.gold-tag { background: #f6c431; color: #090910; }
.cyan-tag { background: #26c6ff; color: #061018; }

.active-aspect-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: rgba(8, 9, 18, 0.9);
  border: 2px solid #f6c431;
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 13px;
}

.seed-control-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(8, 9, 18, 0.9);
  border: 2px solid #35415c;
  padding: 6px 12px;
  margin-bottom: 12px;
}
.seed-label {
  font-size: 11px;
  font-weight: 800;
  color: #ffd646;
  white-space: nowrap;
  letter-spacing: 0.6px;
}
.seed-input {
  max-width: 170px;
  margin-top: 0 !important;
  text-align: center;
  font-weight: 800;
  font-size: 13px !important;
  color: #ffd646 !important;
  user-select: text;
}
.coop-seed-note {
  margin-top: 8px;
  font-size: 11px;
  color: #b7c2d9;
  font-weight: 700;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-actions .comic-btn {
  width: 100%;
}

.controls-strip {
  margin-top: 14px;
  font-size: 11px;
  color: #c9d2e6;
  background: rgba(6, 7, 14, 0.85);
  padding: 8px 10px;
  border: 2px solid #353f59;
}

.modal-wide { width: min(980px, 96vw); max-height: 92vh; overflow-y: auto; padding: 20px; }
.modal-compact { width: min(560px, 94vw); text-align: center; padding: 24px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #2c354f; padding-bottom: 8px; margin-bottom: 12px; }
.modal-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; gap: 10px; }
.section-label { font-size: 12px; font-weight: 800; color: #ffd646; margin: 8px 0 6px; letter-spacing: 0.6px; }

.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

@media (max-width: 780px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

.hud-root { position: fixed; inset: 0; pointer-events: none; z-index: 15; }
.hud-root button { pointer-events: auto; }

.hud-top-left { position: fixed; top: 14px; left: 14px; width: min(440px, 52vw); }
.hud-chamber-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.hud-wind { font-size: 11px; font-weight: 800; color: #a8f0ff; background: rgba(18, 30, 52, 0.9); border: 1px solid #49b6ff; padding: 1px 6px; white-space: nowrap; }
.hud-weather { font-size: 11px; font-weight: 800; color: #ffd646; background: rgba(24, 20, 38, 0.92); border: 1px solid #ffd646; padding: 1px 6px; white-space: nowrap; }
.hud-weather.w-fog { color: #d8e2ef; border-color: #9bb0c9; background: rgba(34, 42, 54, 0.92); }
.hud-weather.w-rain { color: #67e6ff; border-color: #38b2ff; background: rgba(12, 28, 48, 0.92); }
.hud-weather.w-gale { color: #ffe08a; border-color: #ffb830; background: rgba(42, 28, 14, 0.92); }
.hud-weather.w-cold { color: #d4f4ff; border-color: #9be4ff; background: rgba(20, 36, 52, 0.92); }
.hud-weather.w-storm { color: #ff8ae2; border-color: #d44dff; background: rgba(36, 12, 48, 0.92); }
.hud-sub-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hud-seed { font-size: 11px; color: #b7c2d9; font-weight: 700; white-space: nowrap; }
.hud-sub { font-size: 12px; color: #d6def0; }

.boss-bar-wrap { margin-top: 8px; }
.boss-bar-label { font-size: 12px; font-weight: 800; color: #ff795e; margin-bottom: 3px; }
.boss-track { height: 14px; }

.hud-top-right { position: fixed; top: 14px; right: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.minimap-wrap { padding: 6px; text-align: center; }
#minimapCanvas { display: block; border: 2px solid #06060a; background: #0c1724; }
.minimap-caption { font-size: 10px; font-weight: 800; color: #ffd646; margin-top: 3px; }
.hud-mini-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  width: 210px;
}

.vitals-panel { position: fixed; bottom: 14px; left: 14px; width: clamp(200px, 24vw, 285px); }
.vital-header { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.bar-label { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; margin-top: 4px; }
.bar-track { width: 100%; height: 13px; background: #11131f; border: 2px solid #06060a; overflow: hidden; margin-top: 2px; }
.bar-fill { height: 100%; transition: width 0.08s linear; }
.hp-fill { background: linear-gradient(90deg, #bf2626, #ff5d47); }
.mana-fill { background: linear-gradient(90deg, #1d5bd6, #49b6ff); }
.gold-fill { background: linear-gradient(90deg, #e08d10, #ffd646); }
.boss-fill { background: linear-gradient(90deg, #8e1136, #ff2a55); }
.vitals-footer { display: flex; justify-content: space-between; font-size: 11px; margin-top: 6px; }

.ground-panel {
  position: fixed;
  bottom: 102px;
  left: 50%;
  transform: translateX(-50%);
  width: min(460px, 84vw);
  text-align: center;
  box-shadow: 0 0 0 2px #ff564a, 6px 6px 0 #06060a;
}

.spellbar {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(8, 42px);
  gap: 4px;
  padding: 5px 7px;
}

.spell-slot {
  width: 42px;
  height: 34px;
  background: #141827;
  border: 2px solid #35415c;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  pointer-events: auto;
  cursor: pointer;
}
.spell-slot.left-eq { border-color: #49b6ff; box-shadow: inset 0 0 0 2px #49b6ff; }
.spell-slot.right-eq { border-color: #ff9c3b; box-shadow: inset 0 0 0 2px #ff9c3b; }
.spell-slot.locked { opacity: 0.4; }
.spell-slot small { font-size: 8px; color: #b7c2d9; }

.terrain-lock-hint {
  position: fixed;
  left: 50%;
  top: 56%;
  transform: translateX(-50%);
  background: rgba(110, 12, 18, 0.92);
  border: 2px solid #ff4242;
  color: #ffd7d7;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  letter-spacing: 0.5px;
  pointer-events: none;
  z-index: 15;
}

.crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  font-weight: 900;
  color: #ffd646;
  text-shadow: 2px 2px 0 #06060a, -1px -1px 0 #06060a;
}

.nose-reticle {
  position: fixed;
  transform: translate(-50%, -50%);
  font-size: 20px;
  font-weight: 900;
  color: #67e6ff;
  text-shadow: 0 0 6px rgba(103, 230, 255, 0.85), 2px 2px 0 #06060a;
  pointer-events: none;
}

.pointer-hint {
  position: fixed;
  bottom: 98px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 10, 18, 0.86);
  border: 2px solid #f6c431;
  padding: 3px 10px;
  font-size: 10px;
  white-space: nowrap;
  color: #ffd646;
}

@media (max-width: 1120px) {
  .spellbar {
    left: auto;
    right: 14px;
    transform: none;
    grid-template-columns: repeat(8, 36px);
  }
  .spell-slot {
    width: 36px;
    height: 32px;
    font-size: 8px;
  }
  .pointer-hint { display: none; }
}

.popup-layer { position: fixed; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
.comic-popup {
  position: fixed;
  font-weight: 900;
  font-size: 18px;
  color: #ffffff;
  text-shadow: 2px 2px 0 #06060a, -2px -2px 0 #06060a, 2px -2px 0 #06060a, -2px 2px 0 #06060a;
  transform: translate(-50%, -50%) rotate(-6deg);
  white-space: nowrap;
}
.comic-popup.crit { font-size: 24px; color: #ffd646; }

.boss-splash {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translateX(-50%) skewX(-6deg);
  background: #140812;
  border: 4px solid #06060a;
  box-shadow: 0 0 0 3px #ff3344, 10px 10px 0 #06060a;
  padding: 16px 36px;
  text-align: center;
  z-index: 26;
}
.boss-splash-tag { font-size: 12px; font-weight: 900; color: #ff564a; letter-spacing: 2px; }
.boss-splash-name { font-size: 38px; font-weight: 900; color: #ffd646; text-shadow: 3px 3px 0 #06060a; }
.boss-splash-sub { font-size: 14px; color: #ffffff; }

.toast-banner {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 13, 24, 0.94);
  border: 2px solid #ffd646;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #ffd646;
  z-index: 28;
}

.coop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 780px) { .coop-grid { grid-template-columns: 1fr; } }
.coop-col { background: rgba(10, 12, 22, 0.75); border: 2px solid #2b334c; padding: 12px; }
.coop-btn-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.signal-box { margin-top: 10px; }
textarea, input[type="text"] {
  width: 100%;
  background: #090b14;
  color: #e6f4ff;
  border: 2px solid #415075;
  padding: 6px 8px;
  font-family: monospace;
  font-size: 11px;
  margin-top: 6px;
}

.boon-card {
  background: #17182a;
  border: 3px solid #06060a;
  box-shadow: 0 0 0 2px #f6c431, 4px 4px 0 #06060a;
  padding: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.boon-card:hover { filter: brightness(1.16); transform: translateY(-2px); }
.stats-pill { margin-top: 10px; font-weight: 700; color: #67e6ff; font-size: 14px; }
.mt-10 { margin-top: 10px; }
.centered-actions { justify-content: center; margin-top: 16px; }
.span-2 { grid-column: span 2; }

.logs-alert {
  background: rgba(140, 24, 34, 0.9);
  border: 2px solid #ff564a;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 10px;
  margin-bottom: 10px;
}
.logs-pre {
  background: #090b14;
  color: #d6e4ff;
  border: 2px solid #35415c;
  padding: 10px;
  font-family: monospace;
  font-size: 11px;
  line-height: 1.4;
  max-height: 52vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}
