/* Critter Tactics: Roguelike — styles */

:root {
  --purple: #7c4dff;
  --purple-dark: #5a32c9;
  --teal: #14b8a6;
  --yellow: #ffd166;
  --bg: #fff8f0;
  --card-bg: #ffffff;
  --ink: #2d2140;
  --ink-soft: #5c5270;
  --danger: #e5484d;
  --success: #2fb380;
  --border: #e6dfff;

  --t-fuego: #f4622b;
  --t-agua: #2e86de;
  --t-planta: #3fa34d;
  --t-roca: #8d6e63;
  --t-aire: #3aa8a0;

  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

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

/* Display font reserved for game chrome: headings, buttons, labels.
   Body copy stays on the system stack for readability/restraint. */
h1, h2, h3, .screen-title,
.btn, .pill, .type-badge,
.node-label, .critter-name, .item-name, .chip-name, .move-name, .dex-name {
  font-family: 'Baloo 2', system-ui, sans-serif;
}

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

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

h1 {
  margin: 0 0 6px;
  font-size: clamp(1.5rem, 6vw, 2.1rem);
  font-weight: 800;
  color: var(--purple-dark);
  letter-spacing: 0.5px;
}

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

h2 { font-size: 1.3rem; font-weight: 800; color: var(--purple-dark); }
h3 { font-size: 1.05rem; font-weight: 700; color: var(--ink); margin-bottom: 6px; }

#game-app {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 1px 2px rgba(45, 33, 64, 0.05);
  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: 48px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--purple);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 3px 0 var(--purple-dark);
  width: 100%;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--purple-dark); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }

.btn-secondary { background: var(--teal); box-shadow: 0 3px 0 #0e8a7c; }
.btn-secondary:active { box-shadow: 0 1px 0 #0e8a7c; }

.btn-warn { background: var(--danger); box-shadow: 0 3px 0 #b8383b; }
.btn-warn:active { box-shadow: 0 1px 0 #b8383b; }

.btn-outline {
  background: #fff;
  color: var(--purple-dark);
  border: 2px solid var(--purple);
  box-shadow: none;
}

.btn-small { min-height: 40px; padding: 8px 12px; font-size: 0.85rem; }

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

/* Screens */
.screen-title { font-size: 1.25rem; font-weight: 800; color: var(--purple-dark); margin: 0 0 10px; text-align: center; }

/* Stat pill */
.pill {
  display: inline-block;
  background: var(--yellow);
  color: #5a4300;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 4px 10px;
  border-radius: 999px;
}

.meta-stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
/* Only the first stat (currency) gets the accent pill; the rest read as
   plain secondary stats so the row has one clear focal point, not three
   identical badges. */
.meta-stats .pill:nth-child(n+2) {
  background: transparent;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 0;
}

/* Critter card */
.critter-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  position: relative;
  overflow: hidden;
}
.critter-card.fainted { opacity: 0.5; filter: grayscale(0.6); }

.critter-top { display: flex; align-items: center; gap: 10px; }
.critter-emoji {
  font-size: 2.1rem;
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border-radius: 50%;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
}
.critter-info { flex: 1; min-width: 0; }
.critter-name { font-weight: 800; font-size: 1.02rem; }
.critter-sub { font-size: 0.78rem; color: var(--ink-soft); }

.type-badge {
  display: inline-block;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 2px;
}
.type-fuego { background: var(--t-fuego); }
.type-agua { background: var(--t-agua); }
.type-planta { background: var(--t-planta); }
.type-roca { background: var(--t-roca); }
.type-aire { background: var(--t-aire); }

.hp-bar-outer {
  height: 12px;
  background: #eee2ff;
  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(--yellow); }
.hp-bar-inner.low { background: var(--danger); }
.hp-text { font-size: 0.75rem; 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(124,77,255,0); }
  10% { transform: translateX(-4px) rotate(-3deg); }
  20% { transform: translateX(4px) rotate(3deg); box-shadow: 0 0 18px 4px rgba(124,77,255,0.55); }
  30% { transform: translateX(-4px) rotate(-3deg); }
  40% { transform: translateX(4px) rotate(3deg); box-shadow: 0 0 24px 6px rgba(20,184,166,0.55); }
  50% { transform: translateX(-3px) rotate(-2deg); }
  60% { transform: translateX(3px) rotate(2deg); box-shadow: 0 0 18px 4px rgba(255,209,102,0.6); }
  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(--purple); font-size: 0.85rem; }

.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.92rem; display: block; }
.move-meta { font-size: 0.72rem; 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 */
.node-trail {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 2px 10px;
  margin-bottom: 6px;
}
.node-dot {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem;
}
.node-dot.boss { background: var(--yellow); border-color: #d99a00; }

.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 .node-icon { font-size: 1.8rem; width: 44px; text-align: center; }
.node-card .node-label { font-weight: 800; }
.node-card .node-desc { font-size: 0.8rem; 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: 92px;
  background: #fff;
}
.party-chip .chip-name { font-weight: 700; font-size: 0.78rem; }
.party-chip.fainted { opacity: 0.5; }

/* Shop / list items */
.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.92rem; }
.item-desc { font-size: 0.78rem; color: var(--ink-soft); }

/* Dex grid */
.dex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 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-emoji { font-size: 1.6rem; }
.dex-name { font-size: 0.72rem; font-weight: 700; margin-top: 2px; }

/* How to play */
.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: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.how-to-play h2 + h3 { margin-top: 18px; 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 {
  border-collapse: collapse;
  width: 100%;
  min-width: 480px;
  font-size: 0.85rem;
  background: #fff;
}
table.type-chart caption { text-align: left; font-size: 0.78rem; color: var(--ink-soft); margin-bottom: 6px; }
table.type-chart th, table.type-chart td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: center;
}
table.type-chart thead th { background: var(--purple); color: #fff; }
table.type-chart tbody th { background: var(--bg); text-align: left; }

.site-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
  padding: 20px 8px 4px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
}

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