:root {
  --ink: #1c1c1c;
  --paper: #f7f6f2;
  --line: #e4e2da;
  --lime: #d6ff4a;
  --muted: #8d8a82;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "PingFang SC", "Noto Sans SC", sans-serif;
}
button, input { font: inherit; }
body.home {
  min-height: 100%;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 42px 42px;
  display: flex;
  flex-direction: column;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 0;
}
.icon-btn, .round {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 2px solid var(--ink);
  background: #fff;
  display: grid;
  place-items: center;
}
.brand { text-align: center; letter-spacing: 0.12em; }
.brand b { display: block; font-size: 22px; }
.brand span { color: var(--muted); font-size: 11px; letter-spacing: 0.28em; }
.smile {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 2px solid var(--ink);
  background: var(--lime);
  font-size: 26px;
}
.stage { flex: 1; display: grid; place-items: center; padding: 12px; }
.stage img { width: min(78vw, 420px); height: auto; image-rendering: pixelated; filter: drop-shadow(0 18px 0 rgba(0,0,0,0.06)); }
.dock {
  display: flex;
  justify-content: space-around;
  padding: 8px 18px calc(22px + env(safe-area-inset-bottom));
}
.action {
  width: 108px;
  background: none;
  border: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.action .ring {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background:
    radial-gradient(circle at 30% 30%, #fff 0 62%, transparent 63%),
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(180deg, var(--lime), #fff 42%) border-box;
  box-shadow: 0 8px 0 rgba(0,0,0,0.04);
  display: grid;
  place-items: center;
  font-size: 34px;
}
.action small { font-size: 16px; font-weight: 700; }
.sheet, .panel {
  position: fixed;
  inset: 0;
  background: rgba(20,20,20,0.28);
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.sheet.open, .panel.open { display: flex; }
.card {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 22px 18px calc(24px + env(safe-area-inset-bottom));
}
.card h2 { margin: 0 0 12px; font-size: 20px; }
.card button, .auth button {
  width: 100%;
  margin-top: 10px;
  height: 52px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: #fff;
  font-weight: 700;
}
.card button.primary, .auth button.primary { background: var(--lime); }
.auth {
  width: min(420px, calc(100% - 32px));
  margin: auto;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 24px;
  padding: 22px;
}
.auth input {
  width: 100%;
  height: 48px;
  margin-top: 8px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  padding: 0 12px;
}
.note { color: #a33; min-height: 1.2em; font-size: 14px; }
#map { position: fixed; inset: 0; }
.map-bar {
  position: fixed;
  z-index: 500;
  left: 12px;
  right: 12px;
  top: calc(10px + env(safe-area-inset-top));
  display: flex;
  gap: 8px;
}
.map-bar a, .map-bar button {
  border: 2px solid var(--ink);
  background: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  text-decoration: none;
  color: inherit;
  font-weight: 700;
}
.legend {
  position: fixed;
  z-index: 500;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 16px;
  padding: 12px;
}
.pin { font-size: 22px; }
body.dungeon { margin: 0; height: 100%; overflow: hidden; background: #120e16; }
#view {
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  background: #120e16;
}
#map {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 12px;
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
  border: 3px solid #111;
  background: #111;
}
.enemy-hp {
  position: fixed;
  left: 50%;
  bottom: 28%;
  transform: translateX(-50%);
  min-width: 140px;
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 0 #111;
}
.skills, .hud, .enemy-hp, .choices, .result, #map { z-index: 5; }
.skills {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  gap: 8px;
  z-index: 6;
}
.skills button { background: #d6ff4a; }
.hud, .choices, .battle, .result {
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
}
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choices button, .battle button, .result button, .hud button {
  border: 2px solid #111;
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
}
.battle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}
.unit {
  border: 3px solid #111;
  border-radius: 18px;
  background: #fff;
  text-align: center;
  padding: 8px;
  transition: transform 0.12s ease;
}
.unit.sway { transform: translateX(-10px) rotate(-2deg); }
.unit.hit { transform: translateX(12px); filter: brightness(1.4); }
.unit img, .monster {
  width: 100%;
  height: 140px;
  object-fit: contain;
  image-rendering: pixelated;
}
.hp { height: 8px; background: #eee; border-radius: 99px; overflow: hidden; }
.hp span { display: block; height: 100%; background: #3cba6a; }
.fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: none;
}
.fx.on { display: block; }
.fx.slice { background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,0.8) 50%, transparent 60%); }
.fx.fire { background: radial-gradient(circle, rgba(255,120,20,0.55), transparent 60%); }
.fx.frost { background: radial-gradient(circle, rgba(180,230,255,0.7), transparent 60%); }
.fx.void { background: radial-gradient(circle, rgba(120,60,255,0.45), transparent 60%); }
.float {
  position: fixed;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 0 #111;
  pointer-events: none;
}
body.dungeon { background: #161616; color: #f4f1ea; }
body.dungeon .hud { color: #f4f1ea; }
