/* Avalanche Chronicles: The Game — comic-flavored UI over a 3D canvas */

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

:root {
  --paper: #f2f9fe;       /* comic snow-white with a breath of sky */
  --ink: #163049;         /* the comic's navy outline color */
  --accent: #f2c500;      /* Toby's yellow band */
  --accent-ink: #163049;
  --sky: #aed7f2;
  --mike: #f5821e;
  --toby: #2b6fb3;
}

html, body { height: 100%; overflow: hidden; background: #0c1018; }
body {
  font-family: "Outfit", -apple-system, "Helvetica Neue", Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#hud-topleft { position: absolute; top: 14px; left: 14px; display: flex; flex-direction: column; gap: 6px; }
#hud-topright { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
#hud-bottomright { position: absolute; bottom: 14px; right: 14px; }

.chip {
  display: inline-block;
  background: rgba(14, 18, 26, 0.78);
  color: #f3f6fb;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.chip.sub { font-size: 13px; font-weight: 700; opacity: 0.92; }
.chip.ok { border-color: #54c06c; color: #b8f0c6; }
.chip.warn { border-color: #f0a93c; color: #ffd9a0; }
.chip.danger { border-color: #e04545; color: #ffb8b8; }
.chip.urgent { border-color: #e04545; color: #ff9d9d; animation: pulse 1s infinite; }
.chip.unknown { color: #c8cede; border-style: dashed; }

@keyframes pulse { 50% { opacity: 0.45; } }

/* ?debug=1 dev bar — summit bypass buttons, middle-right (testing only; clear of all HUD) */
#devbar { position: fixed; top: 50%; right: 14px; transform: translateY(-50%); z-index: 30; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
#devbar button {
  font: inherit; font-size: 12px; font-weight: 700; padding: 4px 10px;
  background: rgba(20, 23, 31, 0.82); color: #ffd9a0;
  border: 1px solid rgba(255, 217, 160, 0.45); border-radius: 7px; cursor: pointer;
}
#devbar button:hover { background: rgba(40, 46, 60, 0.9); }

#prompt {
  position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%);
  background: rgba(14, 18, 26, 0.8); color: #ffe9a0;
  border: 2px solid rgba(255, 233, 160, 0.4); border-radius: 8px;
  padding: 7px 16px; font-size: 16px; font-weight: 700;
}

#radio {
  position: absolute; bottom: 18px; left: 18px; max-width: 460px;
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 10px;
  padding: 10px 14px; font-size: 16px; font-weight: 600;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45);
}
.radio-name {
  display: inline-block; font-weight: 900; font-size: 12px;
  padding: 2px 8px; border-radius: 6px; color: #fff; margin-right: 8px;
  letter-spacing: 0.08em;
}
.radio-name.mike { background: var(--mike); }
.radio-name.toby { background: var(--toby); }

#escape {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, 80vw); text-align: center;
}
.escape-label {
  color: #fff; font-size: 34px; font-weight: 900; letter-spacing: 0.06em;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.6); margin-bottom: 12px;
  animation: pulse 0.4s infinite;
}
.escape-track {
  height: 34px; background: rgba(10, 12, 18, 0.8);
  border: 3px solid #fff; border-radius: 10px; overflow: hidden;
}
#escape-fill {
  height: 100%; width: 6%;
  background: linear-gradient(90deg, #e04545, #f0a93c, #54c06c);
  transition: width 0.05s linear;
}
.escape-row {
  display: flex; justify-content: space-between; margin-top: 8px;
  color: #fff; font-weight: 800; font-size: 18px; text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
}

#debug {
  position: absolute; bottom: 64px; right: 14px;
  font: 11px/1.5 ui-monospace, Menlo, monospace;
  color: #9fe8a8; background: rgba(0,0,0,0.6); padding: 6px 8px; border-radius: 6px;
  max-width: 480px; text-align: right;
}

#help-btn {
  position: absolute; bottom: 64px; right: 14px;
  width: 38px; height: 38px; border-radius: 50%;
  font-family: inherit; font-size: 20px; font-weight: 900;
  background: rgba(14, 18, 26, 0.78); color: #f3f6fb;
  border: 2px solid rgba(255, 255, 255, 0.3); cursor: pointer;
  pointer-events: auto;
}
#help-btn:hover { background: rgba(34, 42, 58, 0.9); }
#help-panel {
  position: absolute; bottom: 112px; right: 14px; width: 330px;
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 12px;
  padding: 14px 16px; pointer-events: auto;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.4);
}
.help-title { font-weight: 900; letter-spacing: 0.16em; font-size: 13px; margin-bottom: 8px; }
.help-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 12px;
  font-size: 13px; font-weight: 600;
}
.help-grid span:nth-child(odd) { font-weight: 900; }
.help-tip { margin-top: 10px; font-size: 11.5px; font-weight: 600; color: #5a7890; }

#map-btn {
  position: absolute; bottom: 64px; right: 60px;
  width: 38px; height: 38px; border-radius: 50%;
  font-family: inherit; font-size: 17px;
  background: rgba(14, 18, 26, 0.78); color: #f3f6fb;
  border: 2px solid rgba(255, 255, 255, 0.3); cursor: pointer;
  pointer-events: auto;
}
#map-btn:hover { background: rgba(34, 42, 58, 0.9); }
#map-panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--paper); border: 4px solid var(--ink); border-radius: 14px;
  padding: 8px; pointer-events: auto;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.45);
}
#map-canvas { display: block; border-radius: 8px; }

/* ---------- overlays ---------- */
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 20; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(8, 10, 24, 0.9) 100%);
  transition: opacity 1s ease;
}
#whiteout {
  position: fixed; inset: 0; pointer-events: none; z-index: 30; opacity: 0;
  background: #f4f7fb;
}
#blackout {
  position: fixed; inset: 0; pointer-events: none; z-index: 30; opacity: 0;
  background: #06070d;
}

.sign {
  position: fixed; top: 42%; left: 50%; transform: translate(-50%, -50%) scale(2.6);
  z-index: 40; opacity: 0;
  font-size: clamp(54px, 11vw, 130px); font-weight: 900; letter-spacing: 0.04em;
  transition: transform 0.18s cubic-bezier(0.2, 2.2, 0.4, 1), opacity 0.12s ease;
}
.sign.slam { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.sign.white { color: #16181d; text-shadow: 0 4px 0 rgba(0,0,0,0.15); }
.sign.dark { color: #e8ecf6; text-shadow: 0 4px 0 rgba(0,0,0,0.6); }

/* ---------- menu & popups ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto; padding: 20px;
}
#menu { background: linear-gradient(180deg, rgba(174, 215, 242, 0.88), rgba(126, 178, 216, 0.94)); }
#popup { background: rgba(8, 10, 16, 0.45); }

.title-card, .popup-card {
  background: var(--paper); color: var(--ink);
  border: 4px solid var(--ink); border-radius: 14px;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.5);
  padding: 26px 30px; max-width: 880px; width: 100%;
  text-align: center;
}
.popup-card { max-width: 480px; transform: rotate(-0.6deg); }

.title { font-size: clamp(32px, 5.6vw, 58px); font-weight: 900; letter-spacing: 0.01em; margin: 2px 0 0; line-height: 1.02; }
.title-sub { display: block; color: #fff; background: var(--ink); border-radius: 10px; width: fit-content; margin: 8px auto 2px; padding: 2px 18px; font-size: clamp(18px, 2.6vw, 26px); letter-spacing: 0.18em; }
.tagline { font-size: 16.5px; font-weight: 600; color: #3c5871; margin: 10px 0 6px; line-height: 1.45; }
.legacy {
  display: inline-block; font-size: 13px; font-weight: 700; color: var(--ink);
  background: var(--accent); border-radius: 20px; padding: 4px 16px; margin: 6px 0 4px;
}

.menu-label { font-size: 12.5px; font-weight: 800; letter-spacing: 0.2em; color: #6d89a0; margin: 16px 0 8px; }

.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.row.disabled { opacity: 0.35; pointer-events: none; }

.card {
  background: #fff; border: 3px solid var(--ink); border-radius: 10px;
  padding: 10px 12px; min-width: 130px; max-width: 165px; cursor: pointer;
  font-family: inherit; color: var(--ink);
  display: flex; flex-direction: column; gap: 3px; align-items: center;
  transition: transform 0.08s ease;
}
.card:hover { transform: translateY(-3px); }
.card.sel { outline: 4px solid var(--toby); transform: translateY(-3px); }
.card .bars { font-size: 18px; letter-spacing: 0.1em; }
.card .name { font-weight: 900; font-size: 15px; }
.card .sub { font-size: 11.5px; font-weight: 600; color: #666; line-height: 1.25; }
.danger-card.d2 .bars { color: #d3b400; }
.danger-card.d3 .bars { color: #e8861f; }
.danger-card.d4 .bars { color: #d23f2f; }
.danger-card.d5 .bars { color: #7c1010; }

.start-btn {
  margin-top: 18px; font-family: inherit;
  font-size: 24px; font-weight: 900; letter-spacing: 0.06em;
  color: var(--accent-ink); background: var(--accent);
  border: 3px solid var(--ink); border-radius: 12px;
  padding: 12px 42px; cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.start-btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.start-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.controls-hint { margin-top: 14px; font-size: 12px; font-weight: 600; color: #6d89a0; }

.comics-btn {
  display: block; margin: 12px auto 0; font-family: inherit;
  font-size: 16px; font-weight: 900; letter-spacing: 0.04em;
  color: var(--ink); background: #fff;
  border: 3px solid var(--ink); border-radius: 12px;
  padding: 10px 26px; cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.comics-btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.comics-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.comics-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(12, 20, 34, 0.78);
  display: flex; align-items: center; justify-content: center;
}
.comics-panel {
  width: min(1060px, 92vw); max-height: 88vh; overflow-y: auto;
  background: #fdfaf4; border: 3px solid var(--ink); border-radius: 14px;
  box-shadow: 6px 6px 0 var(--ink); padding: 18px 22px 22px;
}
.comics-head { display: flex; align-items: center; justify-content: space-between; }
.comics-title { font-size: 26px; font-weight: 900; letter-spacing: 0.04em; }
.comics-close {
  font-family: inherit; font-size: 18px; font-weight: 900; line-height: 1;
  background: #fff; color: var(--ink); border: 2px solid var(--ink);
  border-radius: 10px; padding: 6px 10px; cursor: pointer; box-shadow: 2px 2px 0 var(--ink);
}
.comics-close:active { transform: translate(1px, 1px); box-shadow: 0 0 0 var(--ink); }
.comics-sub { font-size: 13.5px; font-weight: 600; color: #5c708a; margin: 6px 0 14px; }
.comics-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 14px;
}
.comic-card {
  display: block; text-decoration: none; color: var(--ink);
  border: 2px solid var(--ink); border-radius: 10px; overflow: hidden;
  background: #fff; box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.comic-card:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.comic-card img { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.comic-name { font-size: 11.5px; font-weight: 800; padding: 6px 8px; line-height: 1.25; }

.music-row { margin-top: 12px; display: flex; gap: 8px; justify-content: center; }
.music-btn {
  font-family: inherit; font-size: 13px; font-weight: 800;
  color: var(--ink); background: #fff;
  border: 2px solid var(--ink); border-radius: 20px;
  padding: 5px 14px; cursor: pointer; text-decoration: none;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.music-btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.music-btn:active { transform: translate(1px, 1px); box-shadow: 0 0 0 var(--ink); }

.popup-title { font-size: 44px; font-weight: 900; margin-bottom: 8px; }
.win-title { color: #2c8c46; font-size: 33px; line-height: 1.2; } /* CONGRATULATIONS must fit the 480px card */
.bail-title { color: #555; }
.popup-sub { font-size: 17px; font-weight: 700; color: #444; margin-bottom: 10px; }
.popup-stats { font-size: 16px; font-weight: 700; line-height: 1.7; margin: 10px 0; }
.popup-factoid {
  font-size: 14.5px; font-weight: 600; line-height: 1.5; color: #2c4458;
  background: #dff0fb; border: 2px dashed #8fbcd9; border-radius: 8px;
  padding: 10px 14px; margin: 12px 0;
}
.popup-meta { font-size: 11px; font-weight: 600; color: #999; margin-bottom: 12px; }

.btn-row { display: flex; gap: 10px; justify-content: center; }
.btn {
  font-family: inherit; font-size: 17px; font-weight: 900;
  background: #fff; color: var(--ink);
  border: 3px solid var(--ink); border-radius: 10px;
  padding: 9px 22px; cursor: pointer; box-shadow: 3px 3px 0 var(--ink);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
