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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a1430;
  color: #fff;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  user-select: none;
}

canvas#game {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.hidden { display: none !important; }

/* Overlays (start/gameover) */
.overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, rgba(20, 30, 80, 0.96) 0%, rgba(80, 20, 100, 0.96) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 20px;
  text-align: center;
}

.title {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 0 20px #ff4fd8, 0 0 40px #ff4fd8, 4px 4px 0 #2a0a3a;
  background: linear-gradient(90deg, #ffcf40, #ff4fd8, #4fd8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 12px;
}

.subtitle {
  font-size: 18px;
  opacity: 0.85;
  margin-bottom: 40px;
  font-style: italic;
}

.controls-panel {
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid #4fd8ff;
  border-radius: 12px;
  padding: 20px 30px;
  margin-bottom: 30px;
  box-shadow: 0 0 20px rgba(79, 216, 255, 0.4);
}

.controls-title {
  font-weight: bold;
  letter-spacing: 2px;
  color: #4fd8ff;
  margin-bottom: 12px;
  font-size: 14px;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 30px;
  text-align: left;
  font-size: 14px;
}

.controls-hint {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #4fd8ff55;
  font-size: 12px;
  color: #ffcf40;
  text-align: center;
  font-style: italic;
}

.key {
  display: inline-block;
  background: #1a2450;
  border: 1px solid #4fd8ff;
  border-radius: 4px;
  padding: 2px 8px;
  margin-right: 8px;
  min-width: 32px;
  text-align: center;
  font-family: monospace;
  font-weight: bold;
  color: #4fd8ff;
}

.btn {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 2px;
  padding: 16px 48px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, #ffcf40, #ff4fd8);
  color: #0a1430;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 6px 0 #2a0a3a, 0 0 20px #ff4fd8;
  margin: 6px;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #2a0a3a, 0 0 30px #ff4fd8; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #2a0a3a; }

.btn-reset {
  background: transparent;
  color: #aaa;
  border: 1px solid #555;
  box-shadow: none;
  font-size: 13px;
  padding: 8px 16px;
}
.btn-reset:hover { color: #fff; border-color: #fff; box-shadow: none; transform: none; }

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

.hud-top-left {
  position: absolute;
  top: 20px;
  left: 20px;
  min-width: 260px;
}

.character-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 2px 2px 0 #000;
  margin-bottom: 6px;
}
#character-icon { font-size: 32px; }

.hp-bar-outer {
  width: 240px;
  height: 18px;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #fff;
  border-radius: 10px;
  overflow: hidden;
}
.hp-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, #6cff5c, #ffcf40);
  transition: width 0.2s ease;
}
#hp-text {
  font-size: 12px;
  margin-top: 2px;
  text-shadow: 1px 1px 0 #000;
}

.hud-top-center {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 400px;
  max-width: 600px;
  text-align: center;
}

.mission-banner {
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid #ffcf40;
  border-radius: 8px;
  padding: 12px 20px;
  animation: pulse-glow 2s ease-in-out infinite alternate;
}
@keyframes pulse-glow {
  from { box-shadow: 0 0 10px #ffcf40; }
  to   { box-shadow: 0 0 25px #ffcf40; }
}
.mission-label {
  font-size: 11px;
  letter-spacing: 3px;
  color: #ffcf40;
  font-weight: bold;
}
#mission-text {
  font-size: 16px;
  margin-top: 4px;
  font-weight: bold;
}
#mission-progress {
  font-size: 14px;
  color: #6cff5c;
  margin-top: 4px;
  font-weight: bold;
}

.hud-top-right {
  position: absolute;
  top: 20px;
  right: 20px;
}

#minimap {
  width: 160px;
  height: 160px;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #fff;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.hud-bottom {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
}

.hint {
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid #4fd8ff;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 14px;
  letter-spacing: 1px;
  color: #4fd8ff;
  animation: hint-bob 1.2s ease-in-out infinite alternate;
}
@keyframes hint-bob {
  from { transform: translateY(0); }
  to   { transform: translateY(-4px); }
}

.waypoint-arrow {
  position: absolute;
  font-size: 48px;
  color: #ffcf40;
  text-shadow: 0 0 12px #ffcf40, 2px 2px 0 #000;
  pointer-events: none;
  transition: opacity 0.2s;
  transform-origin: center;
}

.toast {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.85);
  border: 3px solid #ffcf40;
  border-radius: 16px;
  padding: 30px 60px;
  text-align: center;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #ffcf40;
  text-shadow: 0 0 20px #ffcf40;
  animation: toast-pop 0.5s ease-out;
  max-width: 80%;
}
.toast.radio {
  background: rgba(10, 20, 48, 0.95);
  border-color: #4fd8ff;
  color: #fff;
  font-size: 18px;
  letter-spacing: 1px;
  font-weight: normal;
  text-shadow: none;
  text-align: left;
  padding: 20px 30px;
}
.toast .radio-speaker {
  color: #4fd8ff;
  font-weight: bold;
  letter-spacing: 2px;
  font-size: 12px;
  margin-bottom: 6px;
  display: block;
}
@keyframes toast-pop {
  0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  60%  { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Points */
.points-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #ffcf40;
  border-radius: 8px;
  padding: 4px 12px;
  font-family: 'Bangers', 'Press Start 2P', sans-serif;
  letter-spacing: 2px;
}
.points-label {
  font-size: 13px;
  color: #ffcf40;
}
#points-value {
  font-size: 22px;
  color: #fff;
  min-width: 30px;
  text-align: right;
}

.points-popups {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.points-popup {
  position: absolute;
  font-family: 'Bangers', cursive;
  font-size: 36px;
  color: #ffcf40;
  text-shadow: 3px 3px 0 #000, 0 0 20px #ffcf40;
  letter-spacing: 2px;
  animation: points-rise 1.1s ease-out forwards;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}
@keyframes points-rise {
  0%   { opacity: 0; transform: translate(-50%, -20%) scale(0.5); }
  20%  { opacity: 1; transform: translate(-50%, -60%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(1); }
}

/* Chapter banner — book-like title card */
.chapter-banner {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 90;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.55) 60%, transparent 100%);
  animation: chapter-fade 4s ease-in-out forwards;
}
@keyframes chapter-fade {
  0%    { opacity: 0; }
  15%   { opacity: 1; }
  75%   { opacity: 1; }
  100%  { opacity: 0; }
}
.chapter-number {
  font-family: 'Bangers', cursive;
  font-size: 52px;
  letter-spacing: 8px;
  color: #ffcf40;
  text-shadow: 4px 4px 0 #2a0a3a, 0 0 30px #ff4fd8;
  margin-bottom: 12px;
  animation: chapter-number-in 1s ease-out;
}
@keyframes chapter-number-in {
  0%   { transform: translateY(-40px) scale(0.5); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.chapter-title {
  font-family: 'Bangers', cursive;
  font-size: 88px;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 5px 5px 0 #000, 8px 8px 0 #ff4fd8;
  text-align: center;
  max-width: 90vw;
  animation: chapter-title-in 1.2s ease-out;
  transform-origin: center;
}
@keyframes chapter-title-in {
  0%   { transform: scale(0.3) rotate(-15deg); opacity: 0; }
  70%  { transform: scale(1.1) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Comic-book overlay */
.comic-overlay {
  position: fixed;
  inset: 0;
  background: #fdf6e3;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  overflow-y: auto;
  padding: 20px;
}
.comic-page {
  background: #fff9ec;
  border: 4px solid #111;
  border-radius: 4px;
  box-shadow: 8px 8px 0 #111, 0 0 40px rgba(0,0,0,0.2);
  padding: 30px 36px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
}
.comic-title {
  font-family: 'Bangers', cursive;
  font-size: 56px;
  letter-spacing: 4px;
  color: #cc2a44;
  text-shadow: 3px 3px 0 #111;
  margin-bottom: 20px;
  line-height: 1;
}
.comic-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.comic-panel {
  background: #fff;
  border: 3px solid #111;
  padding: 10px;
  position: relative;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.comic-panel svg {
  width: 100%;
  height: 180px;
  display: block;
}
.comic-panel-caption {
  font-family: 'Bangers', cursive;
  font-size: 20px;
  letter-spacing: 1px;
  color: #111;
  margin-top: 8px;
  text-align: center;
  line-height: 1.1;
}
.comic-panel-speech {
  position: absolute;
  background: #fff;
  border: 2px solid #111;
  border-radius: 20px;
  padding: 6px 14px;
  font-family: 'Bangers', cursive;
  font-size: 18px;
  color: #111;
  letter-spacing: 1px;
  top: 8px;
  right: 12px;
  max-width: 60%;
  z-index: 2;
}
.comic-panel-speech::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 20px;
  border: 6px solid transparent;
  border-top-color: #111;
}
.comic-next-btn {
  margin-top: 10px;
  background: linear-gradient(135deg, #ffcf40, #ff4fd8);
  font-family: 'Bangers', cursive;
  font-size: 24px;
  letter-spacing: 3px;
}

/* THE END screen */
.end-page { max-width: 720px; }
.the-end-text {
  font-family: 'Bangers', cursive;
  font-size: 140px;
  letter-spacing: 10px;
  color: #cc2a44;
  text-shadow: 6px 6px 0 #111, 10px 10px 0 #ffcf40;
  line-height: 1;
  margin: 20px 0 10px;
  animation: end-in 1.5s ease-out;
}
@keyframes end-in {
  0%   { transform: scale(0) rotate(-25deg); opacity: 0; }
  60%  { transform: scale(1.2) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.end-subtitle {
  font-family: 'Bangers', cursive;
  font-size: 28px;
  color: #111;
  letter-spacing: 3px;
  margin-bottom: 24px;
}
.end-credits {
  font-family: 'Bangers', cursive;
  font-size: 20px;
  color: #333;
  line-height: 1.6;
  letter-spacing: 1px;
  margin: 20px 0;
}
.end-credits .credit-row {
  margin: 4px 0;
}
.end-credits .credit-role {
  color: #cc2a44;
  font-size: 14px;
  letter-spacing: 2px;
}

/* Screen flash (explosion) */
.screen-flash {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 150;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.screen-flash.active {
  opacity: 1;
}
.screen-flash.fade-out {
  transition: opacity 2s ease;
  opacity: 0;
}

/* Shop */
.shop-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 520px;
  max-width: 92vw;
  background: #fff9ec;
  border: 4px solid #111;
  border-radius: 4px;
  box-shadow: 10px 10px 0 #111, 0 0 40px rgba(0,0,0,0.3);
  padding: 24px;
  z-index: 180;
  pointer-events: auto;
  font-family: 'Bangers', 'Segoe UI', sans-serif;
}
.shop-header {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 3px solid #111;
  padding-bottom: 10px;
  margin-bottom: 14px;
}
.shop-emoji { font-size: 32px; }
.shop-title {
  flex: 1;
  font-family: 'Bangers', cursive;
  font-size: 28px;
  letter-spacing: 2px;
  color: #111;
}
.shop-close {
  background: none;
  border: 2px solid #111;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  font-weight: bold;
  color: #111;
}
.shop-close:hover { background: #ff4f4f; color: #fff; }
.shop-points {
  font-family: 'Bangers', cursive;
  font-size: 22px;
  letter-spacing: 2px;
  color: #cc2a44;
  text-align: right;
  margin-bottom: 12px;
}
#shop-points {
  color: #ffcf40;
  background: #111;
  padding: 2px 10px;
  border-radius: 6px;
  min-width: 40px;
  display: inline-block;
  text-align: center;
}
.shop-items {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.shop-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 2px solid #111;
  padding: 10px 14px;
  transition: transform 0.1s, box-shadow 0.1s;
  cursor: pointer;
}
.shop-item:hover:not(.locked) {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 #111;
}
.shop-item.locked {
  opacity: 0.55;
  cursor: not-allowed;
}
.shop-item-emoji { font-size: 32px; }
.shop-item-info { flex: 1; text-align: left; }
.shop-item-name {
  font-family: 'Bangers', cursive;
  font-size: 20px;
  letter-spacing: 1px;
  color: #111;
}
.shop-item-desc {
  font-size: 12px;
  color: #555;
  font-family: 'Segoe UI', sans-serif;
}
.shop-item-price {
  font-family: 'Bangers', cursive;
  font-size: 24px;
  color: #cc2a44;
  background: #ffcf40;
  border: 2px solid #111;
  padding: 2px 10px;
  border-radius: 6px;
  min-width: 60px;
  text-align: center;
}
.shop-hint {
  margin-top: 14px;
  text-align: center;
  font-size: 12px;
  color: #555;
  font-family: 'Segoe UI', sans-serif;
}

/* Sniff mode overlay — subtle sepia tint to signal "sniff" active */
body.sniff-mode::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(255, 200, 60, 0.15) 70%, rgba(120, 70, 0, 0.25) 100%);
  animation: sniff-pulse 1.2s ease-in-out infinite alternate;
}
@keyframes sniff-pulse {
  from { opacity: 0.6; }
  to   { opacity: 1.0; }
}
body.sniff-mode::after {
  content: '🐾 SNIFF MODE';
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 55;
  background: rgba(0, 0, 0, 0.75);
  color: #ffcf40;
  font-family: 'Bangers', cursive;
  font-size: 22px;
  letter-spacing: 3px;
  padding: 6px 16px;
  border: 2px solid #ffcf40;
  border-radius: 8px;
  pointer-events: none;
}

/* Damage flash */
#hud.hurt-flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 0, 0, 0.5) 100%);
  pointer-events: none;
  animation: hurt-fade 0.4s ease-out;
}
@keyframes hurt-fade {
  from { opacity: 1; }
  to   { opacity: 0; }
}
