/* Pokémon Roguelike (proyecto de fan) — styles
   Original visual identity: crimson + navy + gold, flat geometric
   avatars (no sprites/artwork), restrained borders, no gradients. */

:root {
  --crimson: #c8313f;
  --crimson-dark: #96222d;
  --navy: #1f2a44;
  --navy-soft: #4a5578;
  --gold: #e8a53d;
  --bg: #f7f5f1;
  --card-bg: #ffffff;
  --ink: #1c1a22;
  --ink-soft: #625f6c;
  --danger: #c8313f;
  --success: #3a8f5c;
  --border: #e3ded4;

  --t-normal: #9199a1; --t-normal-ink: #fff;
  --t-fighting: #b8432f; --t-fighting-ink: #fff;
  --t-flying: #8fa1e0; --t-flying-ink: #1c1a22;
  --t-poison: #954a95; --t-poison-ink: #fff;
  --t-ground: #c8a15a; --t-ground-ink: #1c1a22;
  --t-rock: #a3934a; --t-rock-ink: #fff;
  --t-bug: #8b9a2b; --t-bug-ink: #fff;
  --t-ghost: #5f5285; --t-ghost-ink: #fff;
  --t-steel: #9a9aae; --t-steel-ink: #1c1a22;
  --t-fire: #d9762f; --t-fire-ink: #fff;
  --t-water: #4a79c9; --t-water-ink: #fff;
  --t-grass: #5a9e4a; --t-grass-ink: #fff;
  --t-electric: #d6ae2c; --t-electric-ink: #1c1a22;
  --t-psychic: #d1517a; --t-psychic-ink: #fff;
  --t-ice: #6bb8b8; --t-ice-ink: #1c1a22;
  --t-dragon: #6248c9; --t-dragon-ink: #fff;
  --t-dark: #5b4f45; --t-dark-ink: #fff;
  --t-fairy: #d98fae; --t-fairy-ink: #1c1a22;

  --radius: 14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  touch-action: manipulation;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  line-height: 1.5;
}

h1, h2, h3, .screen-title,
.btn, .pill, .type-badge,
.node-label, .mon-name, .item-name, .chip-name, .move-name, .dex-name {
  font-family: 'Rubik', system-ui, sans-serif;
}

.page { max-width: 560px; margin: 0 auto; padding: 12px 12px 32px; }

.site-header {
  text-align: center;
  padding: 20px 8px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

h1 {
  margin: 0 0 6px;
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-weight: 800;
  color: var(--crimson-dark);
  letter-spacing: 0.2px;
}

.tagline { margin: 0 auto; max-width: 44ch; color: var(--ink-soft); font-weight: 500; font-size: 0.94rem; }

.disclaimer-top {
  margin: 10px auto 0;
  max-width: 46ch;
  font-size: 0.72rem;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}

h2 { font-size: 1.25rem; font-weight: 800; color: var(--crimson-dark); }
h3 { font-size: 1.02rem; font-weight: 700; color: var(--ink); margin-bottom: 6px; }

#game-app {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
  min-height: 320px;
  margin-bottom: 26px;
}

.loading-msg { text-align: center; color: var(--ink-soft); padding: 40px 0; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--crimson);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, opacity 0.15s ease;
  width: 100%;
}
.btn:active { transform: translateY(1px); opacity: 0.9; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary { background: var(--navy); }
.btn-warn { background: var(--danger); border: 2px solid var(--crimson-dark); }
.btn-outline { background: #fff; color: var(--crimson-dark); border: 2px solid var(--crimson); }
.btn-small { min-height: 40px; padding: 8px 12px; font-size: 0.85rem; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.center { text-align: center; }
.muted { color: var(--ink-soft); font-size: 0.88rem; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }

.screen-title { font-size: 1.2rem; font-weight: 800; color: var(--crimson-dark); margin: 0 0 10px; text-align: center; }

.pill {
  display: inline-block;
  background: var(--gold);
  color: #453000;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
}
.meta-stats { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.meta-stats .pill:nth-child(n+2) { background: transparent; color: var(--ink-soft); font-weight: 600; padding: 0; }

/* Monster avatar: real sprite (see monAvatarHTML), with the original flat
   geometric circle + monogram as a fallback if the image fails to load. */
.mon-avatar {
  width: 54px; height: 54px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-weight: 800;
  font-size: 1.05rem;
  border: 2px solid rgba(0,0,0,0.08);
  position: relative;
  overflow: hidden;
  background: #fff;
}
.mon-avatar.sm { width: 40px; height: 40px; font-size: 0.85rem; }
.mon-sprite { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; position: relative; z-index: 1; }
.mon-fallback { position: absolute; inset: 0; }
.mon-avatar .half { position: absolute; top: 0; bottom: 0; width: 50%; }
.mon-avatar .half.left { left: 0; }
.mon-avatar .half.right { right: 0; }
.mon-avatar .mono { position: relative; z-index: 1; text-shadow: 0 1px 2px rgba(0,0,0,0.35); }

/* Type colors */
.type-badge, .type-fill-normal, .type-fill-fighting, .type-fill-flying, .type-fill-poison,
.type-fill-ground, .type-fill-rock, .type-fill-bug, .type-fill-ghost, .type-fill-steel,
.type-fill-fire, .type-fill-water, .type-fill-grass, .type-fill-electric, .type-fill-psychic,
.type-fill-ice, .type-fill-dragon, .type-fill-dark, .type-fill-fairy { }

.type-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 2px;
  margin-right: 3px;
}

/* generated per-type modifier classes */
.type-normal, .type-fill-normal { background: var(--t-normal); color: var(--t-normal-ink); }
.type-fighting, .type-fill-fighting { background: var(--t-fighting); color: var(--t-fighting-ink); }
.type-flying, .type-fill-flying { background: var(--t-flying); color: var(--t-flying-ink); }
.type-poison, .type-fill-poison { background: var(--t-poison); color: var(--t-poison-ink); }
.type-ground, .type-fill-ground { background: var(--t-ground); color: var(--t-ground-ink); }
.type-rock, .type-fill-rock { background: var(--t-rock); color: var(--t-rock-ink); }
.type-bug, .type-fill-bug { background: var(--t-bug); color: var(--t-bug-ink); }
.type-ghost, .type-fill-ghost { background: var(--t-ghost); color: var(--t-ghost-ink); }
.type-steel, .type-fill-steel { background: var(--t-steel); color: var(--t-steel-ink); }
.type-fire, .type-fill-fire { background: var(--t-fire); color: var(--t-fire-ink); }
.type-water, .type-fill-water { background: var(--t-water); color: var(--t-water-ink); }
.type-grass, .type-fill-grass { background: var(--t-grass); color: var(--t-grass-ink); }
.type-electric, .type-fill-electric { background: var(--t-electric); color: var(--t-electric-ink); }
.type-psychic, .type-fill-psychic { background: var(--t-psychic); color: var(--t-psychic-ink); }
.type-ice, .type-fill-ice { background: var(--t-ice); color: var(--t-ice-ink); }
.type-dragon, .type-fill-dragon { background: var(--t-dragon); color: var(--t-dragon-ink); }
.type-dark, .type-fill-dark { background: var(--t-dark); color: var(--t-dark-ink); }
.type-fairy, .type-fill-fairy { background: var(--t-fairy); color: var(--t-fairy-ink); }

/* Monster card */
.mon-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  position: relative;
  overflow: hidden;
}
.mon-card.fainted { opacity: 0.5; filter: grayscale(0.7); }
.mon-top { display: flex; align-items: center; gap: 10px; }
.mon-info { flex: 1; min-width: 0; }
.mon-name { font-weight: 800; font-size: 1rem; }
.mon-sub { font-size: 0.78rem; color: var(--ink-soft); }

.hp-bar-outer { height: 11px; background: #ece7db; border-radius: 999px; overflow: hidden; margin-top: 8px; border: 1px solid var(--border); }
.hp-bar-inner { height: 100%; border-radius: 999px; transition: width 0.5s ease, background-color 0.5s ease; background: var(--success); }
.hp-bar-inner.mid { background: var(--gold); }
.hp-bar-inner.low { background: var(--danger); }
.hp-text { font-size: 0.74rem; color: var(--ink-soft); margin-top: 2px; text-align: right; }

/* Capture animation */
.capturing { animation: captureShake 1.1s ease-in-out; }
@keyframes captureShake {
  0%, 100% { transform: translateX(0) rotate(0); box-shadow: 0 0 0 rgba(200,49,63,0); }
  10% { transform: translateX(-4px) rotate(-3deg); }
  20% { transform: translateX(4px) rotate(3deg); box-shadow: 0 0 16px 4px rgba(200,49,63,0.5); }
  30% { transform: translateX(-4px) rotate(-3deg); }
  40% { transform: translateX(4px) rotate(3deg); box-shadow: 0 0 20px 6px rgba(31,42,68,0.5); }
  50% { transform: translateX(-3px) rotate(-2deg); }
  60% { transform: translateX(3px) rotate(2deg); box-shadow: 0 0 16px 4px rgba(232,165,61,0.55); }
  70% { transform: translateX(-2px) rotate(-1deg); }
  80% { transform: translateX(2px) rotate(1deg); }
  90% { transform: translateX(-1px); }
}

/* Battle layout */
.battle-arena { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.vs-label { text-align: center; font-weight: 800; color: var(--crimson); font-size: 0.82rem; }

.battle-log {
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.85rem;
  min-height: 44px;
  max-height: 110px;
  overflow-y: auto;
  margin: 10px 0;
}
.battle-log p { margin: 2px 0; }

.move-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.move-btn {
  text-align: left;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-height: 54px;
  cursor: pointer;
  touch-action: manipulation;
  color: var(--ink);
}
.move-btn:active { background: var(--bg); }
.move-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.move-name { font-weight: 700; font-size: 0.9rem; display: block; }
.move-meta { font-size: 0.7rem; color: var(--ink-soft); }
.move-eff { display: block; font-size: 0.7rem; font-weight: 700; margin-top: 2px; }
.move-eff.eff-super { color: #1f9d55; }
.move-eff.eff-good { color: #2f855a; }
.move-eff.eff-bad { color: #b45309; }
.move-eff.eff-none { color: var(--ink-soft); }

.action-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.action-row.three { grid-template-columns: repeat(3, 1fr); }

/* Node map — original geometric icons via CSS, no emoji */
.node-trail { display: flex; gap: 6px; overflow-x: auto; padding: 6px 2px 10px; margin-bottom: 6px; }
.node-dot {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.node-dot.boss { background: var(--gold); border-color: #b9822a; }

.node-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 2px solid rgba(0,0,0,0.08);
}
.node-icon svg { width: 20px; height: 20px; display: block; }
.node-icon.n-wild { background: #dcebd8; }
.node-icon.n-trainer { background: #f4dede; }
.node-icon.n-heal { background: #dcece6; }
.node-icon.n-shop { background: #f0e6cf; }
.node-icon.n-boss { background: var(--gold); }
.node-dot .node-icon-mini { width: 14px; height: 14px; }

.node-options { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.node-card {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
  touch-action: manipulation;
}
.node-card:active { background: var(--bg); }
.node-card:disabled { opacity: 0.45; cursor: not-allowed; }
.node-card .node-label { font-weight: 800; }
.node-card .node-desc { font-size: 0.78rem; color: var(--ink-soft); }

.party-strip { display: flex; gap: 8px; margin-bottom: 10px; overflow-x: auto; }
.party-chip { flex-shrink: 0; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 6px 8px; min-width: 96px; background: #fff; }
.party-chip[role="button"] { cursor: pointer; touch-action: manipulation; }
.party-chip.selected { border-color: var(--accent, #2f855a); box-shadow: 0 0 0 2px var(--accent, #2f855a); }
.party-chip .chip-name { font-weight: 700; font-size: 0.76rem; }
.party-chip.fainted { opacity: 0.5; }
.small { font-size: 0.78rem; }

.item-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fff;
}
.item-name { font-weight: 700; font-size: 0.9rem; }
.item-desc { font-size: 0.76rem; color: var(--ink-soft); }

.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.dex-item { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 8px; text-align: center; background: #fff; }
.dex-item.unseen { color: var(--ink-soft); }
.dex-name { font-size: 0.68rem; font-weight: 700; margin-top: 4px; }

.how-to-play { padding: 8px 4px 4px; border-top: 1px solid var(--border); }
.how-to-play h2 { margin-top: 0; }
.how-to-play h3 { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); }
.how-to-play h2 + h3 { margin-top: 16px; padding-top: 0; border-top: none; }
.how-to-play p, .how-to-play li { color: var(--ink-soft); }
.how-to-play p strong, .how-to-play li strong { color: var(--ink); }
.table-wrap { overflow-x: auto; margin: 10px 0 16px; }
table.type-chart-table { border-collapse: collapse; width: 100%; min-width: 760px; font-size: 0.78rem; background: #fff; }
table.type-chart-table caption { text-align: left; font-size: 0.76rem; color: var(--ink-soft); margin-bottom: 6px; }
table.type-chart-table th, table.type-chart-table td { border: 1px solid var(--border); padding: 4px 6px; text-align: center; }
table.type-chart-table thead th { background: var(--navy); color: #fff; }
table.type-chart-table tbody th { background: var(--bg); text-align: left; }

.site-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.78rem;
  padding: 18px 8px 4px;
  margin-top: 22px;
  border-top: 1px solid var(--border);
}
.site-footer .disclaimer { max-width: 52ch; margin: 6px auto 0; }
.site-footer a { color: var(--navy-soft); }

@media (min-width: 480px) {
  .move-grid { grid-template-columns: 1fr 1fr; }
  .btn { width: auto; }
}
