:root{
  --bg:#0b1220;
  --panel:rgba(255,255,255,.05);
  --text:#e7ebff;
  --muted:rgba(231,235,255,.72);
  --line:rgba(255,255,255,.12);
  --accent:#8fb3ff;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}
input,textarea,[contenteditable]{-webkit-user-select:text;user-select:text}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  display:flex;
  flex-direction:column;
  min-height:100dvh;
  overflow:hidden;
  overscroll-behavior:none;
  background:radial-gradient(1000px 700px at 18% -10%, rgba(39,177,236,.18), transparent 60%),
             radial-gradient(900px 600px at 80% 10%, rgba(233,156,32,.14), transparent 60%),
             var(--bg);
  color:var(--text);
}
.legalBar{
  position:sticky;top:0;z-index:10;
  display:flex;gap:10px;align-items:center;justify-content:center;
  padding:10px 12px;
  background:rgba(0,0,0,.35);
  border-bottom:1px solid var(--line);
  backdrop-filter:blur(8px);
  font-size:13px;
}
.legalBar a{color:rgba(231,235,255,.9);text-decoration:none}
.legalBar a:hover{text-decoration:underline}
.sep{opacity:.55}
.playing .legalBar{padding:6px 10px;font-size:12px}
.playing .app-root{padding:8px;gap:10px}
.playing .row.head{display:none}
.playing #btnStart{display:none}
.playing #btnSound{display:none}
.playing #msg{display:none}
.app-root{
  max-width:1100px;
  margin:0 auto;
  padding:12px;
  width:100%;
  flex:1;
  display:flex;
  flex-direction:column;
  gap:12px;
  min-height:0;
}
.panel{
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--panel);
  padding:12px;
  box-shadow:0 18px 42px rgba(0,0,0,.25);
}
.row{display:flex;gap:10px;align-items:center}
.row.wrap{flex-wrap:wrap}
.row.head{justify-content:space-between;align-items:flex-start}
.right{display:flex;gap:10px;align-items:center}
.title{font-weight:900;letter-spacing:.3px;font-size:22px}
.muted{color:var(--muted)}
.muted.small{font-size:13px}
.pill{
  padding:6px 10px;border-radius:999px;
  background:rgba(0,0,0,.25);
  border:1px solid rgba(255,255,255,.12);
  font-size:13px;
}
.btn{
  border:1px solid rgba(143,179,255,.35);
  background:rgba(143,179,255,.18);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:800;
}
.btn:hover{background:rgba(143,179,255,.24)}
.btn:disabled{opacity:.5;cursor:not-allowed}
.btn.ghost{
  background:rgba(0,0,0,.18);
  border-color:rgba(255,255,255,.14);
  font-weight:750;
}
select{
  background:rgba(0,0,0,.18);
  border:1px solid rgba(255,255,255,.14);
  color:var(--text);
  border-radius:10px;
  padding:8px 10px;
}
.stats{margin-top:10px;justify-content:space-between}
.grow{flex:1;min-width:220px}
.stat{
  display:flex;gap:8px;align-items:baseline;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(0,0,0,.12);
  border-radius:12px;
  padding:8px 10px;
}
.stat .k{font-size:12px;color:rgba(231,235,255,.70);font-weight:800}
.stat .v{font-size:18px;font-weight:900}
.stat.mini{padding:6px 8px}
.stat.mini .v{font-size:16px}

.adv{display:inline-block}
.adv summary{list-style:none}
.adv summary::-webkit-details-marker{display:none}
.adv[open] summary{border-color:rgba(143,179,255,.50);background:rgba(143,179,255,.22)}
.advBody{
  margin-top:10px;
  padding-top:10px;
  border-top:1px solid rgba(255,255,255,.10);
  min-width:min(520px, 92vw);
}

.canvasWrap{
  flex:1;
  min-height:0;
  border:1px solid rgba(255,255,255,.12);
  border-radius:16px;
  overflow:hidden;
  background:rgba(0,0,0,.18);
  display:flex;
  align-items:center;
  justify-content:center;
  position:relative;
}
canvas{
  display:block;
  touch-action:none;
  max-width:100%;
  max-height:100%;
}

.touchHud{
  position:absolute;
  inset:0;
  pointer-events:none;
  display:none;
}
.joyArea{
  position:absolute;
  left:calc(18px + env(safe-area-inset-left));
  bottom:calc(18px + env(safe-area-inset-bottom));
  width:240px;
  height:240px;
  pointer-events:auto;
  --jx:0px;
  --jy:0px;
  --joyBaseSize:160px;
  touch-action:none;
}
.joyBase{
  position:absolute;
  left:50%;
  top:50%;
  width:var(--joyBaseSize);
  height:var(--joyBaseSize);
  margin-left:calc(var(--joyBaseSize) * -0.5);
  margin-top:calc(var(--joyBaseSize) * -0.5);
  border-radius:50%;
  background:transparent;
  border:1px solid rgba(255,255,255,.18);
  box-shadow:0 18px 44px rgba(0,0,0,.35);
  backdrop-filter:none;
}
.joyKnob{
  position:absolute;
  left:50%;
  top:50%;
  width:72px;
  height:72px;
  margin-left:-36px;
  margin-top:-36px;
  border-radius:50%;
  background:rgba(143,179,255,.20);
  border:1px solid rgba(143,179,255,.42);
  transform:translate(var(--jx), var(--jy));
  transition:transform 80ms ease;
}
.joyKnob.active{transition:none}
.actions{
  position:absolute;
  right:calc(18px + env(safe-area-inset-right));
  bottom:calc(18px + env(safe-area-inset-bottom));
  display:flex;
  flex-direction:column;
  gap:12px;
  pointer-events:auto;
}
.actBtn{
  width:132px;
  height:64px;
  border-radius:18px;
  border:1px solid rgba(143,179,255,.38);
  background:rgba(143,179,255,.18);
  color:var(--text);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:950;
  letter-spacing:.5px;
  box-shadow:0 18px 44px rgba(0,0,0,.32);
  touch-action:none;
}
.actBtn svg{width:26px;height:26px;display:block}
.actBtn.alt{
  border-color:rgba(233,156,32,.35);
  background:rgba(233,156,32,.16);
}
.actBtn:active{transform:translateY(1px)}

@media (pointer:coarse){
  .touchHud{display:block}
}

@media (max-width:640px){
  .panel{padding:10px}
  .title{font-size:20px}
  .btn{padding:9px 10px}
  .stat.mini .v{font-size:15px}
  .advBody{min-width:unset}
  .joyArea{width:220px;height:220px;--joyBaseSize:148px;left:calc(14px + env(safe-area-inset-left));bottom:calc(14px + env(safe-area-inset-bottom))}
  .joyKnob{width:66px;height:66px;margin-left:-33px;margin-top:-33px}
  .actions{right:calc(14px + env(safe-area-inset-right));bottom:calc(14px + env(safe-area-inset-bottom));gap:10px}
  .actBtn{width:120px;height:58px;border-radius:16px;font-size:14px}
  .actBtn svg{width:24px;height:24px}
}
