:root{
  --bg0:#06070b;
  --bg1:#0b0f1a;
  --card:rgba(17, 20, 30, 0.78);
  --stroke:rgba(255,255,255,0.10);
  --text:#e8ecff;
  --muted:#a5abc4;
  --accent:#8ef0c8;
  --accent2:#8aa8ff;
  --danger:#ff5c7a;
  --shadow: 0 22px 80px rgba(0,0,0,0.55);
  --radius: 18px;

  --hp: #ff6b8c;
  --hpBg: rgba(255,255,255,0.10);
}

body[data-theme="graphite"]{
  --bg0:#070707;
  --bg1:#0f1115;
  --card:rgba(22, 23, 26, 0.78);
  --stroke:rgba(255,255,255,0.10);
  --text:#f2f2f2;
  --muted:#b3b3b3;
  --accent:#b6ff77;
  --accent2:#7cc2ff;
  --hp:#ff6b6b;
}

body[data-theme="neon"]{
  --bg0:#05010a;
  --bg1:#12002a;
  --card:rgba(24, 10, 44, 0.78);
  --stroke:rgba(255,255,255,0.12);
  --text:#fff2ff;
  --muted:#d7c6ea;
  --accent:#40ffb0;
  --accent2:#ff6bd6;
  --hp:#ff4aa6;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  color:var(--text);
  font-family: ui-rounded, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: radial-gradient(circle at 20% 10%, rgba(138,168,255,0.28), transparent 40%),
              radial-gradient(circle at 80% 20%, rgba(142,240,200,0.22), transparent 45%),
              radial-gradient(circle at 40% 80%, rgba(255,92,122,0.14), transparent 45%),
              linear-gradient(180deg, var(--bg1), var(--bg0));
}

.bg{
  position:fixed;
  inset:0;
  pointer-events:none;
  background-image: radial-gradient(rgba(255,255,255,0.055) 1px, transparent 1px);
  background-size: 18px 18px;
  opacity: 0.35;
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 5;
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  backdrop-filter: blur(12px);
  background: rgba(0,0,0,0.25);
}

.brand{ display:flex; align-items:center; gap: 12px; }
.logo{ width: 40px; height: 40px; display:grid; place-items:center; border: 1px solid var(--stroke); border-radius: 14px; background: rgba(255,255,255,0.06); }
.title{ font-weight: 900; letter-spacing: 0.3px; }
.subtitle{ color: var(--muted); font-size: 12px; }

.topActions{ display:flex; gap: 10px; align-items:center; flex-wrap: wrap; justify-content:flex-end; }

.shell{ width: min(1100px, calc(100% - 28px)); margin: 18px auto 56px; display:grid; gap: 16px; }

.card{
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 16px;
}

.btn{
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
  user-select:none;
}
.btn:hover{ transform: translateY(-1px); }
.btn:active{ transform: translateY(0); filter: brightness(0.96); }
.btnPrimary{ background: linear-gradient(180deg, rgba(142,240,200,0.32), rgba(255,255,255,0.06)); border-color: rgba(142,240,200,0.30); }
.btnSoft{ background: rgba(255,255,255,0.06); }

.select{
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  outline:none;
}

.hud{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat{ border:1px solid var(--stroke); border-radius: 16px; padding: 12px; background: rgba(0,0,0,0.18); }
.label{ color: var(--muted); font-size: 12px; }
.value{ font-weight: 1000; font-size: 18px; margin-top: 6px; }

.grid2{ display:grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; align-items:start; }

.arenaTop{ display:flex; justify-content: space-between; align-items:center; gap: 12px; }
.pill{ border:1px solid var(--stroke); border-radius:999px; padding: 8px 12px; background: rgba(0,0,0,0.18); font-weight: 900; }

.who{ display:flex; align-items:center; gap: 10px; }
.mini{
  width: 36px;
  height: 36px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.18);
  overflow: hidden;
}

.mini img{ width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }

.arenaMid{ display:grid; grid-template-columns: 1fr 1.2fr; gap: 14px; align-items: stretch; margin-top: 12px; }

.spriteBox, .enemyBox{
  border:1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  background: rgba(0,0,0,0.16);
  padding: 12px;
  display:grid;
  gap: 10px;
  justify-items:center;
}

canvas{ image-rendering: pixelated; image-rendering: crisp-edges; }
#player{ width: 180px; height: 270px; filter: drop-shadow(0 18px 28px rgba(0,0,0,0.38)); }
#enemy{ width: 220px; height: 220px; filter: drop-shadow(0 18px 28px rgba(0,0,0,0.38)); }

.caption{ color: var(--muted); font-size: 12px; }

.hp{ width: 100%; display:grid; gap: 6px; }
.hpBar{ width: 100%; height: 12px; border-radius: 999px; background: var(--hpBg); border: 1px solid var(--stroke); overflow:hidden; }
.hpFill{ height: 100%; width: 50%; background: linear-gradient(90deg, var(--hp), rgba(255,255,255,0.12)); }
.hpText{ color: var(--muted); font-size: 12px; text-align:center; }

.attack{ width: 100%; padding: 12px 14px; font-size: 16px; }

.hint, .tiny{ color: var(--muted); font-size: 12px; }
.muted{ color: var(--muted); }

.rowBetween{ display:flex; justify-content: space-between; align-items:center; gap: 12px; }

.shopList{ display:grid; gap: 10px; margin-top: 12px; }

.shopItem{
  border:1px solid var(--stroke);
  border-radius: 16px;
  background: rgba(0,0,0,0.16);
  padding: 12px;
  display:grid;
  gap: 8px;
}

.shopTop{ display:flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.shopName{ font-weight: 1000; }
.shopDesc{ color: var(--muted); font-size: 12px; line-height: 1.3; }

.divider{ height: 1px; background: rgba(255,255,255,0.10); margin: 14px 0; }

.fileBtn{ position: relative; overflow: hidden; }
.fileBtn input{ position:absolute; inset:0; opacity:0; cursor:pointer; }
.importRow{ display:flex; gap: 10px; align-items:center; flex-wrap: wrap; margin-top: 10px; }

.log{ display:grid; gap: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 12px; color: rgba(255,255,255,0.75); }

.toast{ position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(760px, calc(100% - 28px)); padding: 12px 14px; border-radius: 999px; text-align:center; border: 1px solid var(--stroke); background: rgba(0,0,0,0.45); backdrop-filter: blur(8px); }

@media (max-width: 980px){
  .grid2{ grid-template-columns: 1fr; }
  .arenaMid{ grid-template-columns: 1fr; }
  #player{ width: 160px; height: 240px; }
  #enemy{ width: 220px; height: 220px; }
  .hud{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
