/* =========================================================================
   Profile Dex — cyberpunk cyberprofile styling.
   Palette from the game logo: navy #001b25/#031e28, steel #1d4456/#1b4254,
   sky #87b9cd/#72adc0, ice #ddf3fb, alert red #e2453b. Cyan neon accent.
   Colorblind-safe: every colour cue is paired with a text label or icon.
   ========================================================================= */
:root {
  --bg: #00131b;
  --bg-2: #031e28;
  --panel: #06222e;
  --panel-2: #0a2c3a;
  --steel: #1d4456;
  --steel-2: #1b4254;
  --line: #174155;
  --sky: #87b9cd;
  --ice: #ddf3fb;
  --neon: #46e8e0;
  --neon-dim: #2aa7a2;
  --alert: #e2453b;
  --gold: #f2c14e;
  --text: #cfe8f2;
  --muted: #6f9aab;
  --mono: "Consolas", "SFMono-Regular", "Courier New", monospace;
  --sans: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(70, 232, 224, 0.08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(226, 69, 59, 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
}
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: repeating-linear-gradient(180deg, rgba(70, 232, 224, 0.035) 0 1px, transparent 1px 3px);
  mix-blend-mode: screen;
}
.page { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 0 20px 60px; }

/* ---- Masthead ---- */
.masthead {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 0; margin-bottom: 8px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.masthead-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.masthead-logo { filter: drop-shadow(0 0 6px rgba(70, 232, 224, 0.5)); }
.home-link {
  font-family: var(--mono); font-weight: 700; letter-spacing: 0.32em;
  color: var(--neon); font-size: 18px; text-shadow: 0 0 10px rgba(70, 232, 224, 0.4);
}
.masthead-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.view-tab, .spoiler-toggle {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  background: transparent; color: var(--sky); border: 1px solid var(--line);
  padding: 7px 14px; cursor: pointer; clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.view-tab:hover, .spoiler-toggle:hover { border-color: var(--neon); color: var(--ice); }
.view-tab.active { border-color: var(--neon); color: var(--neon); background: rgba(70, 232, 224, 0.08); }
.spoiler-toggle[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.dashboard-link {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em;
  color: var(--muted); text-decoration: none; padding: 7px 10px;
}
.dashboard-link:hover { color: var(--neon); }

.loading { padding: 80px; text-align: center; color: var(--muted); font-family: var(--mono); }
.site-footer { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; font-family: var(--mono); }

/* ---- Toolbar ---- */
.dex-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 18px 0; }
.dex-search {
  flex: 1 1 240px; min-width: 200px;
  background: var(--panel); color: var(--ice); border: 1px solid var(--line);
  padding: 10px 14px; font-family: var(--mono); font-size: 13px;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.dex-search:focus { outline: none; border-color: var(--neon); box-shadow: 0 0 0 1px var(--neon); }
.dex-count { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--panel); color: var(--sky); border: 1px solid var(--line);
  padding: 6px 12px; cursor: pointer;
}
.chip:hover { border-color: var(--neon); color: var(--ice); }
.chip.active { background: rgba(70, 232, 224, 0.12); border-color: var(--neon); color: var(--neon); }
.chip .chip-n { color: var(--muted); margin-left: 6px; }

/* ---- Card grid ---- */
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.dossier-card {
  position: relative; text-align: left; cursor: pointer;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); color: var(--text);
  padding: 14px; display: flex; gap: 14px; align-items: center;
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
  transition: border-color 0.15s, transform 0.15s;
}
.dossier-card:hover { border-color: var(--neon); transform: translateY(-2px); }
.dossier-card:focus-visible { outline: 2px solid var(--neon); }
.card-portrait {
  width: 76px; height: 76px; flex: 0 0 76px; object-fit: cover; object-position: top center;
  background: var(--bg-2); border: 1px solid var(--neon-dim);
  image-rendering: auto;
}
.card-body { min-width: 0; flex: 1; }
.card-code { font-family: var(--mono); font-size: 16px; font-weight: 700; color: var(--ice); letter-spacing: 0.04em; }
.card-name { font-size: 13px; color: var(--sky); margin-top: 1px; }
.card-meta { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  border: 1px solid var(--line); color: var(--muted); padding: 2px 7px;
}
.tag-faction { border-color: var(--neon-dim); color: var(--sky); }
.tag-tier { border-color: var(--steel); color: var(--sky); }
.tag-companion { border-color: var(--gold); color: var(--gold); }
.tag-spoiler { border-color: var(--alert); color: var(--alert); }
.tag-ace { border-color: var(--neon-dim); color: var(--neon); }
.tag-noportrait { border-style: dashed; border-color: var(--muted); color: var(--muted); }
.portrait-filter { white-space: nowrap; }

.empty-state { padding: 60px; text-align: center; color: var(--muted); font-family: var(--mono); }

/* ---- Detail dossier ---- */
.dossier { max-width: 1080px; margin: 0 auto; }
.back-row { margin: 14px 0; }
.back-btn {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
  background: transparent; border: 1px solid var(--line); color: var(--sky); padding: 8px 14px; cursor: pointer;
}
.back-btn:hover { border-color: var(--neon); color: var(--neon); }

.id-card {
  position: relative; display: grid; grid-template-columns: 320px 1fr; gap: 0;
  background: linear-gradient(150deg, var(--panel-2), var(--bg-2));
  border: 1px solid var(--neon-dim);
  box-shadow: 0 0 0 1px rgba(70, 232, 224, 0.15), 0 0 40px rgba(70, 232, 224, 0.08) inset;
  clip-path: polygon(22px 0, 100% 0, 100% calc(100% - 22px), calc(100% - 22px) 100%, 0 100%, 0 22px);
}
.id-portrait-col { padding: 22px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.id-portrait-label { font-family: var(--mono); font-size: 12px; letter-spacing: 0.3em; color: var(--neon); text-align: center; }
.id-portrait-frame {
  position: relative; aspect-ratio: 1; background: var(--bg);
  border: 2px solid var(--neon); box-shadow: 0 0 18px rgba(70, 232, 224, 0.25);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.id-portrait-frame img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.id-portrait-frame .corner { position: absolute; width: 18px; height: 18px; border: 2px solid var(--neon); }
.id-portrait-frame .corner.tl { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.id-portrait-frame .corner.tr { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.id-portrait-frame .corner.bl { bottom: -1px; left: -1px; border-right: 0; border-top: 0; }
.id-portrait-frame .corner.br { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.emotion-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.emotion-btn {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--panel); border: 1px solid var(--line); color: var(--sky); padding: 3px 8px; cursor: pointer;
}
.emotion-btn:hover { border-color: var(--neon); color: var(--ice); }
.emotion-btn.active { border-color: var(--neon); color: var(--neon); background: rgba(70, 232, 224, 0.1); }
.outfit-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.outfit-row::before { content: "OUTFIT"; width: 100%; text-align: center; font-family: var(--mono); font-size: 9px; letter-spacing: 0.18em; color: var(--muted); }
.outfit-btn {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--panel); border: 1px solid var(--gold); color: var(--sky); padding: 3px 10px; cursor: pointer;
}
.outfit-btn:hover { color: var(--ice); }
.outfit-btn.active { border-color: var(--gold); color: var(--gold); background: rgba(242, 193, 78, 0.14); }

/* ---- Sort select ---- */
.sort-field { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.sort-field select {
  background: var(--panel); color: var(--ice); border: 1px solid var(--line); padding: 6px 8px;
  font-family: var(--mono); font-size: 12px;
}
.sort-field select:focus { outline: none; border-color: var(--neon); }

/* ---- Detail nav / action buttons ---- */
.detail-nav { display: flex; align-items: center; gap: 8px; margin: 14px 0; }
.nav-spacer { flex: 1; }
.nav-arrow {
  font-family: var(--mono); font-size: 14px; line-height: 1;
  background: transparent; border: 1px solid var(--line); color: var(--sky); padding: 8px 12px; cursor: pointer;
}
.nav-arrow:hover { border-color: var(--neon); color: var(--neon); }
.act-btn {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
  background: transparent; border: 1px solid var(--line); color: var(--sky); padding: 8px 12px; cursor: pointer;
}
.act-btn:hover { border-color: var(--neon); color: var(--neon); }

/* ---- Signature Ace sprite ---- */
.sprite { display: inline-block; background-repeat: no-repeat; background-position: 0 0; vertical-align: middle; image-rendering: auto; }
.ace-panel { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); text-align: center; }
.ace-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.24em; color: var(--neon); margin-bottom: 6px; }
.ace-art { min-height: 116px; display: flex; align-items: center; justify-content: center; }
.ace-name { font-family: var(--mono); font-size: 13px; color: var(--ice); margin-top: 4px; }
.ace-noart { width: 100px; height: 100px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--line); color: var(--muted); font-size: 28px; }

/* ---- Event mugshot codes / portrait-needed ---- */
.muted-note { color: var(--muted); font-size: 12px; margin: 0 0 10px; }
.code-list { display: flex; flex-direction: column; gap: 6px; }
.code-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text); padding: 7px 12px; cursor: pointer;
}
.code-row:hover { border-color: var(--neon); }
.code-emotion { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--sky); min-width: 74px; }
.code-row code { font-family: var(--mono); font-size: 12px; color: var(--neon); }
.portrait-needed .draw-hint { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.portrait-needed .draw-hint .k { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.portrait-needed code { font-family: var(--mono); color: var(--gold); }
.portrait-needed .code-row code { color: var(--gold); }

/* ---- Toast ---- */
.dex-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--neon); color: var(--ice);
  font-family: var(--mono); font-size: 13px; padding: 10px 18px; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 0 20px rgba(70, 232, 224, 0.2);
}
.dex-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.analyze-bar { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em; color: var(--neon-dim); }
.analyze-bar .bar { flex: 1; height: 2px; background: linear-gradient(90deg, var(--neon), transparent); }

.id-data-col { padding: 24px 26px; min-width: 0; }
.id-heading { font-family: var(--mono); font-size: 12px; letter-spacing: 0.28em; color: var(--sky); }
.id-code { font-family: var(--mono); font-size: 30px; font-weight: 700; color: var(--neon); letter-spacing: 0.03em; text-shadow: 0 0 14px rgba(70, 232, 224, 0.35); line-height: 1.1; margin: 2px 0 2px; }
.id-realname { font-size: 15px; color: var(--ice); margin-bottom: 14px; }
.id-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.id-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.id-field { display: flex; flex-direction: column; gap: 2px; border-bottom: 1px dotted var(--line); padding-bottom: 6px; }
.id-field.wide { grid-column: 1 / -1; }
.id-field .k { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.id-field .v { font-size: 14px; color: var(--ice); }

/* ---- Sections ---- */
.dossier-sections { margin-top: 22px; display: grid; gap: 16px; }
.section-card {
  background: var(--panel); border: 1px solid var(--line);
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
}
.section-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--neon);
}
.section-head .mark { color: var(--neon-dim); }
.section-body { padding: 14px 16px; white-space: pre-wrap; line-height: 1.55; color: var(--text); font-size: 14px; }
.theme-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; color: var(--neon); font-family: var(--mono); font-size: 13px; text-decoration: none; }
.theme-link:hover { text-decoration: underline; }

/* ---- Spoiler masking ---- */
.spoiler-mask { position: relative; }
.spoiler-mask .spoiler-content { filter: blur(7px); user-select: none; }
.spoiler-cover {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: rgba(3, 30, 40, 0.75); cursor: pointer;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--alert);
  border: 1px dashed var(--alert);
}
.spoiler-cover:hover { background: rgba(3, 30, 40, 0.6); color: var(--ice); }

/* ---- Hierarchy ---- */
.hierarchy-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-top: 18px; }
.faction-col { background: var(--panel); border: 1px solid var(--neon-dim); clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px); }
.faction-title { padding: 14px 16px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-weight: 700; letter-spacing: 0.06em; color: var(--neon); }
.faction-title .sub { display: block; font-weight: 400; font-size: 11px; letter-spacing: 0.1em; color: var(--muted); margin-top: 3px; }
.tier-block { padding: 10px 16px; border-bottom: 1px solid rgba(23, 65, 85, 0.5); }
.tier-block:last-child { border-bottom: 0; }
.tier-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--sky); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.tier-label::before { content: "▸"; color: var(--neon-dim); }
.tier-members { display: flex; flex-wrap: wrap; gap: 6px; }
.member {
  font-family: var(--mono); font-size: 12px; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line); padding: 4px 10px;
}
.member.link { cursor: pointer; border-color: var(--neon-dim); color: var(--ice); }
.member.link:hover { border-color: var(--neon); color: var(--neon); }

@media (max-width: 720px) {
  .id-card { grid-template-columns: 1fr; }
  .id-portrait-col { border-right: 0; border-bottom: 1px solid var(--line); }
  .id-fields { grid-template-columns: 1fr; }
}

/* ===== Showcase (clean public view) ===== */
body.showcase .dev-only, body.showcase .dev-panel { display: none !important; }

/* ===== Ace -> Pokédex link ===== */
.ace-link { display: inline-flex; flex-direction: column; align-items: center; gap: 5px; text-decoration: none; }
.ace-go { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; color: var(--neon-dim); }
.ace-link:hover .ace-go { color: var(--neon); }
.ace-link:hover .sprite { filter: drop-shadow(0 0 9px rgba(70, 232, 224, 0.55)); }

/* ===== Export card button accent ===== */
.act-accent { border-color: var(--neon-dim); color: var(--neon); }
.act-accent:hover { border-color: var(--neon); background: rgba(70, 232, 224, 0.12); }

/* ===== Cyberpunk motion polish (decorative, reduced-motion safe) ===== */
@keyframes neon-flicker { 0%, 18%, 22%, 100% { opacity: 1; } 20% { opacity: 0.74; } 21% { opacity: 1; } }
@keyframes bar-slide { from { transform: translateX(-60%); } to { transform: translateX(320%); } }
.home-link { animation: neon-flicker 7s infinite steps(1); }
.id-code { animation: neon-flicker 9s infinite steps(1); }
.analyze-bar .bar { position: relative; overflow: hidden; }
.analyze-bar .bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 30%; background: var(--neon); box-shadow: 0 0 8px var(--neon); animation: bar-slide 2.4s linear infinite; }
.dossier-card { transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s; }
.dossier-card:hover { box-shadow: 0 0 20px rgba(70, 232, 224, 0.16); }
.id-portrait-frame:hover { box-shadow: 0 0 26px rgba(70, 232, 224, 0.35); }
@media (prefers-reduced-motion: reduce) { .home-link, .id-code, .analyze-bar .bar::after { animation: none; } }

/* ===== Signature team ===== */
.section-head .team-card-btn { margin-left: auto; padding: 4px 10px; font-size: 11px; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.team-mon { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 5px; padding: 12px 8px; border: 1px solid var(--line); background: var(--bg-2); text-decoration: none; color: var(--text); }
a.team-mon:hover { border-color: var(--neon); }
a.team-mon:hover .sprite { filter: drop-shadow(0 0 8px rgba(70, 232, 224, 0.5)); }
.team-role { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--neon); }
.team-name { font-size: 13px; color: var(--ice); font-weight: 600; }
.team-note { font-size: 11px; color: var(--muted); line-height: 1.35; }
.team-noart { width: 92px; height: 92px; font-size: 30px; }

/* ===== Faction roster poster button ===== */
.faction-title { position: relative; }
.poster-btn { position: absolute; top: 12px; right: 12px; padding: 4px 10px; font-size: 11px; }
