:root{
  --bg0:#070A12;
  --bg1:#0B1020;
  --card:#0E1630CC;
  --stroke:#223057;
  --text:#E9EEFF;
  --muted:#AAB6E8;
  --accent:#6EE7FF;
  --accent2:#8B5CF6;
  --danger:#FF5C8A;
  --shadow: 0 12px 35px rgba(0,0,0,.45);
  --radius: 16px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  color:var(--text);
  background: radial-gradient(1200px 800px at 20% 10%, #121A3A 0%, rgba(18,26,58,0) 55%),
              radial-gradient(900px 700px at 80% 25%, rgba(139,92,246,.22) 0%, rgba(139,92,246,0) 60%),
              linear-gradient(180deg, var(--bg1), var(--bg0));
  overflow:hidden;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:14px 16px;
  border-bottom:1px solid rgba(255,255,255,.06);
  background: linear-gradient(180deg, rgba(10,14,28,.92), rgba(10,14,28,.55));
  backdrop-filter: blur(10px);
}

.brand{display:flex; align-items:center; gap:12px; min-width:280px}
.dot{
  width:14px; height:14px; border-radius:50%;
  background: radial-gradient(circle at 35% 35%, #B9FBFF, var(--accent));
  box-shadow: 0 0 0 4px rgba(110,231,255,.12), 0 0 26px rgba(110,231,255,.35);
}
.title{font-weight:700; letter-spacing:.3px}
.subtitle{font-size:12px; color:var(--muted); margin-top:2px}

.hud{display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end}
.chip{
  padding:8px 10px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(10,14,28,.55);
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(0,0,0,.25);
  font-variant-numeric: tabular-nums;
}
.chip .k{color:var(--muted); margin-right:8px; font-size:12px}

.stage{
  position:relative;
  height: calc(100% - 56px);
  display:grid;
  grid-template-columns: 1fr;
  place-items:center;
}

canvas#game{
  width:min(960px, calc(100vw - 24px));
  height:auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.02);
}

.panel{
  position:absolute;
  top:18px;
  left:18px;
  width:min(360px, calc(100vw - 36px));
  padding:12px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,.08);
  background: var(--card);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.panel-row{display:flex; gap:10px; align-items:center; justify-content:flex-start; flex-wrap:wrap}
.help{color:var(--muted); font-size:12px; line-height:1.35}

.btn{
  appearance:none;
  border: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(180deg, rgba(110,231,255,.20), rgba(110,231,255,.08));
  color:var(--text);
  border-radius: 12px;
  padding:10px 12px;
  cursor:pointer;
  font-weight:650;
  letter-spacing:.2px;
  box-shadow: 0 10px 25px rgba(0,0,0,.25);
}
.btn:hover{border-color: rgba(110,231,255,.35)}
.btn:active{transform: translateY(1px)}
.btn-ghost{
  background: rgba(255,255,255,.04);
}

.touch{
  position:absolute;
  bottom:18px;
  left:18px;
  right:18px;
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:14px;
  pointer-events:none;
}
.dpad, .actions{
  pointer-events:auto;
  display:grid;
  gap:10px;
}
.dpad{
  grid-template-columns: 56px 56px 56px;
  grid-template-rows: 56px 56px;
  align-items:center;
}
.dpad .tbtn[data-key="up"]{grid-column:2; grid-row:1}
.dpad .tbtn[data-key="left"]{grid-column:1; grid-row:2}
.dpad .tbtn[data-key="down"]{grid-column:2; grid-row:2}
.dpad .tbtn[data-key="right"]{grid-column:3; grid-row:2}

.actions{
  grid-template-columns: 92px 56px;
  grid-auto-rows: 56px;
  justify-items:end;
}
.tbtn{
  width:56px;
  height:56px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(10,14,28,.65);
  color:var(--text);
  font-size:18px;
  font-weight:750;
  box-shadow: 0 12px 28px rgba(0,0,0,.32);
  user-select:none;
  -webkit-user-select:none;
  touch-action:none;
}
.tbtn.big{
  width:92px;
  font-size:14px;
  letter-spacing:.2px;
}
.tbtn:active{
  background: rgba(110,231,255,.16);
  border-color: rgba(110,231,255,.35);
}

@media (max-width: 820px){
  .panel{display:none}
}
