*{box-sizing:border-box}
:root{
  --bg:#0a1428;
  --fg:#e8f4f8;
  --muted:#8ba8c0;
  --card:#1a2940;
  --accent:#4a9eff;
  --accent-glow:#6bb4ff;
  --emerald:#48d597;
  --ruby:#e74c3c;
}

html,body{
  margin:0;
  padding:0;
  background: #0b1628;
  color:var(--fg);
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,'Helvetica Neue',Arial;
  position: relative;
}

/* ── Pokéball shadow background ───────────────────────── */
.bg-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 20% 15%, rgba(74,158,255,0.08) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 75%, rgba(72,213,151,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 55% 40%, rgba(231,76,60,0.04) 0%, transparent 50%),
    linear-gradient(160deg, #0b1628 0%, #0f2440 35%, #0d2a30 60%, #12203a 85%, #0b1628 100%);
}

.bg-pokeballs {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Vignette overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,0.45) 100%);
  pointer-events: none;
  z-index: 1;
}

.container{
  max-width:1100px;
  margin:0 auto;
  padding:1rem 1.25rem;
  position: relative;
  z-index: 2;
}

.grid{display:grid;grid-template-columns:1fr 1fr 1fr;gap:1rem}
@media (max-width:1100px){.grid{grid-template-columns:1fr}}

h1,h2{
  margin:.25rem 0 1rem 0;
  color: var(--accent-glow);
  text-shadow: 0 0 20px rgba(74, 158, 255, 0.4);
}

h1 {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--fg);
  /* stronger glow + subtle colored rim to make it pop */
  text-shadow: 0 6px 22px rgba(0,0,0,0.65),
               0 0 12px rgba(74,158,255,0.22),
               0 0 6px rgba(72,213,151,0.08);
  letter-spacing: 0.4px;
}

.muted{color:var(--muted)}

.card{
  background: rgba(26, 41, 64, 0.85);
  border: 1px solid rgba(74, 158, 255, 0.3);
  border-radius:16px;
  padding:1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 
              0 0 0 1px rgba(72, 213, 151, 0.1) inset,
              0 4px 16px rgba(74, 158, 255, 0.2);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 2;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    rgba(231, 76, 60, 0.3), 
    rgba(74, 158, 255, 0.5), 
    rgba(72, 213, 151, 0.4), 
    transparent);
}

.row{display:flex;gap:.75rem;align-items:center;margin:.5rem 0}

/* Species sprite */
.species-sprite {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  -ms-interpolation-mode: nearest-neighbor;
  object-fit: contain;
  flex-shrink: 0;
  display: none;
}
.species-sprite.visible {
  display: block;
}
.row.six>div{flex:1;min-width:100px}
label{min-width:140px;color:var(--accent-glow)}

input,select,button,textarea{
  background: rgba(10, 20, 40, 0.6);
  color:var(--fg);
  border: 1px solid rgba(74, 158, 255, 0.3);
  border-radius:10px;
  padding:.6rem .75rem;
  transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(72, 213, 151, 0.2);
  background: rgba(10, 20, 40, 0.8);
}

.moves select{display:block;margin:.25rem 0}

/* ── Field sizing: compact inputs instead of full-width stretch ── */
.row > select { width: auto; min-width: 140px; }
.row > input[type="number"] { width: 100px; }
.row > input[type="text"] { width: 200px; }
#pid { width: 160px; }

/* Grid cells (IVs / EVs) fill their column */
.grid input[type="number"] { width: 100%; }

/* TID / SID paired row */
.row.two > div { flex: 0 0 auto; width: 160px; }
.row.two > div input[type="number"] { width: 100%; }
#output{width:100%;font-family:ui-monospace,Menlo,Consolas,monospace}
#hexOutput{width:100%;font-family:ui-monospace,Menlo,Consolas,monospace;height:200px;resize:none}

button{
  cursor:pointer;
  background: linear-gradient(135deg, rgba(74, 158, 255, 0.2), rgba(72, 213, 151, 0.2));
  border-color: rgba(74, 158, 255, 0.5);
  font-weight: 500;
  transition: all 0.2s ease;
}

button:hover{
  border-color: var(--emerald);
  background: linear-gradient(135deg, rgba(74, 158, 255, 0.3), rgba(72, 213, 151, 0.3));
  box-shadow: 0 0 20px rgba(72, 213, 151, 0.3);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

details{margin-top:.5rem}
pre{white-space:pre-wrap;word-break:break-word}
.copy-check{color:#4ade80;font-size:0.875rem;margin-top:0.25rem;opacity:0;transition:opacity 0.3s ease}
.copy-check.show{opacity:1}

/* Profanity warning banner above Base64 output */
.profanity-warning{
  background:#422006;
  color:#fbbf24;
  border:1px solid #92400e;
  border-radius:0.375rem;
  padding:0.5rem 0.75rem;
  margin-bottom:0.5rem;
  font-size:0.85rem;
  line-height:1.4;
}

/* ── PID Finder ──────────────────────────────────────── */

/* Show the button row only when wild encounter is active */
.wild-only { display: none; }
body.encounter-wild .wild-only { display: flex; }
.wild-or-legend { display: none; }
body.encounter-wild .wild-or-legend,
body.encounter-static .wild-or-legend,
body.encounter-cxd_shadow .wild-or-legend,
body.encounter-roamer .wild-or-legend { display: flex; }

/* Hide the external Shiny checkbox row when PID Finder is available */
body.encounter-wild .shiny-external,
body.encounter-static .shiny-external,
body.encounter-cxd_shadow .shiny-external,
body.encounter-roamer .shiny-external { display: none; }

.pid-finder-btn {
  font-size: 0.9rem;
  padding: 0.5rem 1.1rem;
  white-space: nowrap;
}

.pid-finder-status {
  font-size: 0.85rem;
  color: var(--emerald);
  margin-left: 0.5rem;
}

.make-shiny-btn {
  font-size: 0.9rem;
  padding: 0.5rem 1.1rem;
  white-space: nowrap;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff;
  border: none;
  border-radius: 0.4rem;
  cursor: pointer;
  transition: filter 0.15s, box-shadow 0.15s;
}
.make-shiny-btn:hover {
  filter: brightness(1.12);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.45);
}
.make-shiny-btn.is-shiny {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.make-shiny-btn.is-shiny:hover {
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.45);
}

.make-shiny-status {
  font-size: 0.82rem;
  margin-left: 0.5rem;
  color: var(--text-muted, #94a3b8);
}

/* Overlay */
.pid-finder-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.pid-finder-overlay.open { display: flex; }

/* Modal card */
.pid-finder-modal {
  background: var(--card);
  border: 1px solid rgba(74, 158, 255, 0.4);
  border-radius: 16px;
  max-width: 920px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6),
              0 0 0 1px rgba(72,213,151,0.1) inset;
  color: var(--fg);
  animation: pfSlideIn .2s ease;
}
@keyframes pfSlideIn { from { opacity:0; transform:translateY(-18px); } to { opacity:1; transform:translateY(0); } }

.pid-finder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(74, 158, 255, 0.2);
}
.pid-finder-header h3 {
  margin: 0;
  color: var(--accent-glow);
  font-size: 1.15rem;
}
.pid-finder-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}
.pid-finder-close:hover { color: var(--ruby); }

.pid-finder-body { padding: 1.25rem; }

/* Summary chips */
.pid-finder-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(10,20,40,0.4);
  border-radius: 10px;
  border: 1px solid rgba(74,158,255,0.15);
}
.pf-tag { color: var(--muted); }
.pf-tag b { color: var(--fg); font-weight: 600; }

/* IV minimums grid */
.pid-finder-iv-section { margin-bottom: 1rem; }
.pid-finder-label {
  display: block;
  color: var(--accent-glow);
  font-weight: 500;
  margin-bottom: 0.5rem;
  min-width: auto;
}
.pid-finder-iv-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
}
.pid-finder-iv-grid div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.pid-finder-iv-grid label {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: auto;
  text-align: center;
}
.pid-finder-iv-grid input {
  text-align: center;
  padding: 0.4rem;
  width: 100%;
}

/* Method checkboxes */
.pid-finder-methods {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.pid-finder-methods label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: auto;
  color: var(--fg);
  cursor: pointer;
}

/* Controls + progress */
.pid-finder-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.pid-finder-controls button { padding: 0.5rem 1.25rem; white-space: nowrap; }
.pid-finder-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 180px;
}
.pid-finder-progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(10,20,40,0.6);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(74,158,255,0.2);
}
.pid-finder-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--emerald));
  border-radius: 4px;
  transition: width 0.3s ease;
}
#pfProgressText {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 80px;
  text-align: right;
}

/* Results */
.pid-finder-result-count {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.pid-finder-results-scroll {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid rgba(74,158,255,0.15);
  border-radius: 10px;
}
.pid-finder-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.pid-finder-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}
.pid-finder-table th {
  background: rgba(10,20,40,0.95);
  padding: 0.5rem 0.4rem;
  text-align: center;
  color: var(--accent-glow);
  font-weight: 600;
  font-size: 0.8rem;
  border-bottom: 1px solid rgba(74,158,255,0.3);
  white-space: nowrap;
}
.pid-finder-table td {
  padding: 0.4rem;
  text-align: center;
  border-bottom: 1px solid rgba(74,158,255,0.08);
  white-space: nowrap;
}
.pid-finder-table tr:hover td { background: rgba(74,158,255,0.08); }
.pid-finder-table .pid-cell {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}
.pid-finder-table .iv-perfect { color: var(--emerald); font-weight: 600; }
.pid-finder-table .iv-zero    { color: var(--ruby);    font-weight: 600; }
.pid-finder-table .select-btn {
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
}

@media (max-width: 700px) {
  .pid-finder-iv-grid { grid-template-columns: repeat(3, 1fr); }
  .pid-finder-modal   { margin: 0.5rem; }
}
