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

body {
  background: #0a0a0a;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  font-family: 'Press Start 2P', monospace;
}

#wrapper {
  position: relative;
  display: inline-block;
  line-height: 0;
}

#gameCanvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── SCREENS ─────────────────────────────────────── */
.screen {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  z-index: 10;
  pointer-events: none;
}
.screen.active { display: flex; pointer-events: auto; }

/* ── START SCREEN ────────────────────────────────── */
.game-title {
  font-size: clamp(10px, 3.5vw, 22px);
  color: #f7e96b;
  text-align: center;
  text-shadow: 3px 3px 0 #8B5E00, -1px -1px 0 #8B5E00;
  line-height: 1.4;
  margin-bottom: 6px;
}

.subtitle {
  font-size: clamp(5px, 1.2vw, 8px);
  color: #aee571;
  margin-bottom: 14px;
}

.choose-label {
  font-size: clamp(5px, 1.4vw, 9px);
  color: #ccc;
  margin-bottom: 10px;
  letter-spacing: 2px;
}

.char-select-row {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
}

.char-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 12px;
  border: 3px solid #555;
  cursor: pointer;
  background: rgba(0,0,0,0.55);
  transition: border-color 0.1s, background 0.1s;
  box-shadow: 4px 4px 0 #222;
  min-width: 90px;
}
.char-card:hover  { border-color: #f7e96b; background: rgba(247,233,107,0.1); }
.char-card.selected { border-color: #4a76ee; background: rgba(74,118,238,0.15);
  box-shadow: 4px 4px 0 #1a3a80; }

.portrait-canvas {
  image-rendering: pixelated;
  margin-bottom: 6px;
}

.char-name   { font-size: clamp(5px, 1.5vw, 9px);  color: #fff; margin-bottom: 3px; }
.char-breed  { font-size: clamp(4px, 1vw, 6px);    color: #aaa; margin-bottom: 5px; }
.char-ability{ font-size: clamp(4px, 1vw, 6px);    color: #4a76ee; }

.pixel-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(6px, 1.5vw, 9px);
  color: #000;
  background: #f7e96b;
  border: none;
  padding: 10px 18px;
  cursor: pointer;
  box-shadow: 4px 4px 0 #8B5E00;
  transition: transform 0.05s, box-shadow 0.05s;
  margin-bottom: 10px;
}
.pixel-btn:hover:not(:disabled) { transform: translate(-2px,-2px); box-shadow: 6px 6px 0 #8B5E00; }
.pixel-btn:active:not(:disabled){ transform: translate(2px,2px);  box-shadow: 2px 2px 0 #8B5E00; }
.pixel-btn:disabled { background: #555; color: #888; cursor: default; box-shadow: 4px 4px 0 #333; }

.pixel-btn-secondary {
  background: #4a76ee;
  color: #fff;
  box-shadow: 4px 4px 0 #1a3a80;
}
.pixel-btn-secondary:hover { box-shadow: 6px 6px 0 #1a3a80; }

.controls-hint {
  font-size: clamp(4px, 1vw, 6px);
  color: #666;
  text-align: center;
}

/* ── HUD ─────────────────────────────────────────── */
#gameScreen { pointer-events: none; }

#hud-topleft {
  position: absolute;
  top: 6px; left: 8px;
  font-size: clamp(6px, 1.8vw, 10px);
  color: #ff5555;
  line-height: 1.6;
}

#hud-topright {
  position: absolute;
  top: 6px; right: 8px;
  text-align: right;
  font-size: clamp(5px, 1.4vw, 8px);
  color: #fff;
  line-height: 1.8;
}

#hud-bottomleft {
  position: absolute;
  bottom: 8px; left: 8px;
  font-size: clamp(5px, 1.2vw, 7px);
  color: #f7e96b;
}

#speedup-flash {
  position: absolute;
  top: 30%;
  font-size: clamp(8px, 2.5vw, 14px);
  color: #ff5555;
  text-shadow: 2px 2px 0 #800;
  animation: flashAnim 0.8s ease-out forwards;
}
#speedup-flash.hidden { display: none; }

@keyframes flashAnim {
  0%   { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(1.0); }
}

/* ── GAME OVER SCREEN ────────────────────────────── */
.over-title {
  font-size: clamp(12px, 4vw, 24px);
  color: #ff5555;
  text-shadow: 3px 3px 0 #800;
  margin-bottom: 12px;
}

.new-high {
  font-size: clamp(6px, 1.8vw, 10px);
  color: #f7e96b;
  margin-bottom: 8px;
  animation: blink 0.5s step-end infinite;
}
.new-high.hidden { display: none; }

@keyframes blink { 50% { opacity: 0; } }

.over-label {
  font-size: clamp(5px, 1.2vw, 7px);
  color: #aaa;
  margin-bottom: 2px;
}

.over-score {
  font-size: clamp(10px, 2.5vw, 16px);
  color: #fff;
  margin-bottom: 10px;
}

.over-buttons {
  display: flex;
  gap: 12px;
  margin-top: 6px;
}

/* ── BACK LINK ───────────────────────────────────── */
#back-link {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(5px, 1vw, 7px);
  color: #555;
  text-decoration: none;
  margin-top: 8px;
}
#back-link:hover { color: #aaa; }
