/* DigiCatch Online v0.1.0 — mobile-first portrait, fullscreen cover */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0b1026;
  --bg2: #141b3d;
  --card: #1a2247;
  --card2: #222c5c;
  --line: #2f3a6e;
  --text: #eef2ff;
  --muted: #9aa7d8;
  --accent: #38e1ff;
  --accent2: #7c5cff;
  --gold: #ffd23f;
  --green: #4ade80;
  --red: #f87171;
  --danger: #dc2626;
  --radius: 14px;
}
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
#app {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #0b1026 0%, #101736 55%, #0b1026 100%);
  position: relative;
}
body.no-game #hud, body.no-game #tabbar { display: none; }

/* ---------- HUD ---------- */
#hud {
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  background: rgba(11, 16, 38, .95);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.hud-left { min-width: 0; }
#hud-tamer { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
#hud-sub { font-size: 11px; color: var(--muted); }
.hud-mid { display: flex; gap: 6px; flex: 1; justify-content: center; flex-wrap: wrap; }
.hud-pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; font-size: 12px; white-space: nowrap; }
.hud-right { display: flex; align-items: center; gap: 6px; }
.hud-btn {
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; min-width: 38px; height: 32px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.hud-btn.active { background: var(--accent2); border-color: var(--accent2); }
.hud-ver { font-size: 10px; color: var(--muted); font-weight: 700; }

/* ---------- Screens ---------- */
#screens { flex: 1; display: flex; flex-direction: column; }
.screen { display: none; padding: 14px 14px 20px; animation: fadein .18s ease; }
.screen.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.screen-title { font-size: 21px; font-weight: 800; margin-bottom: 4px; }
.screen-sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.section-head { font-size: 15px; font-weight: 700; margin: 16px 0 8px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 10px; }
.disclaimer { color: var(--muted); font-size: 11px; margin-top: 18px; line-height: 1.5; }

/* ---------- Buttons / inputs ---------- */
.btn {
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 11px; padding: 10px 14px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent2), #2f9dff); border-color: transparent; }
.btn-big { width: 100%; padding: 14px; font-size: 16px; margin-top: 10px; }
.btn-small { padding: 6px 10px; font-size: 12px; }
.btn-block { display: block; width: 100%; margin-top: 8px; text-align: left; }
.btn-danger { background: #3f1016; border-color: var(--danger); color: #fca5a5; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.field-label { display: block; font-weight: 700; margin: 16px 0 6px; }
input[type="text"], select {
  width: 100%; background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px;
  font-size: 15px; font-family: inherit;
}
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent2); }

/* ---------- Title / starter ---------- */
.title-wrap { text-align: center; padding-top: 34px; }
.title-logo {
  font-size: 40px; font-weight: 900; letter-spacing: 1px;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.title-sub { color: var(--muted); font-weight: 700; letter-spacing: 3px; margin-top: 2px; }
.title-tag { margin: 18px 0 8px; font-size: 15px; }
.title-art { font-size: 44px; letter-spacing: 6px; margin: 14px 0 6px; }
.title-wrap .disclaimer { text-align: left; }
.starter-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.starter-card {
  display: flex; gap: 12px; align-items: center; text-align: left;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 10px; cursor: pointer; width: 100%; color: var(--text); font-family: inherit;
}
.starter-card.selected { border-color: var(--accent); background: var(--card2); box-shadow: 0 0 0 2px var(--accent) inset; }
.starter-card img { width: 84px; height: 84px; object-fit: contain; }
.starter-card .sc-name { font-weight: 800; font-size: 17px; }
.starter-card .sc-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.starter-card .sc-line { font-size: 12px; margin-top: 4px; color: var(--accent); }

/* ---------- Battle ---------- */
.chapter-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.chapter-info { flex: 1; min-width: 0; }
#chapter-name { font-weight: 800; font-size: 15px; }
#chapter-step { font-size: 12px; color: var(--muted); }
.chapter-progress { flex: 1.4; height: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
#chapter-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .4s ease; }
.loop-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 10px; cursor: pointer; }

#arena {
  position: relative; background: radial-gradient(120% 100% at 50% 0%, #1d2a63 0%, var(--bg2) 60%, #0d1330 100%);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 12px 12px; overflow: hidden;
}
.fighter-area { display: flex; gap: 12px; align-items: center; }
#enemy-area { flex-direction: row-reverse; text-align: right; }
.sprite-wrap { position: relative; flex-shrink: 0; width: 118px; height: 118px; display: flex; align-items: center; justify-content: center; }
.sprite { width: 112px; height: 112px; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0,0,0,.5)); }
.sprite.small { width: 64px; height: 64px; }
.bob { animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.sprite.hit { animation: hitflash .18s ease; }
@keyframes hitflash { 0% { filter: brightness(2.4) saturate(0); } 100% { filter: brightness(1); } }
.sprite.gold { filter: sepia(1) saturate(4) hue-rotate(-12deg) brightness(1.15) drop-shadow(0 0 14px rgba(255,210,63,.9)); }
.gold-badge {
  position: absolute; top: 0; right: 0; background: var(--gold); color: #3a2b00;
  font-size: 11px; font-weight: 900; border-radius: 999px; padding: 2px 8px;
}
.fighter-info { flex: 1; min-width: 0; }
.fighter-name { font-weight: 800; font-size: 16px; }
.lv-badge { background: var(--card2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.fighter-tags { margin: 5px 0 7px; display: flex; gap: 5px; flex-wrap: wrap; }
#enemy-area .fighter-tags { justify-content: flex-end; }
.tag { font-size: 11px; font-weight: 700; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.tag.attr-Vaccine { color: #7dd3fc; border-color: #38bdf8; }
.tag.attr-Virus { color: #f0abfc; border-color: #c084fc; }
.tag.attr-Data { color: #86efac; border-color: #4ade80; }
.tag.attr-Free { color: #d6d3d1; }
.hpbar, .xpbar { position: relative; height: 16px; background: #0a0e24; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.xpbar { height: 7px; margin-top: 5px; }
.hp-fill { height: 100%; background: linear-gradient(90deg, #22c55e, #4ade80); transition: width .3s ease; }
.hp-fill.low { background: linear-gradient(90deg, #ef4444, #f87171); }
.hp-fill.mid { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.xp-fill { height: 100%; background: var(--accent); transition: width .3s ease; }
.hp-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; text-shadow: 0 1px 2px #000; }
#vs-line { text-align: center; font-size: 13px; color: var(--muted); padding: 8px 0; }
.party-chips { display: flex; gap: 8px; margin-top: 10px; }
.party-chip {
  flex: 1; display: flex; align-items: center; gap: 6px; background: var(--card);
  border: 2px solid var(--line); border-radius: 11px; padding: 5px 7px; cursor: pointer;
  color: var(--text); font-family: inherit; font-size: 11px; min-width: 0;
}
.party-chip.active { border-color: var(--accent); }
.party-chip.fainted { opacity: .45; }
.party-chip img { width: 34px; height: 34px; object-fit: contain; flex-shrink: 0; }
.party-chip .pc-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.party-chip .pc-hp { color: var(--muted); }
.battle-log { background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 8px 10px; margin-top: 10px; font-size: 12px; min-height: 56px; color: var(--muted); }
.battle-log div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.battle-log div:last-child { color: var(--text); }
.battle-actions { display: flex; gap: 8px; margin-top: 10px; }
.battle-actions .btn { flex: 1; }

/* floating damage numbers */
#float-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.dmg-float {
  position: absolute; font-weight: 900; font-size: 22px; color: #fff;
  text-shadow: 0 2px 0 #000, 0 0 10px rgba(0,0,0,.6);
  animation: floatup .8s ease-out forwards; white-space: nowrap;
}
.dmg-float.super { color: var(--gold); font-size: 25px; }
.dmg-float.weak { color: #cbd5e1; font-size: 17px; }
.dmg-float.heal { color: var(--green); }
.dmg-float .eff { display: block; font-size: 11px; text-align: center; }
@keyframes floatup { 0% { opacity: 0; transform: translateY(8px); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateY(-46px); } }

/* ---------- Team / lists ---------- */
.team-actions { display: flex; flex-direction: column; gap: 8px; }
.mon-list { display: flex; flex-direction: column; gap: 8px; }
.mon-card {
  display: flex; gap: 10px; align-items: center; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 9px; text-align: left;
  width: 100%; color: var(--text); font-family: inherit; cursor: pointer;
}
.mon-card img { width: 62px; height: 62px; object-fit: contain; flex-shrink: 0; }
.mon-card .mc-body { flex: 1; min-width: 0; }
.mon-card .mc-name { font-weight: 800; font-size: 15px; }
.mon-card .mc-meta { font-size: 12px; color: var(--muted); margin: 2px 0 5px; }
.mon-card .mc-actions { display: flex; gap: 6px; flex-shrink: 0; }
.empty-note { color: var(--muted); font-size: 13px; padding: 10px 4px; }

/* ---------- Dex ---------- */
.dex-filters { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.dex-filter.active { background: var(--accent2); border-color: var(--accent2); }
.dex-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dex-cell {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 4px 6px; text-align: center; cursor: pointer; color: var(--text); font-family: inherit;
}
.dex-cell img { width: 64px; height: 64px; object-fit: contain; }
.dex-cell .dc-name { font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dex-cell .dc-stage { font-size: 10px; color: var(--muted); }
.dex-cell.seen img { filter: brightness(0); }
.dex-cell.unseen { opacity: .55; }

/* ---------- Shop ---------- */
.shop-list { display: flex; flex-direction: column; gap: 10px; }
.shop-item {
  display: flex; gap: 12px; align-items: center; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
}
.shop-item .si-icon { font-size: 34px; }
.shop-item .si-body { flex: 1; }
.shop-item .si-name { font-weight: 800; }
.shop-item .si-desc { font-size: 12px; color: var(--muted); }
.shop-item .si-owned { font-size: 12px; color: var(--accent); margin-top: 2px; }

/* ---------- Options ---------- */
.opt-group { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.opt-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.opt-row:last-child { border-bottom: 0; }
.opt-row select { width: auto; min-width: 130px; }
.selftest { font-weight: 700; }
.selftest-list { list-style: none; margin-top: 8px; font-size: 12px; color: var(--muted); }
.selftest-list li.pass { color: var(--green); }
.selftest-list li.fail { color: var(--red); font-weight: 700; }
.about { font-size: 13px; color: var(--muted); }

/* ---------- Tab bar ---------- */
#tabbar {
  display: flex; border-top: 1px solid var(--line); background: rgba(11, 16, 38, .97);
  padding-bottom: env(safe-area-inset-bottom); position: sticky; bottom: 0; z-index: 50;
}
.tab {
  flex: 1; background: none; border: 0; color: var(--muted); font-family: inherit;
  font-size: 20px; padding: 8px 0 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.tab span { font-size: 10px; font-weight: 700; }
.tab.active { color: var(--accent); }

/* ---------- Modal / overlay / toast ---------- */
#modal-root:empty, #overlay-root:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 6, 18, .82); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-card {
  background: var(--bg2); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 18px 18px 0 0; width: 100%; max-width: 480px; max-height: 88dvh;
  overflow-y: auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: slideup .2s ease;
}
@keyframes slideup { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-card h3 { font-size: 18px; margin-bottom: 8px; }
.modal-card .modal-img { display: block; margin: 0 auto; width: 150px; height: 150px; object-fit: contain; }
.modal-card .modal-img.silhouette { filter: brightness(0); }
.modal-meta { font-size: 13px; color: var(--muted); text-align: center; margin: 4px 0 10px; }
.modal-desc { font-size: 13px; color: var(--text); background: var(--card); border-radius: 10px; padding: 10px; margin: 8px 0; }
.modal-skills { font-size: 13px; margin: 8px 0; }
.modal-skills b { color: var(--accent); }
.modal-evo { font-size: 13px; color: var(--muted); text-align: center; margin: 6px 0; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal-actions .btn { flex: 1; }
.chapter-option {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  margin-top: 8px; color: var(--text); font-family: inherit; cursor: pointer; text-align: left;
}
.chapter-option.locked { opacity: .5; }
.chapter-option .co-name { font-weight: 800; }
.chapter-option .co-lv { font-size: 12px; color: var(--muted); }
.chapter-option .co-tag { font-size: 12px; font-weight: 800; color: var(--gold); }

/* catch + evolution overlays */
.overlay-full {
  position: fixed; inset: 0; z-index: 120; background: rgba(4, 6, 18, .9);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center;
}
.overlay-full img { width: 170px; height: 170px; object-fit: contain; }
.overlay-full h3 { font-size: 20px; }
.overlay-full p { color: var(--muted); font-size: 14px; }
.digiball { width: 84px; height: 84px; border-radius: 50%; border: 4px solid #111; position: relative; overflow: hidden; background: #fff; }
.digiball::before { content: ""; position: absolute; inset: 0 0 50% 0; background: #ef4444; }
.digiball::after { content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 22px; height: 22px; background: #fff; border: 4px solid #111; border-radius: 50%; }
.digiball.shake { animation: ballshake .45s ease-in-out 3; }
@keyframes ballshake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-24deg) translateX(-4px); } 75% { transform: rotate(24deg) translateX(4px); } }
.evo-flash { position: fixed; inset: 0; background: #fff; z-index: 130; animation: evoflash .7s ease forwards; pointer-events: none; }
@keyframes evoflash { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }

#toast-root { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 200; display: flex; flex-direction: column; gap: 6px; align-items: center; width: min(92vw, 440px); pointer-events: none; }
.toast {
  background: #1e293b; border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 9px 16px; font-size: 13px; font-weight: 700;
  box-shadow: 0 6px 20px rgba(0,0,0,.5); animation: toastin .2s ease; max-width: 100%; text-align: center;
}
.toast.gold { background: #57430a; border-color: var(--gold); color: var(--gold); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

#loading {
  position: fixed; inset: 0; z-index: 300; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
#loading .loading-box { text-align: center; font-size: 40px; color: var(--muted); }
#loading .loading-box span { font-size: 14px; }
