* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', 'Poppins', Roboto, Arial, sans-serif;
  background: #0e1a12;
  color: #f2f7ef;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  cursor: default;
}

.hidden { display: none !important; }

/* Crosshair */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border: 2px solid rgba(255,255,255,0.85);
  border-radius: 50%;
  pointer-events: none;
  z-index: 20;
  mix-blend-mode: difference;
}

/* Action prompt */
#prompt {
  position: fixed;
  bottom: 14%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 30, 20, 0.75);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  z-index: 15;
  backdrop-filter: blur(6px);
  transition: opacity 0.15s ease;
}
#prompt.urgent {
  background: rgba(160, 40, 40, 0.85);
  animation: pulse 0.9s infinite;
}
@keyframes pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.05); }
}

/* Toasts */
#toasts {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 30;
  align-items: center;
  pointer-events: none;
  max-width: min(90vw, 520px);
}
.toast {
  background: rgba(15, 25, 18, 0.88);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13.5px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  text-align: center;
  backdrop-filter: blur(6px);
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* HUD */
#hud {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 15;
}
.panel {
  background: rgba(14, 26, 18, 0.72);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 14px 16px;
  min-width: 230px;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  margin-top: 8px;
}
.stat-row:first-child { margin-top: 0; }
.stat-label { opacity: 0.9; }
.stat-value { font-weight: 700; }
.bar {
  height: 7px;
  border-radius: 5px;
  background: rgba(255,255,255,0.12);
  overflow: hidden;
  margin-top: 4px;
}
.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 5px;
  transition: width 0.3s ease;
}
.bar-fill.forest { background: linear-gradient(90deg,#4f9d3f,#1f6b2c); }
.bar-fill.bio { background: linear-gradient(90deg,#e0b34b,#c97a2b); }
.bar-fill.water { background: linear-gradient(90deg,#4fb4e0,#1f6fa8); }
.mini-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-top: 10px;
  opacity: 0.9;
}
.mini-stats strong { color: #d9f2c9; }
.manual-hint {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 11px;
  text-align: center;
  opacity: 0.65;
}
.manual-hint kbd { font-size: 10.5px; padding: 1px 6px; }

/* Minimap */
#minimap-wrap {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 15;
  padding: 6px;
  background: rgba(14, 26, 18, 0.72);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
}
#minimap {
  display: block;
  width: 132px;
  height: 132px;
  border-radius: 8px;
}

/* Logger speech bubbles */
#logger-chat-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 18;
}
.chat-bubble {
  position: absolute;
  left: 0;
  top: 0;
  max-width: 170px;
  background: rgba(255, 252, 240, 0.96);
  color: #241c10;
  padding: 7px 12px;
  border-radius: 14px;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  opacity: 0;
  scale: 0.85;
  transition: opacity 0.18s ease, scale 0.18s ease;
  will-change: transform;
}
.chat-bubble.visible {
  opacity: 1;
  scale: 1;
}
.chat-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: rgba(255, 252, 240, 0.96);
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10,20,12,0.75), rgba(4,10,6,0.95));
  backdrop-filter: blur(3px);
}
.card {
  max-width: 560px;
  width: 92%;
  background: rgba(18, 30, 20, 0.92);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  padding: 34px 36px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.card h1 { margin: 0 0 4px; font-size: 30px; }
.card h2 { margin: 0 0 8px; }
.subtitle {
  margin: 0 0 16px;
  color: #a7e08a;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.desc { font-size: 14px; line-height: 1.6; opacity: 0.92; margin-bottom: 18px; }
.goal {
  font-size: 13.5px;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 20px;
}
.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  text-align: left;
  font-size: 13.5px;
  margin: 18px auto;
  max-width: 380px;
}
kbd {
  display: inline-block;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 5px;
  padding: 2px 7px;
  margin-right: 3px;
  font-size: 12px;
  font-family: inherit;
}
button {
  background: linear-gradient(135deg,#4f9d3f,#2c6e2f);
  color: white;
  border: none;
  padding: 13px 28px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 8px 20px rgba(47,120,50,0.4);
}
button:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(47,120,50,0.5); }
button:active { transform: translateY(0); }

.button-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn-secondary {
  background: rgba(255,255,255,0.1);
  box-shadow: none;
  border: 1px solid rgba(255,255,255,0.2);
}
.btn-secondary:hover { box-shadow: 0 8px 20px rgba(0,0,0,0.3); }

/* Level select */
.level-select-card { max-width: 640px; }
.level-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 20px 0;
}
.level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 14px;
  padding: 16px 10px;
  color: inherit;
  font-family: inherit;
  text-align: center;
  box-shadow: none;
}
.level-card:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(0,0,0,0.35); }
.level-card:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(255,255,255,0.03);
}
.level-card-num {
  font-size: 20px;
  font-weight: 800;
  color: #a7e08a;
}
.level-card:disabled .level-card-num { color: #d9c98a; }
.level-card-name { font-size: 14px; font-weight: 700; }
.level-card-tagline { font-size: 11.5px; opacity: 0.8; line-height: 1.4; }
.level-card-best {
  font-size: 11px;
  font-weight: 700;
  color: #a7e08a;
  margin-top: 2px;
}

#level-confirm h2 { margin-bottom: 4px; }
#level-confirm .goal { margin-top: 4px; }

@media (max-width: 520px) {
  .level-grid { grid-template-columns: 1fr; }
}

#manual-screen, #skills-screen, #leaderboard-screen, #settings-screen { z-index: 50; }
.manual-card {
  max-width: 680px;
  text-align: left;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}
.manual-card h1, .manual-card .subtitle { text-align: center; }
.manual-body {
  overflow-y: auto;
  padding-right: 6px;
  margin-bottom: 20px;
}
.manual-body section { margin-bottom: 18px; }
.manual-body h3 {
  margin: 0 0 6px;
  font-size: 15px;
  color: #a7e08a;
}
.manual-body p, .manual-body li {
  font-size: 13.5px;
  line-height: 1.6;
  opacity: 0.94;
}
.manual-body ul { margin: 6px 0 0; padding-left: 20px; }
.manual-table { border-collapse: collapse; width: 100%; }
.manual-table td {
  padding: 5px 8px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.manual-table td:first-child { white-space: nowrap; width: 1%; }
.manual-card > button { align-self: center; }

.final-stats {
  text-align: left;
  font-size: 14px;
  line-height: 1.9;
  background: rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 18px;
}
.final-stats strong { color: #d9f2c9; }

@media (max-width: 520px) {
  .controls-grid { grid-template-columns: 1fr; }
  .card { padding: 24px 20px; }
}

/* Ranger skills */
.skill-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.skill-info { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.skill-name { font-size: 14px; font-weight: 700; }
.skill-level { font-size: 11.5px; font-weight: 600; color: #a7e08a; margin-left: 4px; }
.skill-desc { font-size: 12.5px; opacity: 0.85; }
.skill-btn { white-space: nowrap; padding: 9px 16px; font-size: 13px; }
.skill-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* Leaderboard */
.leaderboard-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 13.5px;
}
.leaderboard-name-row input {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  padding: 6px 10px;
  color: inherit;
  font-family: inherit;
  font-size: 13px;
}
.leaderboard-section { margin-bottom: 16px; }
.leaderboard-section h4 { margin: 0 0 6px; font-size: 13.5px; color: #a7e08a; }
.leaderboard-table td:first-child { width: 10%; }
.leaderboard-empty { font-size: 13.5px; opacity: 0.8; }
.leaderboard-import-text {
  width: 100%;
  min-height: 64px;
  margin: 4px 0 0;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  padding: 10px;
  color: inherit;
  font-family: inherit;
  font-size: 12.5px;
  resize: vertical;
}
.leaderboard-import-msg { font-size: 12.5px; min-height: 1.4em; opacity: 0.9; color: #a7e08a; }

/* Settings */
.settings-row { text-align: left; font-size: 14px; margin: 14px 0; }
.settings-row label { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.settings-row input[type="checkbox"] { width: 18px; height: 18px; }

/* Accessibility: high-contrast HUD - stronger borders/opacity and bolder
   text on the HUD panel and overlay cards, on top of whatever color mode
   (default or colorblind-safe) is active. */
.high-contrast-mode .panel,
.high-contrast-mode #minimap-wrap {
  background: rgba(6, 14, 8, 0.94);
  border-color: rgba(255,255,255,0.4);
}
.high-contrast-mode .stat-value,
.high-contrast-mode .mini-stats strong {
  color: #ffffff;
  font-weight: 800;
}
.high-contrast-mode .bar { background: rgba(255,255,255,0.28); }
.high-contrast-mode #prompt {
  background: rgba(0,0,0,0.92);
  border-color: rgba(255,255,255,0.5);
  font-weight: 800;
}
.high-contrast-mode .card {
  background: rgba(4, 10, 6, 0.98);
  border-color: rgba(255,255,255,0.35);
}
