/* ═══════════════════════════════════════════════
   PokéCozy — style.css
   Cozy Retro-Modern Theme
   ═══════════════════════════════════════════════ */

:root {
  --color-bg:           #1F232B;
  --color-bg-deep:      #181C23;
  --color-surface:      #F4F1EA;
  --color-surface-warm: #EDE8DF;
  --color-surface-dim:  #E2DDD4;
  --color-accent:       #E8A838;   
  --color-accent-soft:  #F0C070;
  --color-accent-glow:  rgba(232, 168, 56, 0.18);
  --color-red:          #C44B3A;
  --color-red-soft:     rgba(196, 75, 58, 0.12);
  --color-green:        #5A8A5E;
  --color-muted:        #7A8394;
  --color-border:       rgba(244, 241, 234, 0.1);
  --font-display:  'Cinzel', serif;
  --font-body:     'Lora', serif;
  --font-mono:     'JetBrains Mono', monospace;
  --space-xs:  4px; --space-sm: 8px; --space-md: 16px; --space-lg: 24px; --space-xl: 40px;
  --radius-sm: 8px; --radius-md: 14px; --radius-lg: 22px; --radius-xl: 32px;
  --shadow-card:  0 4px 32px rgba(0,0,0,0.28), 0 1px 4px rgba(0,0,0,0.2);
  --shadow-lift:  0 12px 48px rgba(0,0,0,0.36), 0 2px 8px rgba(0,0,0,0.24);
  --shadow-glow:  0 0 32px var(--color-accent-glow), 0 4px 32px rgba(0,0,0,0.28);
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-snap: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { background-color: var(--color-bg); color: var(--color-surface); font-family: var(--font-body); line-height: 1.6; min-height: 100vh; overflow-x: hidden; position: relative; }

.grain-overlay {
  pointer-events: none; position: fixed; inset: 0; z-index: 1; opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 200px;
}

.orb { position: fixed; border-radius: 50%; filter: blur(80px); pointer-events: none; z-index: 0; animation: orb-drift 20s ease-in-out infinite alternate; }
.orb--1 { width: 520px; height: 520px; background: radial-gradient(circle, rgba(232, 168, 56, 0.07) 0%, transparent 70%); top: -180px; left: -120px; animation-duration: 24s; }
.orb--2 { width: 400px; height: 400px; background: radial-gradient(circle, rgba(90, 138, 94, 0.06) 0%, transparent 70%); bottom: -100px; right: -80px; animation-duration: 18s; animation-direction: alternate-reverse; }
.orb--3 { width: 300px; height: 300px; background: radial-gradient(circle, rgba(196, 75, 58, 0.05) 0%, transparent 70%); top: 50%; left: 60%; animation-duration: 30s; }
@keyframes orb-drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(30px, -40px) scale(1.06); } }

.app-shell { position: relative; z-index: 2; max-width: 1100px; margin: 0 auto; padding: var(--space-xl) var(--space-lg); display: flex; flex-direction: column; gap: var(--space-xl); animation: shell-reveal 0.8s var(--ease-out) both; }
@keyframes shell-reveal { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }

.site-header { text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--space-sm); padding-bottom: var(--space-md); }
.header-badge { display: flex; align-items: center; gap: var(--space-sm); background: rgba(232, 168, 56, 0.12); border: 1px solid rgba(232, 168, 56, 0.3); border-radius: 100px; padding: 5px 18px; }
.badge-text { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.18em; color: var(--color-accent-soft); }
.badge-icon { font-size: 0.6rem; color: var(--color-accent); }
.site-title { font-family: var(--font-display); font-size: clamp(2.4rem, 6vw, 4rem); letter-spacing: 0.04em; color: var(--color-surface); text-shadow: 0 2px 24px rgba(232, 168, 56, 0.3); }
.site-tagline { font-style: italic; color: var(--color-muted); font-size: 0.95rem; }

.main-grid { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: var(--space-lg); }
.card--profile { grid-column: 1; grid-row: 1; }
.card--pokedex { grid-column: 2; grid-row: 1; }
.card--actions { grid-column: 1; grid-row: 2; }
.card--console { grid-column: 2; grid-row: 2; }

@media (max-width: 700px) {
  .main-grid { grid-template-columns: 1fr; }
  .card--profile, .card--pokedex, .card--actions, .card--console { grid-column: 1; grid-row: auto; }
}

.card { background: var(--color-surface); border-radius: var(--radius-lg); padding: var(--space-lg); box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: var(--space-md); color: #2C2420; position: relative; overflow: hidden; transition: box-shadow 0.3s var(--ease-out), transform 0.3s var(--ease-out); animation: card-in 0.6s var(--ease-out) both; }
.card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.card--profile { animation-delay: 0.25s; } .card--pokedex { animation-delay: 0.32s; } .card--actions { animation-delay: 0.39s; } .card--console { animation-delay: 0.46s; }
@keyframes card-in { from { opacity: 0; transform: translateY(20px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.card::before { content: ''; position: absolute; top: 0; left: var(--space-lg); right: var(--space-lg); height: 2px; background: linear-gradient(90deg, transparent, rgba(232, 168, 56, 0.5), transparent); }
.card::after { content: '· · ·'; position: absolute; bottom: var(--space-sm); right: var(--space-md); font-size: 0.6rem; color: rgba(44, 36, 32, 0.2); }

.card__eyebrow { display: flex; align-items: center; gap: var(--space-xs); font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: #7A6A62; }
.eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-accent); }
.eyebrow-dot--live { background: var(--color-green); animation: pulse-live 2s ease-out infinite; }
@keyframes pulse-live { 0% { box-shadow: 0 0 0 0 rgba(90, 138, 94, 0.5); } 70% { box-shadow: 0 0 0 7px rgba(90, 138, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(90, 138, 94, 0); } }

.profile-avatar { font-size: 3.2rem; text-align: center; animation: float 5s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.profile-name { font-family: var(--font-display); font-size: 1.5rem; text-align: center; color: #2C2420; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-sm); }
.stat { background: var(--color-surface-warm); border-radius: var(--radius-sm); padding: var(--space-sm) var(--space-md); display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--color-surface-dim); }
.stat__label { font-size: 0.68rem; text-transform: uppercase; font-family: var(--font-mono); color: #9A8880; }
.stat__value { font-size: 1.1rem; font-weight: 600; color: #2C2420; }

.pokedex-count { display: flex; align-items: baseline; gap: var(--space-sm); }
.pokedex-count__number { font-size: 3.5rem; font-weight: 600; color: var(--color-accent); }
.pokedex-count__label { font-size: 0.85rem; color: #7A6A62; }
.pokemon-list { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.pokemon-tag { background: var(--color-surface-warm); border: 1px solid var(--color-surface-dim); border-radius: 100px; padding: 3px 12px; font-size: 0.78rem; font-family: var(--font-mono); color: #4A3C38; display: flex; align-items: center; gap: 5px; }

.action-group { display: flex; flex-direction: column; gap: var(--space-sm); }
.action-group__title { font-size: 1rem; font-weight: 600; color: #2C2420; }
.action-group__desc { font-size: 0.83rem; color: #7A6A62; font-style: italic; }

.btn { display: inline-flex; align-items: center; gap: var(--space-sm); padding: 10px 22px; border-radius: var(--radius-md); border: none; font-family: var(--font-body); font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: transform 0.18s var(--ease-snap), box-shadow 0.2s var(--ease-out); }
.btn--primary { background: #2C2420; color: var(--color-accent-soft); }
.btn--primary:hover { background: #1F1A17; transform: translateY(-2px); box-shadow: 0 6px 24px rgba(44,36,32,0.25), 0 0 0 2px var(--color-accent); }
.btn--danger { background: var(--color-surface-warm); color: var(--color-red); border: 1.5px solid rgba(196, 75, 58, 0.3); }
.btn--danger:hover { background: var(--color-red-soft); transform: translateY(-2px); border-color: var(--color-red); }

.console-output { flex: 1; min-height: 140px; max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.log-entry { display: flex; gap: var(--space-sm); font-family: var(--font-mono); font-size: 0.75rem; padding: 5px 8px; border-radius: var(--radius-sm); }
.log-entry--info { color: #4A3C38; }
.log-entry--success { color: var(--color-green); background: rgba(90, 138, 94, 0.08); }
.log-entry--warn { color: #C47A2A; background: rgba(232, 168, 56, 0.1); }
.log-entry--error { color: var(--color-red); background: var(--color-red-soft); }
.log-entry__time { color: #9A8880; flex-shrink: 0; }

.map-section { display: flex; flex-direction: column; gap: var(--space-md); }
.map-wrap { position: relative; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lift); border: 1px solid var(--color-border); }
#map { width: 100%; height: 420px; background: #181C23; z-index: 0; }

.player-marker-wrap { position: relative; display: flex; align-items: center; justify-content: center; }
.player-radius-ring { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: var(--ring-px, 60px); height: var(--ring-px, 60px); border-radius: 50%; border: 2px solid rgba(232, 168, 56, 0.55); background: rgba(232, 168, 56, 0.07); animation: ring-pulse 2.8s ease-out infinite; }
@keyframes ring-pulse { 0% { box-shadow: 0 0 0 0 rgba(232, 168, 56, 0.35); opacity: 1; } 60% { box-shadow: 0 0 0 12px rgba(232, 168, 56, 0); opacity: 0.7; } 100% { box-shadow: 0 0 0 0 rgba(232, 168, 56, 0); opacity: 1; } }
.player-dot { position: relative; z-index: 2; width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #F0C070, #E8A838 60%, #B87820); border: 2.5px solid #1F232B; }

.map-recenter { position: absolute; bottom: var(--space-md); right: var(--space-md); z-index: 400; width: 40px; height: 40px; border-radius: 50%; background: rgba(31, 35, 43, 0.88); color: var(--color-accent-soft); cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* ── MAP HUD (Beneath Map Layout Rules) ── */
.map-hud {
  position: relative !important; top: auto !important; left: auto !important; transform: none !important; z-index: 10;
  background: var(--color-surface); border-radius: var(--radius-lg); padding: var(--space-md) var(--space-lg); width: 100%; box-shadow: var(--shadow-card);
  display: flex !important; flex-direction: row; align-items: center; justify-content: space-between; gap: var(--space-lg); margin-top: var(--space-md);
  border-left: 3px solid var(--color-accent); animation: card-in 0.5s var(--ease-out) both;
  background-image: repeating-linear-gradient(0deg, transparent, transparent 23px, rgba(44, 36, 32, 0.035) 23px, rgba(44, 36, 32, 0.035) 24px);
}
.hud-row-container { display: flex; flex: 1; justify-content: space-around; gap: var(--space-md); }
.hud-badge { display: flex; align-items: center; gap: var(--space-xs); flex-shrink: 0; }
.map-hud .hud-divider { width: 1px; height: 32px; background: var(--color-surface-dim); margin: 0; display: block; }
.hud-row { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hud-label { font-size: 0.68rem; color: #7A6A62; text-transform: uppercase; }
.hud-value { font-size: 1rem; font-weight: 600; color: #2C2420; }
.hud-pc-btn { width: auto; padding: 8px 16px; flex-shrink: 0; display: flex; gap: 7px; border-radius: var(--radius-sm); border: 1.5px solid rgba(232, 168, 56, 0.35); background: rgba(232, 168, 56, 0.08); cursor: pointer; }

@media (max-width: 650px) {
  .map-hud { flex-direction: column !important; align-items: stretch; gap: var(--space-sm); }
  .hud-row-container { flex-direction: row; justify-content: space-between; }
  .map-hud .hud-divider { display: none; }
}

/* ══════════════════════════════════════════════
   POKÉMON SPAWN MARKERS & HITBOXES
══════════════════════════════════════════════ */
.poke-marker {
  position: relative; display: flex; flex-direction: column; align-items: center; cursor: pointer; width: 100%; height: 100%;
}
.poke-marker::before { content: ''; position: absolute; inset: -10px; background: transparent; z-index: 0; }
.poke-marker__sprite { width: 56px; height: 56px; object-fit: contain; image-rendering: pixelated; animation: poke-bob 2.2s ease-in-out infinite; pointer-events: none; position: relative; z-index: 2; }
@keyframes poke-bob { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-8px); } }

.poke-marker__shadow { position: absolute; bottom: 2px; width: 32px; height: 8px; border-radius: 50%; background: rgba(0,0,0,0.35); filter: blur(3px); animation: poke-shadow 2.2s ease-in-out infinite; pointer-events: none; }
@keyframes poke-shadow { 0%, 100% { transform: scaleX(1); opacity: 0.4; } 45% { transform: scaleX(0.7); opacity: 0.2; } }
.poke-marker__wobble-ring { position: absolute; bottom: 0; width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.18); animation: wobble-ring 2.2s ease-out infinite; pointer-events: none; }
@keyframes wobble-ring { 0% { transform: scale(0.6); opacity: 0.8; } 70% { transform: scale(1.5); opacity: 0; } }

/* ── MODALS & ENCOUNTERS ── */
.landmark-popup { position: fixed; inset: 0; z-index: 1800; display: flex; align-items: flex-end; justify-content: center; }
.landmark-popup__backdrop { position: absolute; inset: 0; background: rgba(15, 18, 24, 0.6); backdrop-filter: blur(4px); }
.landmark-popup__card { position: relative; z-index: 1; background: var(--color-surface); border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding: var(--space-lg); width: 100%; max-width: 480px; box-shadow: 0 -8px 48px rgba(0,0,0,0.3); transform: translateY(0); transition: transform 0.4s var(--ease-snap); display: flex; flex-direction: column; gap: var(--space-md); }
.is-hidden { display: none !important; }

/* ── BATTLE OVERLAY ── */
.battle-screen { position: fixed; inset: 0; z-index: 2000; display: flex; flex-direction: column; overflow: hidden; background: #181C23; }
.battle-arena { flex: 1 1 55%; position: relative; background: linear-gradient(180deg, #2A3550 0%, #3D4F6E 45%, #5E6B44 45%, #4A5538 100%); }
.combatant { position: absolute; display: flex; gap: 10px; z-index: 2; }
.combatant--enemy { top: 12%; right: 4%; flex-direction: column; align-items: flex-end; }
.combatant--player { bottom: 6%; left: 4%; flex-direction: column-reverse; align-items: flex-start; }
.battle-sprite { image-rendering: pixelated; object-fit: contain; }
.battle-sprite--enemy { width: 140px; height: 140px; animation: enemy-idle 3s ease-in-out infinite; }
.battle-sprite--player { width: 120px; height: 120px; }
.fainted { filter: grayscale(1) opacity(0.3) !important; transform: translateY(20px) !important; }
.hit-flash { animation: hit-flash 0.4s steps(1) !important; }
@keyframes hit-flash { 0%,100% { opacity: 1; } 50% { filter: brightness(10); opacity: 0.5; } }

.status-panel { background: var(--color-surface); border-radius: var(--radius-md); padding: 10px 14px; min-width: 180px; color: #2C2420; display: flex; flex-direction: column; gap: 6px; }
.hp-bar-wrap { height: 8px; background: var(--color-surface-dim); border-radius: 4px; overflow: hidden; width: 100%; }
.hp-bar { height: 100%; background: #5A8A5E; transition: width 0.5s var(--color-green); }
.hp-bar--critical { animation: hp-pulse 0.8s ease-in-out infinite; background: #C44B3A; }
@keyframes hp-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.battle-controls { flex: 0 0 45%; background: var(--color-bg-deep); display: flex; flex-direction: column; }
.battle-dialogue { padding: 14px var(--space-lg); min-height: 64px; color: #fff; }
.battle-btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-sm); padding: var(--space-sm); }
.battle-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; background: #374151; border: none; border-radius: var(--radius-md); color: #fff; cursor: pointer; padding: var(--space-md); }
.battle-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.battle-btn--attack { background: linear-gradient(160deg, #C8503A, #A03828); }
.battle-btn--catch { background: linear-gradient(160deg, #D4403A, #AA2020); }
.battle-btn--locked { display: none !important; }

.dmg-number { position: absolute; font-family: var(--font-mono); font-weight: 600; color: #FF6B6B; animation: dmg-float 1.1s var(--ease-out) forwards; }
.dmg-number--player { color: #F0C070; }
@keyframes dmg-float { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-40px); } }
.battle-result-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 2rem; z-index: 20; }

/* ── PC DRAWER ── */
.pc-drawer { position: fixed; inset: 0; z-index: 1500; display: flex; justify-content: flex-end; }
.pc-drawer__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.pc-drawer__panel { position: relative; width: min(420px, 100vw); height: 100%; background: #F9F6EE; display: flex; flex-direction: column; color: #2C2420; }
.pc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: var(--space-md); padding: var(--space-md); overflow-y: auto; }
.pc-card { background: #fff; border-radius: var(--radius-md); padding: var(--space-sm); display: flex; flex-direction: column; align-items: center; position: relative; border: 1.5px solid var(--color-surface-dim); }
.pc-card__level { position: absolute; top: 4px; right: 4px; font-size: 0.6rem; background: #2C2420; color: #fff; padding: 2px 4px; border-radius: 4px; }
.pc-card__sprite { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; }
.pc-card__hp-wrap { height: 4px; background: #eee; width: 100%; overflow: hidden; margin-top: 4px; }
.pc-card__hp-bar { height: 100%; background: var(--color-green); }
.pc-card__hp-bar.is-red { background: var(--color-red); }
.pc-card__hp-bar.is-yellow { background: #C8A830; }

.landmark-marker__pin { width: 30px; height: 30px; background: #8AAAD4; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: flex; align-items: center; justify-content: center; }
.landmark-marker__pin--center { background: #E8A0B0; }
.landmark-marker__emoji { transform: rotate(45deg); display: block; }
.landmark-marker__label { background: rgba(0,0,0,0.8); font-size: 0.6rem; padding: 2px 4px; border-radius: 4px; white-space: nowrap; }

/* ── STARTER SELECTION VISUALS ── */
.starter-choice-btn { transition: transform 0.2s var(--ease-snap), background-color 0.2s !important; user-select: none; }
.starter-choice-btn:hover:not(:disabled) { background-color: var(--color-surface-dim) !important; transform: scale(1.05) translateY(-4px) !important; border-color: var(--color-accent) !important; }
