/*
 * 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;
  overflow: hidden;
}

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

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

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

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

.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 / OVER / LEADERBOARD PAGES (unchanged)
   ═══════════════════════════════════════════════════════════════ */

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

.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 {
  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;
}

.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; }

.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; }

/* Inline leaderboard on the title page */
.title-leaderboard {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: 'Press Start 2P', monospace;
  padding: 0 0.25rem;
}

.leaderboard-title {
  font-size: 9px;
  color: #f5e642;
  letter-spacing: 0.1em;
  text-shadow: 1px 1px 0 #8a7000;
}

.leaderboard-sub {
  font-size: 6px;
  color: #64748b;
  letter-spacing: 0.15em;
}

/* ── 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%; }

/* Stats card on the game-over page */
.over-stats { gap: 0.4rem; }
.over-stats .stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 8px;
  color: #333;
}
.over-stats .stat-label  { color: #555; letter-spacing: 0.1em; }
.over-stats .stat-val    { font-size: 10px; color: #1a1a1a; }
.over-stats .stat-bad .stat-val { color: #a02020; }

/* ── 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;
}

/* ═══════════════════════════════════════════════════════════════
   CITYSCAPE — canvas-driven first-person walk
   ═══════════════════════════════════════════════════════════════ */

.cityscene {
  position: fixed;
  inset: 0;
  overflow: hidden;
  font-family: 'Press Start 2P', monospace;
  background: #02030a;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.scene-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

/* ── HUD ───────────────────────────────────────────────────── */

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.85rem 1rem 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  z-index: 8;
  pointer-events: none;
  gap: 0.75rem;
}

.hud-name {
  font-size: 8px;
  color: #f0edd8;
  background: rgba(10,10,18,0.55);
  padding: 6px 9px;
  border: 2px solid #1a1a28;
  border-radius: 4px;
  letter-spacing: 0.08em;
}

.hud-score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: rgba(10,10,18,0.55);
  padding: 6px 10px;
  border: 2px solid #1a1a28;
  border-radius: 4px;
  gap: 2px;
  min-width: 84px;
}

.hud-score-label {
  font-size: 6px;
  color: #94a3b8;
  letter-spacing: 0.15em;
}

.hud-score-value {
  font-size: 16px;
  color: #f5e642;
  text-shadow: 1px 1px 0 #00000088;
  line-height: 1;
}

.hud-delta {
  position: absolute;
  top: 54px;
  right: 1rem;
  font-size: 14px;
  opacity: 0;
  transform: translateY(0);
  pointer-events: none;
  letter-spacing: 0.04em;
  text-shadow: 2px 2px 0 #00000088;
}

.hud-delta.good { color: #6ee06e; }
.hud-delta.bad  { color: #e84040; }

@keyframes deltaPop {
  0%   { opacity: 0; transform: translateY(8px); }
  20%  { opacity: 1; transform: translateY(-2px); }
  100% { opacity: 0; transform: translateY(-26px); }
}

.hud-delta.show { animation: deltaPop 0.75s ease-out forwards; }

/* ── Tap zones (diagonal split) ────────────────────────────── */

.tap-zone {
  position: absolute;
  inset: 0;
  border: none;
  cursor: pointer;
  z-index: 10;
  background: transparent;
  font-family: 'Press Start 2P', monospace;
  color: #f0edd8;
  padding: 0;
  margin: 0;
  display: flex;
  -webkit-tap-highlight-color: transparent;
}

.tap-zone:focus { outline: none; }

.tap-pet {
  clip-path: polygon(0 0, 100% 0, 0 100%);
  background: linear-gradient(135deg, rgba(46, 122, 70, 0.16) 0%, rgba(46, 122, 70, 0) 70%);
  align-items: flex-start;
  justify-content: flex-start;
  padding: 4rem 0 0 1.5rem;
}

.tap-kick {
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  background: linear-gradient(315deg, rgba(168, 34, 34, 0.18) 0%, rgba(168, 34, 34, 0) 70%);
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 1.5rem 4rem 0;
}

.tap-pet:active  { background: linear-gradient(135deg, rgba(46, 200, 90, 0.35) 0%, rgba(46, 200, 90, 0) 80%); }
.tap-kick:active { background: linear-gradient(315deg, rgba(220, 50, 50, 0.40) 0%, rgba(220, 50, 50, 0) 80%); }

.tap-label {
  font-size: 20px;
  letter-spacing: 0.12em;
  text-shadow: 2px 2px 0 #00000099, 0 0 16px rgba(0,0,0,0.5);
}

.tap-pet .tap-label  { color: #aef0c0; }
.tap-kick .tap-label { color: #f0aeae; }

/* ── Footer ────────────────────────────────────────────────── */

.hud-footer {
  position: absolute;
  bottom: 0.5rem;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  font-size: 6px;
  z-index: 9;
  pointer-events: none;
}

.hud-footer a   { color: #475569; text-decoration: none; pointer-events: auto; background: rgba(10,10,18,0.6); padding: 4px 8px; border-radius: 3px; }
.hud-footer a:hover { color: #94a3b8; }
.hud-footer span { color: #2a2a3a; }

/* ── Player actor sprites (hand on PET, foot on KICK) ─────── */

.actor {
  position: absolute;
  pointer-events: none;
  z-index: 9;
  opacity: 0;
}

.actor svg { width: 100%; height: 100%; display: block; }

.actor-hand {
  width: 320px;
  height: 360px;
  right: 5%;
  bottom: 0;
  transform: translateY(105%) rotate(-10deg);
  transform-origin: 70% 95%;
}

.actor-foot {
  width: 320px;
  height: 380px;
  left: 4%;
  bottom: 0;
  transform: translateY(110%) rotate(-12deg);
  transform-origin: 30% 95%;
}

@keyframes handPet {
  0%   { opacity: 0;   transform: translateY(105%)  rotate(-10deg); }
  18%  { opacity: 1;   transform: translateY(40%)   rotate(-26deg); }
  42%  { opacity: 1;   transform: translateY(-32%)  rotate(-46deg); }
  60%  { opacity: 1;   transform: translateY(-22%)  rotate(-40deg); }
  100% { opacity: 0;   transform: translateY(105%)  rotate(-10deg); }
}

@keyframes footKick {
  0%   { opacity: 0;   transform: translateY(110%)  rotate(-12deg); }
  18%  { opacity: 1;   transform: translateY(35%)   rotate(8deg); }
  42%  { opacity: 1;   transform: translateY(-30%)  rotate(38deg); }
  60%  { opacity: 1;   transform: translateY(-20%)  rotate(26deg); }
  100% { opacity: 0;   transform: translateY(110%)  rotate(-12deg); }
}

.actor-hand.acting { animation: handPet 0.75s cubic-bezier(0.30, 0.0, 0.30, 1) forwards; }
.actor-foot.acting { animation: footKick 0.75s cubic-bezier(0.30, 0.0, 0.30, 1) forwards; }

/* ── Blood overlay (rat death) ─────────────────────────────── */

.blood-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 60%, #aa0000 0%, #660000 60%, #220000 100%);
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  transition: opacity 1.1s ease-in;
}

.blood-overlay.active { opacity: 0.85; }
