/*
 * This is a manifest file that'll be compiled into application.css.
 */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* ── Reset ──────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0a0a12;
}

/* ── Shared typography ──────────────────────────────────────── */

.pixel { font-family: 'Press Start 2P', monospace; }

/* ── Shared components ──────────────────────────────────────── */

/* Pokémon-style bordered box */
.poke-box {
  background: #f0edd8;
  border: 3px solid #222;
  border-radius: 6px;
  font-family: 'Press Start 2P', monospace;
  color: #111;
}

/* Shared button */
.pixel-btn {
  display: block;
  width: 100%;
  padding: 1rem;
  background: #f0edd8;
  border: 3px solid #222;
  border-radius: 6px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #111;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.08s, color 0.08s;
  letter-spacing: 0.05em;
}

.pixel-btn:hover,
.pixel-btn:focus {
  background: #222;
  color: #f0edd8;
  outline: none;
}

.pixel-btn:active { transform: scale(0.98); }

.pixel-btn-outline {
  background: transparent;
  color: #888;
  border-color: #444;
}

.pixel-btn-outline:hover {
  background: #333;
  color: #f0edd8;
  border-color: #333;
}

/* ═══════════════════════════════════════════════════════════════
   TITLE / START / OVER / LEADERBOARD PAGES
   ═══════════════════════════════════════════════════════════════ */

.title-page {
  min-height: 100vh;
  background: #0a0a12;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1.25rem 2.5rem;
  gap: 1.25rem;
}

/* ── Title header ───────────────────────────────────────────── */

.title-header {
  text-align: center;
  margin-top: 0.5rem;
}

.game-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1.3rem, 5vw, 2rem);
  color: #f5e642;
  text-shadow: 3px 3px 0 #a89a00, 6px 6px 0 rgba(0,0,0,0.4);
  letter-spacing: 0.04em;
  line-height: 1.4;
  margin: 0 0 0.5rem;
}

.small-title { font-size: clamp(1rem, 4vw, 1.5rem); }

.game-subtitle {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #64748b;
  letter-spacing: 0.15em;
  margin: 0;
}

/* ── Title mascots ──────────────────────────────────────────── */

.title-mascots {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 360px;
}

.mascot-left,
.mascot-right { flex: 1; }

.mascot-left svg,
.mascot-right svg { width: 100%; height: auto; max-height: 120px; }

.mascot-flip { transform: scaleX(-1); }

.mascot-vs {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: #475569;
  flex-shrink: 0;
  padding: 0 0.5rem;
}

/* ── Rules box ──────────────────────────────────────────────── */

.title-rules {
  width: 100%;
  max-width: 360px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.rule-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 7px;
  line-height: 1;
}

.rule-key { color: #333; }

.rule-val       { font-size: 8px; font-weight: bold; }
.rule-val.good  { color: #2a7a2a; }
.rule-val.warn  { color: #a06010; }
.rule-val.bad   { color: #a02020; }

/* ── Start form ─────────────────────────────────────────────── */

.title-form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 0.75rem; }

.input-box { padding: 0; overflow: hidden; }

.pixel-input {
  width: 100%;
  padding: 1rem;
  background: #f0edd8;
  border: none;
  outline: none;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #111;
  letter-spacing: 0.05em;
}

.pixel-input::placeholder { color: #aaa; }

.flash-error {
  width: 100%;
  max-width: 360px;
  padding: 0.75rem 1rem;
  background: #f0dada;
  border-color: #a02020;
  color: #a02020;
  font-size: 7px;
  text-align: center;
}

.scores-link {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #475569;
  text-decoration: none;
  margin-top: 0.25rem;
}
.scores-link:hover { color: #94a3b8; }

/* ── Game over ──────────────────────────────────────────────── */

.over-page { justify-content: center; }

.over-header { text-align: center; }

.over-label {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.9rem, 3.5vw, 1.2rem);
  color: #e84040;
  text-shadow: 2px 2px 0 #8a0000;
  margin: 0 0 0.5rem;
}

.over-sub {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #64748b;
  margin: 0;
}

.over-sprite { width: 120px; height: auto; opacity: 0.7; }
.over-sprite svg { width: 100%; height: auto; }

.over-card {
  width: 100%;
  max-width: 360px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.over-player {
  font-size: 9px;
  color: #333;
  border-bottom: 2px solid #ccc;
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
}

.over-score-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.over-score-label { font-size: 7px; color: #555; }
.over-score-val   { font-size: 18px; color: #1a1a1a; }

.over-enc {
  font-size: 6px;
  color: #888;
  margin-top: 0.25rem;
}

.over-actions {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.over-actions form { width: 100%; }

/* ── Leaderboard ────────────────────────────────────────────── */

.scores-box {
  width: 100%;
  max-width: 360px;
  padding: 0;
  overflow: hidden;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid #ddd8b8;
  font-size: 7px;
}

.score-row:last-child { border-bottom: none; }

.score-row--top { background: #faf5d0; }

.score-rank  { color: #888; width: 1.5rem; flex-shrink: 0; text-align: right; }
.score-name  { flex: 1; color: #111; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.score-pts   { color: #1a5a1a; font-size: 9px; flex-shrink: 0; }

.empty-scores {
  width: 100%;
  max-width: 360px;
  padding: 2rem;
  text-align: center;
  font-size: 7px;
  color: #888;
  line-height: 2;
}

/* ═══════════════════════════════════════════════════════════════
   BATTLE PAGE (PLAY SCREEN)
   ═══════════════════════════════════════════════════════════════ */

.battle-page {
  min-height: 100vh;
  background: #0a0a12;
  display: flex;
  flex-direction: column;
  font-family: 'Press Start 2P', monospace;
}

/* ── Battle scene ───────────────────────────────────────────── */

.battle-scene {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  /* Sky gradient */
  background: linear-gradient(to bottom, #080812 0%, #0f0f22 45%, #181820 70%, #1e1e1e 100%);
}

/* ── Scrolling street (sidewalk + road markings) ─────────────── */

@keyframes sidewalkScroll {
  from { background-position: 0 0; }
  to   { background-position: -120px 0; }
}

@keyframes buildingScroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* Sky / upper half — dark night with scrolling building silhouettes */
.battle-scene::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: 0;
  bottom: 35%;
  background:
    /* Window lights pattern */
    repeating-linear-gradient(
      90deg,
      transparent 0, transparent 18px,
      rgba(255,220,80,0.18) 18px, rgba(255,220,80,0.18) 22px,
      transparent 22px, transparent 40px,
      rgba(255,220,80,0.10) 40px, rgba(255,220,80,0.10) 44px,
      transparent 44px, transparent 60px
    ),
    linear-gradient(to bottom, #050510 0%, #0a0a1e 60%, #141428 100%);
  animation: sidewalkScroll 3s linear infinite;
  z-index: 0;
}

/* Ground / lower half — sidewalk concrete with scrolling joint lines */
.battle-scene::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  height: 35%;
  background:
    repeating-linear-gradient(
      90deg,
      #1c1c1c 0, #1c1c1c 1px,
      transparent 1px, transparent 60px
    ),
    repeating-linear-gradient(
      0deg,
      #1c1c1c 0, #1c1c1c 1px,
      transparent 1px, transparent 30px
    ),
    #161616;
  animation: sidewalkScroll 1.2s linear infinite;
  z-index: 0;
}

/* Horizon divider line */
.battle-divider {
  position: absolute;
  left: 0; right: 0;
  bottom: 35%;
  height: 3px;
  background: #2a2a4a;
  z-index: 1;
}

/* Animated sidewalk strip just below the divider — curb */
.battle-street {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(35% - 8px);
  height: 8px;
  background:
    repeating-linear-gradient(
      90deg,
      #3a3a5a 0, #3a3a5a 1px,
      #252540 1px, #252540 24px
    );
  animation: sidewalkScroll 0.8s linear infinite;
  z-index: 1;
}

/* ── Info boxes ─────────────────────────────────────────────── */

.enemy-info {
  position: absolute;
  top: 8%;
  left: 4%;
  width: 46%;
  z-index: 2;
  padding: 10px 12px;
}

.player-info {
  position: absolute;
  bottom: 5%;
  right: 4%;
  width: 50%;
  z-index: 2;
  padding: 10px 12px;
}

.info-name {
  font-size: 8px;
  color: #111;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info-sub {
  font-size: 6px;
  color: #666;
}

.info-score-label {
  font-size: 6px;
  color: #666;
  margin-bottom: 2px;
}

.info-score {
  font-size: 14px;
  color: #111;
  line-height: 1;
}

/* ── Sprite zones ───────────────────────────────────────────── */

.enemy-sprite-zone {
  position: absolute;
  top: 2%;
  right: 4%;
  width: 50%;
  bottom: 37%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.player-sprite-zone {
  position: absolute;
  left: 4%;
  width: 46%;
  top: 38%;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.sprite-shadow {
  width: 80px;
  height: 16px;
  background: radial-gradient(ellipse, rgba(0,0,0,0.5) 0%, transparent 70%);
  border-radius: 50%;
  flex-shrink: 0;
  margin-bottom: 4px;
}

/* ── SVG sprite sizing ──────────────────────────────────────── */

.creature-svg {
  width: 100%;
  max-width: 130px;
  height: auto;
  flex-shrink: 0;
}

.trainer-svg {
  width: 75%;
  max-width: 90px;
  height: auto;
  flex-shrink: 0;
}

/* ── Entrance animations ────────────────────────────────────── */

@keyframes enemyEnter {
  from { opacity: 0; transform: translateX(40px) scale(0.85); }
  to   { opacity: 1; transform: translateX(0)    scale(1); }
}

@keyframes trainerEnter {
  from { opacity: 0; transform: translateX(-30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes creatureBob {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

.enemy-sprite-zone .creature-svg {
  animation:
    enemyEnter 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards,
    creatureBob 2.4s ease-in-out 0.5s infinite;
}

.player-sprite-zone .trainer-svg {
  animation: trainerEnter 0.35s ease-out 0.15s both;
}

/* ── Dialog box ─────────────────────────────────────────────── */

.dialog-box {
  background: #f0edd8;
  border: 3px solid #222;
  border-radius: 6px;
  margin: 4px 4px 2px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  flex-shrink: 0;
}

.dialog-text {
  font-size: 8px;
  line-height: 1.9;
  color: #111;
  flex: 1;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.dialog-cursor {
  width: 10px;
  height: 10px;
  border-right: 3px solid #111;
  border-bottom: 3px solid #111;
  transform: rotate(45deg);
  flex-shrink: 0;
  margin-left: 8px;
  animation: blink 0.8s ease-in-out infinite;
}

/* ── Battle menu ────────────────────────────────────────────── */

.battle-menu {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 4px;
  flex-shrink: 0;
}

.battle-form { flex: 1; }

.battle-btn {
  width: 100%;
  padding: 1.1rem 0.5rem;
  background: #f0edd8;
  border: 3px solid #222;
  border-radius: 6px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #111;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: background 0.08s, color 0.08s;
}

.battle-btn:hover,
.battle-btn:focus {
  outline: none;
}

.battle-btn-kick:hover,
.battle-btn-kick:focus { background: #c84040; color: #f0edd8; border-color: #8a1010; }
.battle-btn-pet:hover,
.battle-btn-pet:focus  { background: #2a6a2a; color: #f0edd8; border-color: #0a3a0a; }

.battle-btn:active { transform: scale(0.97); }

/* ── Battle footer ──────────────────────────────────────────── */

.battle-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0 0.75rem;
  font-size: 6px;
  flex-shrink: 0;
}

.battle-footer a { color: #475569; text-decoration: none; }
.battle-footer a:hover { color: #94a3b8; }
.battle-footer span { color: #2a2a3a; }

.key-hint { color: #1e293b; font-size: 6px; }

/* ═══════════════════════════════════════════════════════════════
   DEATH ANIMATIONS (rat bite)
   ═══════════════════════════════════════════════════════════════ */

/* Rat lunges toward the player */
@keyframes ratLunge {
  0%   { transform: translateX(0) scale(1); }
  35%  { transform: translateX(-60px) scale(1.25); }
  60%  { transform: translateX(-40px) scale(1.2); }
  100% { transform: translateX(-60px) scale(1.25); }
}

.rat-lunge .creature-svg {
  animation: ratLunge 0.5s ease-out forwards !important;
}

/* Full-page blood-red wash that fades in */
@keyframes bloodWash {
  0%   { opacity: 0; }
  30%  { opacity: 0.7; }
  100% { opacity: 0.85; }
}

.blood-wash::after {
  content: '';
  position: fixed;
  inset: 0;
  background: #8b0000;
  opacity: 0;
  animation: bloodWash 1.2s ease-in forwards;
  pointer-events: none;
  z-index: 100;
}

/* Blood splash — large circle that bursts in the scene */
@keyframes splashBurst {
  0%   { transform: scale(0); opacity: 1; }
  60%  { transform: scale(1.4); opacity: 0.9; }
  100% { transform: scale(1.2); opacity: 0.6; }
}

.blood-splash {
  position: absolute;
  left: 30%;
  top: 30%;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle, #cc0000 0%, #880000 60%, transparent 100%);
  animation: splashBurst 0.4s ease-out forwards;
  pointer-events: none;
  z-index: 10;
}

/* Blood drips that fall from top of scene */
@keyframes bloodDripFall {
  0%   { top: 0;    opacity: 1; }
  100% { top: 100%; opacity: 0.8; }
}

.blood-drip {
  position: absolute;
  top: 0;
  border-radius: 50% 50% 60% 60%;
  background: radial-gradient(ellipse, #dd1111 20%, #660000 100%);
  animation: bloodDripFall 0.9s ease-in forwards;
  pointer-events: none;
  z-index: 11;
}
