* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0a0e1f;
  --bg2: #131a33;
  --ink: #eef1ff;
  --sub: #9aa3c8;
  --line: rgba(255,255,255,.10);
  --gold: #ffd23f;
  --fire: #ff5a4d; --water: #4db4ff; --wood: #57d966;
  --light: #ffd23f; --dark: #b06cff; --heart: #ff7eb0;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", system-ui, sans-serif;
  background: radial-gradient(120% 80% at 50% -10%, #1b2349 0%, #0a0e1f 60%, #05060d 100%);
  color: var(--ink);
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}

#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 46px; z-index: 30;
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  background: linear-gradient(180deg, rgba(10,14,31,.92), rgba(10,14,31,.55) 70%, transparent);
  backdrop-filter: blur(6px);
}
#topbar .back { color: var(--sub); font-size: 14px; font-weight: 600; }
#topbar .brand { font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 6px; }
#topbar .brand .ic { font-size: 18px; }
#topbar .spacer { flex: 1; }
#topbar .hs { font-size: 12px; color: var(--sub); font-weight: 700; }
#topbar .hs b { color: var(--gold); }

#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#game { display: block; touch-action: none; }

/* ===== Overlays ===== */
.ov {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 16px; padding-top: calc(46px + env(safe-area-inset-top));
  background: rgba(5,7,16,.72); backdrop-filter: blur(7px);
  overflow: auto;
}
.ov.hidden { display: none; }
.ovcard {
  width: 100%; max-width: 380px; background: linear-gradient(180deg, #161d3a, #0e1228);
  border: 1px solid var(--line); border-radius: 20px; padding: 22px 20px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6); text-align: center;
}
.ovcard.wide { max-width: 440px; }
.ovcard h1 { font-size: 30px; font-weight: 900; letter-spacing: -.02em; line-height: 1.05; }
.ovcard h1 .sub2 { display: block; font-size: 14px; font-weight: 700; color: var(--gold); letter-spacing: .22em; margin-top: 4px; }
.ovcard h2 { font-size: 22px; font-weight: 900; margin-bottom: 12px; }
.lead { font-size: 13px; color: var(--sub); line-height: 1.6; margin: 12px 4px 16px; text-align: left; }
.lead b { color: var(--ink); }

.teamsel { text-align: left; background: rgba(0,0,0,.22); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.tshead { display: flex; align-items: baseline; justify-content: space-between; font-weight: 800; font-size: 14px; margin-bottom: 10px; }
.tshead small { font-weight: 500; color: var(--sub); font-size: 11px; }
.tscount b { color: var(--gold); }
.roster { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.mon {
  position: relative; aspect-ratio: 1; border-radius: 11px; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 21px; cursor: pointer;
  background: rgba(255,255,255,.04); transition: transform .12s, box-shadow .12s;
}
.mon:active { transform: scale(.92); }
.mon.picked { box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(255,210,63,.5); }
.mon .pdot { position: absolute; top: -5px; right: -5px; width: 16px; height: 16px; border-radius: 50%; background: var(--gold); color: #2a1d00; font-size: 10px; font-weight: 900; display: flex; align-items: center; justify-content: center; }
.mon .att { position: absolute; bottom: 2px; right: 3px; font-size: 9px; }
.teamrow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.slot {
  aspect-ratio: 1; border-radius: 11px; border: 1px dashed var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 22px; position: relative;
  background: rgba(0,0,0,.18);
}
.slot.filled { border-style: solid; background: rgba(255,255,255,.05); cursor: pointer; }
.slot .role { position: absolute; bottom: -1px; left: 0; right: 0; font-size: 8px; font-weight: 800; color: var(--gold); text-align: center; }
.leaderinfo { margin-top: 10px; font-size: 11.5px; color: var(--sub); line-height: 1.5; min-height: 16px; }
.leaderinfo b { color: var(--gold); }

.ovbtns { display: flex; gap: 8px; margin-top: 16px; }
button { font-family: inherit; cursor: pointer; border: 0; }
.primary { flex: 1; padding: 13px; border-radius: 13px; background: linear-gradient(180deg, #6c8bff, #4b63e6); color: #fff; font-size: 15px; font-weight: 800; box-shadow: 0 8px 22px rgba(76,99,230,.4); }
.primary:disabled { opacity: .4; box-shadow: none; }
.ghost { flex: 1; padding: 13px; border-radius: 13px; background: rgba(255,255,255,.07); color: var(--ink); font-size: 15px; font-weight: 700; border: 1px solid var(--line); }
.link { display: block; margin: 12px auto 0; background: none; color: var(--sub); font-size: 12px; text-decoration: underline; }

.rules { text-align: left; font-size: 12.5px; color: var(--sub); line-height: 1.6; padding-left: 4px; }
.rules li { margin-bottom: 9px; list-style: none; padding-left: 16px; position: relative; }
.rules li::before { content: "◆"; position: absolute; left: 0; color: var(--gold); font-size: 9px; top: 3px; }
.rules b { color: var(--ink); }

.overstats { display: flex; gap: 10px; justify-content: center; margin: 6px 0 14px; }
.overstats div { flex: 1; background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 12px; padding: 12px 4px; }
.overstats span { display: block; font-size: 26px; font-weight: 900; color: var(--gold); }
.overstats small { font-size: 11px; color: var(--sub); }
.bestline { font-size: 12.5px; color: var(--sub); margin-bottom: 14px; }
.bestline.nb { color: var(--gold); font-weight: 800; }
