/* ==========================================================================
   Hazard Patrol — Stylesheet
   Mobile-first, clean visual language for a professional safety-campaign
   audience. No external fonts/images — everything here is system fonts +
   CSS/canvas shapes so the game stays fully self-contained.
   ========================================================================== */

:root {
  --bg: #12141a;
  --panel: #1b1f29;
  --panel-border: #333a4a;
  --text: #e8eaed;
  --text-dim: #9aa1b2;

  --blue: #4285F4;
  --red: #EA4335;
  --yellow: #FBBC05;
  --green: #34A853;

  --font: "Consolas", "Courier New", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  height: 100%;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 8px;
  gap: 6px;
}

/* ---------------- HUD ---------------- */
#hud {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 6px;
  padding: 8px 10px;
  gap: 8px;
  flex-wrap: nowrap;
}

.hud-brand {
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--yellow);
  font-size: 13px;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
  white-space: nowrap;
}

.hud-stats {
  display: flex;
  gap: 12px;
  flex-wrap: nowrap;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 44px;
}

.hud-label {
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.hud-value {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.hud-sep { color: var(--text-dim); font-size: 13px; font-weight: 400; }

#hudTime { color: var(--green); }
#hudScore { color: var(--yellow); }
#hudFound, #hudTotal { color: var(--blue); }

@media (max-width: 430px) {
  .restart-label { display: none; }
  .hud-brand { font-size: 11px; letter-spacing: 1px; }
}

#restartBtn {
  background: var(--panel);
  color: var(--text-dim);
  border: 2px solid var(--panel-border);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
}
#restartBtn:hover { color: var(--text); border-color: var(--blue); }

/* ---------------- STAGE ---------------- */
#stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 480 / 760;
  background: #000;
  border: 3px solid var(--panel-border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  touch-action: none;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
}

/* ---------------- TOUCH CONTROLS ---------------- */
.touch-controls {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 4;
}
body.touch-mode .touch-controls { display: block; }

.dpad {
  position: absolute;
  left: 14px;
  bottom: 14px;
  width: 128px;
  height: 128px;
}

.dpad-btn {
  position: absolute;
  width: 44px;
  height: 44px;
  background: rgba(20, 22, 28, 0.55);
  border: 2px solid rgba(232,234,237,0.35);
  border-radius: 8px;
  color: #e8eaed;
  font-size: 16px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}
.dpad-btn:active { background: rgba(66,133,244,0.55); border-color: var(--blue); }

.dpad-up { left: 42px; top: 0; }
.dpad-down { left: 42px; top: 84px; }
.dpad-left { left: 0; top: 42px; }
.dpad-right { left: 84px; top: 42px; }

.inspect-btn {
  position: absolute;
  right: 18px;
  bottom: 26px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: rgba(251, 188, 5, 0.75);
  border: 2px solid rgba(26,26,26,0.6);
  color: #1a1a1a;
  font-family: var(--font);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.5px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.inspect-btn:active { background: rgba(251, 188, 5, 0.95); }

#promptBubble {
  position: absolute;
  transform: translate(-50%, -100%);
  background: var(--yellow);
  color: #1a1a1a;
  font-weight: 700;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 2px solid #1a1a1a;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
}

#toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 4px;
  border: 2px solid #7a1c14;
  z-index: 6;
  pointer-events: none;
}

.hidden { display: none !important; }

/* ---------------- OVERLAYS / CARDS ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 9, 12, 0.78);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
  overflow: hidden;
}

/* Soft glowing color blobs drifting behind the card — decorative only */
.aurora {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.38;
}
.blob-blue {
  width: 220px; height: 220px;
  background: var(--blue);
  top: -60px; left: -50px;
  animation: blobDriftA 10s ease-in-out infinite alternate;
}
.blob-green {
  width: 190px; height: 190px;
  background: var(--green);
  bottom: -70px; right: -50px;
  animation: blobDriftB 12s ease-in-out infinite alternate;
}
@keyframes blobDriftA { from { transform: translate(0,0); } to { transform: translate(30px, 24px); } }
@keyframes blobDriftB { from { transform: translate(0,0); } to { transform: translate(-26px, -28px); } }

/* Slow-rising particles — a little "data flowing through the floor" flourish */
.particles {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.particle {
  position: absolute;
  bottom: -10px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--blue);
  opacity: 0;
  animation: floatUp 7s linear infinite;
}
.particle:nth-child(3n+1) { background: var(--green); width: 3px; height: 3px; }
.particle:nth-child(3n+2) { background: var(--yellow); width: 5px; height: 5px; }
@keyframes floatUp {
  0% { transform: translateY(0); opacity: 0; }
  12% { opacity: 0.75; }
  88% { opacity: 0.4; }
  100% { transform: translateY(-90vh); opacity: 0; }
}

.card {
  position: relative;
  z-index: 1;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 10px;
  padding: 16px 20px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  max-height: 96%;
  overflow-y: auto;
  animation: cardIn 0.45s ease-out;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.card.wide { max-width: 640px; }

.hero-badge {
  display: flex;
  justify-content: center;
  margin-bottom: 2px;
}
.hero-badge svg {
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 0 14px rgba(66,133,244,0.5));
  animation: heroFloat 3.6s ease-in-out infinite;
}
@keyframes heroFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.kicker {
  text-align: center;
  margin: 0 0 4px 0;
  font-size: 10.5px;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.card h1 {
  margin: 0 0 2px 0;
  text-align: center;
  font-size: 27px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #8ab4ff, var(--yellow));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 0 0 8px 0;
  text-align: center;
  color: var(--blue);
  font-size: 15px;
  letter-spacing: 1px;
}

.lead {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  margin: 0 0 10px 0;
  text-align: center;
}
.lead.small { font-size: 12px; color: var(--text-dim); }

/* ---------------- ZONE STRIP (compact icon row) ---------------- */
.mini-label {
  margin: 0 0 5px 0;
  text-align: center;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.zone-strip {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 0 0 10px 0;
  flex-wrap: wrap;
}

.zone-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  flex: 0 0 auto;
}
.zone-icon svg { width: 13px; height: 13px; }
.zone-icon-rack { background: rgba(66,133,244,0.18); color: var(--blue); }
.zone-icon-load { background: rgba(251,188,5,0.18); color: var(--yellow); }
.zone-icon-maint { background: rgba(180,139,224,0.18); color: #b48be0; }
.zone-icon-chem { background: rgba(52,168,83,0.18); color: var(--green); }
.zone-icon-path { background: rgba(234,67,53,0.18); color: var(--red); }

/* ---------------- CHARACTER SELECT ---------------- */
.char-select { margin: 0 0 10px 0; }

.char-options {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.char-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 72px;
  background: #20242e;
  border: 2px solid var(--panel-border);
  border-radius: 8px;
  padding: 6px 4px 5px 4px;
  cursor: pointer;
  color: var(--text-dim);
  font-family: var(--font);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.char-btn svg { width: 26px; height: 36px; }
.char-btn span { font-size: 10px; letter-spacing: 0.5px; }
.char-btn:hover { border-color: #4a5266; transform: translateY(-1px); }
.char-btn.selected {
  border-color: var(--blue);
  background: rgba(66,133,244,0.14);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(66,133,244,0.4), 0 4px 12px rgba(66,133,244,0.25);
}

kbd {
  background: #2a2f3d;
  border: 1px solid var(--panel-border);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font);
  font-size: 11px;
  color: var(--text);
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
  background: linear-gradient(135deg, var(--blue), #2a5fd6);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 13px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(66,133,244,0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #5b95f5, var(--blue));
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(66,133,244,0.5);
}
.btn-primary:active { transform: translateY(0); }
.btn-icon { font-size: 11px; }

/* ---------------- HAZARD MODAL ---------------- */
.hz-zone {
  margin: 0;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-transform: uppercase;
}

#hzTitle {
  margin: 2px 0 10px 0;
  font-size: 20px;
  color: var(--yellow);
}

#hzScenario {
  font-size: 13.5px;
  line-height: 1.5;
  margin: 0 0 14px 0;
}

.hz-question {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--blue);
  margin: 0 0 8px 0;
}

.hz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hz-option-btn {
  text-align: left;
  background: #242a37;
  border: 2px solid var(--panel-border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 5px;
  font-family: var(--font);
  font-size: 12.5px;
  line-height: 1.4;
  cursor: pointer;
  min-height: 44px;
}
.hz-option-btn:hover { border-color: var(--blue); background: #2a3140; }
.hz-option-btn:disabled { cursor: default; opacity: 0.55; }

.hz-option-btn.chosen-correct { border-color: var(--green); background: #1d3327; }
.hz-option-btn.chosen-partial { border-color: var(--yellow); background: #332f1d; }
.hz-option-btn.chosen-wrong { border-color: var(--red); background: #33201d; }

.hz-feedback { margin-top: 14px; border-top: 1px dashed var(--panel-border); padding-top: 12px; }
#hzFeedbackText { font-size: 13px; line-height: 1.5; }
.hz-category { font-size: 11.5px; color: var(--text-dim); font-style: italic; }
#hzPoints { font-size: 13px; font-weight: 700; color: var(--yellow); }

/* ---------------- END SCREEN ---------------- */
.rating {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--green);
  margin-top: 0;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}
@media (max-width: 560px) {
  .results-grid { grid-template-columns: 1fr; }
}

.result-box {
  background: #20242e;
  border: 1px solid var(--panel-border);
  border-top: 3px solid var(--panel-border);
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.results-grid .result-box:nth-child(1) { border-top-color: var(--yellow); }
.results-grid .result-box:nth-child(2) { border-top-color: var(--blue); }
.results-grid .result-box:nth-child(3) { border-top-color: var(--green); }
.result-label { font-size: 10.5px; color: var(--text-dim); letter-spacing: 0.5px; }
.result-value { font-size: 17px; font-weight: 700; color: var(--yellow); }

/* ---------------- FOOTER ---------------- */
#controlsBar {
  width: 100%;
  max-width: 480px;
  text-align: center;
  font-size: 10.5px;
  color: var(--text-dim);
  padding: 4px 4px 0 4px;
}
body.touch-mode #controlsBar { display: none; }

/* ---------------- SUCCESS (all hazards found) ---------------- */
#endScreen.success .card {
  border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(52,168,83,0.4), 0 10px 30px rgba(0,0,0,0.5);
}
#endScreen.success #endHeadline {
  color: var(--green);
}
