:root {
  --poke-red: #e3350d;
  --poke-yellow: #ffcb05;
  --poke-blue: #3b4cca;
  --bg: #1c1c28;
  --card-bg: #262637;
  --text: #f2f2f2;
  --muted: #9a9ab0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

/* ---------- login ---------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #2b2b45, #101018);
}

.login-card {
  background: var(--card-bg);
  padding: 2.5rem;
  border-radius: 16px;
  text-align: center;
  width: 320px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.pokeball {
  width: 60px;
  height: 60px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: linear-gradient(var(--poke-red) 0 48%, #111 48% 52%, #fff 52% 100%);
  border: 3px solid #111;
  position: relative;
  animation: spin 3s linear infinite;
}
.pokeball::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 16px; height: 16px;
  background: #fff;
  border: 3px solid #111;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
@keyframes spin { to { transform: rotate(360deg); } }

.subtitle { color: var(--muted); margin-top: -0.5rem; margin-bottom: 1.5rem; }

#login-form { display: flex; flex-direction: column; gap: 0.75rem; }

input, select, button {
  font: inherit;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border: 1px solid #3a3a52;
  background: #1c1c28;
  color: var(--text);
}

button {
  background: var(--poke-red);
  border: none;
  color: white;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s ease;
}
button:hover { transform: translateY(-1px); filter: brightness(1.1); }
button.secondary { background: var(--poke-blue); }
button.danger { background: #444; }

.error { color: #ff6b6b; }

/* ---------- dashboard ---------- */

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: linear-gradient(90deg, var(--poke-red), #b8280a);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  position: relative;
  z-index: 2;
}
header.topbar h1 { margin: 0; font-size: 1.3rem; }
header.topbar .who { color: #ffe1d6; font-size: 0.9rem; }

/* ---------- environment / terrain ---------- */

body {
  transition: background 1.2s ease;
  background-size: 400% 400%;
  animation: env-bg-shift 20s ease infinite;
}
body[data-env="forest"]  { background-image: linear-gradient(120deg, #1e3b1a, #2f5c24, #16321b); }
body[data-env="cave"]    { background-image: linear-gradient(120deg, #2a2a2e, #3d3d46, #1a1a1e); }
body[data-env="water"]   { background-image: linear-gradient(120deg, #0d3b52, #146b8c, #0a2d40); }
body[data-env="volcano"] { background-image: linear-gradient(120deg, #4a1408, #7a2609, #2a0c04); }
body[data-env="storm"]   { background-image: linear-gradient(120deg, #23233a, #3a3a5c, #17172a); }
body[data-env="snow"]    { background-image: linear-gradient(120deg, #2c3b47, #4a6b7c, #1c2830); }
body[data-env="psychic"] { background-image: linear-gradient(120deg, #3a1a4a, #5c2c74, #24102f); }

@keyframes env-bg-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.env-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(2px);
  position: relative;
  z-index: 2;
}
.env-icon { font-size: 1.2rem; animation: env-icon-pulse 3s ease-in-out infinite; }
@keyframes env-icon-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.env-picker { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; margin-top: 0.75rem; }
.env-picker select { padding: 0.25rem 0.5rem; }

.env-particles {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
.env-particles span {
  position: absolute;
  top: -2rem;
  animation-name: env-particle-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  opacity: 0.75;
}
@keyframes env-particle-fall {
  0% { transform: translateY(-2rem) rotate(0deg); }
  100% { transform: translateY(110vh) rotate(360deg); }
}

.terrain-boost { box-shadow: 0 0 0 2px var(--poke-yellow), 0 0 16px rgba(255, 203, 5, 0.5); }
.terrain-tag { font-size: 0.7rem; color: var(--poke-yellow); font-weight: bold; margin: 0.15rem 0; }

.battle-banner {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 0.7rem;
  overflow: hidden;
  background: linear-gradient(90deg, #7a0d0d, #b8280a, #7a0d0d);
  background-size: 200% 100%;
  animation: battle-sweep 2.5s linear infinite;
  box-shadow: 0 0 24px rgba(227, 53, 13, 0.6), inset 0 0 20px rgba(0, 0, 0, 0.4);
  border-top: 2px solid var(--poke-yellow);
  border-bottom: 2px solid var(--poke-yellow);
}
.battle-banner-text {
  display: inline-block;
  color: var(--poke-yellow);
  font-weight: bold;
  font-size: 1.1rem;
  letter-spacing: 2px;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
  animation: battle-pulse 1s ease-in-out infinite;
}
@keyframes battle-sweep {
  0% { background-position: 0% 0; }
  100% { background-position: -200% 0; }
}
@keyframes battle-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

main { max-width: 1000px; margin: 0 auto; padding: 1.5rem; position: relative; z-index: 2; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.tabs button { background: #33334a; color: var(--muted); }
.tabs button.active { background: var(--poke-blue); color: white; }

.section-title {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 1.5rem 0 0.75rem;
}

.pokemon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}

.pokemon-card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 6px 18px rgba(0,0,0,0.3);
}
.pokemon-card img { width: 96px; height: 96px; display: block; margin: 0 auto; image-rendering: pixelated; }
.pokemon-card h3 { margin: 0.25rem 0 0; text-align: center; }
.pokemon-card .level { text-align: center; color: var(--muted); font-size: 0.85rem; margin-bottom: 0.5rem; }

.bar { height: 10px; border-radius: 6px; background: #111; overflow: hidden; margin-bottom: 0.35rem; }
.bar-fill { height: 100%; transition: width 0.4s ease; }
.bar-fill.hp { background: linear-gradient(90deg, #33d17a, #7bed9f); }
.bar-fill.hp.low { background: linear-gradient(90deg, #e3350d, #ff8c69); }
.bar-fill.xp { background: linear-gradient(90deg, var(--poke-yellow), #ffe27a); }

.bar-label { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); }

.status-tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  background: #3a3a52;
  margin: 0.25rem 0;
}
.status-tag.status-poisoned { background: #7a3fa0; }
.status-tag.status-asleep { background: #4a5568; }
.status-tag.status-paralyzed { background: #b7a800; color: #111; }
.status-tag.status-burned { background: #b8280a; }

.moves { list-style: none; padding: 0; margin: 0.5rem 0; font-size: 0.8rem; color: var(--muted); }
.moves li { display: flex; align-items: center; gap: 0.3rem; margin: 0.2rem 0; }
.moves button { font-size: 0.7rem; padding: 0.15rem 0.4rem; }

.hint { font-size: 0.75rem; color: var(--muted); margin: 0.3rem 0 0; }

.admin-controls { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.admin-controls button, .admin-controls select { font-size: 0.75rem; padding: 0.35rem 0.5rem; }

.side-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1.5rem; }
@media (max-width: 700px) { .side-columns { grid-template-columns: 1fr; } }

.chip-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.chip button { padding: 0 0.3rem; background: transparent; color: var(--muted); font-size: 0.9rem; }

.inline-form { display: flex; gap: 0.4rem; margin-top: 0.75rem; flex-wrap: wrap; }
.inline-form input { width: 90px; }

/* ---------- battle encounter ---------- */

#encounter-section {
  background: rgba(20, 10, 10, 0.35);
  border: 1px solid rgba(227, 53, 13, 0.4);
  border-radius: 14px;
  padding: 1rem 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 0 24px rgba(227, 53, 13, 0.15) inset;
}
#encounter-section .section-title { margin-top: 0; }

.encounter-admin { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.toggle { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--muted); }
.toggle input { width: auto; }

.opponent-card { border: 1px solid rgba(227, 53, 13, 0.5); }
.opponent-card.secret { border-style: dashed; }
.mystery-silhouette {
  width: 96px;
  height: 96px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  background: radial-gradient(circle, #333 0%, #111 100%);
  border-radius: 50%;
  animation: mystery-bob 2s ease-in-out infinite;
}
@keyframes mystery-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.bar-fill.hp-hidden {
  background: repeating-linear-gradient(45deg, #444, #444 8px, #333 8px, #333 16px);
}

.battle-log { margin-top: 1rem; }
.battle-log ul { list-style: none; padding: 0; margin: 0; max-height: 220px; overflow-y: auto; font-size: 0.85rem; }
.battle-log li { padding: 0.3rem 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.05); }
.battle-log .log-time { color: var(--muted); font-size: 0.7rem; margin-right: 0.5rem; }

/* ---------- damage / heal flash ---------- */

#flash-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0;
}
#flash-overlay.flash-damage { animation: flashRed 0.5s ease-out; }
#flash-overlay.flash-heal { animation: flashGreen 0.5s ease-out; }
@keyframes flashRed {
  0% { background: rgba(227, 53, 13, 0.55); opacity: 1; }
  100% { background: rgba(227, 53, 13, 0); opacity: 0; }
}
@keyframes flashGreen {
  0% { background: rgba(51, 209, 122, 0.45); opacity: 1; }
  100% { background: rgba(51, 209, 122, 0); opacity: 0; }
}
