:root{
  --bg0:#0b1020;
  --bg1:#0b1a2a;
  --panel: rgba(255,255,255,0.06);
  --panel2: rgba(255,255,255,0.09);
  --line: rgba(255,255,255,0.12);
  --text: rgba(255,255,255,0.88);
  --muted: rgba(255,255,255,0.62);
  --accent:#b7ff6a;
  --accent2:#58d8ff;
  --accent3:#ff78dc;
  --danger:#ff556e;
  --shadow: 0 14px 40px rgba(0,0,0,0.40);
}

*{ box-sizing:border-box; }

html,body{ height:100%; }
body{
  margin:0;
  color:var(--text);
  background:
    radial-gradient(1000px 600px at 15% 10%, rgba(88,216,255,0.14), transparent 60%),
    radial-gradient(900px 700px at 85% 30%, rgba(183,255,106,0.14), transparent 55%),
    radial-gradient(800px 600px at 30% 90%, rgba(255,120,220,0.12), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

.app{
  min-height:100%;
  display:flex;
  flex-direction:column;
  gap:14px;
  padding:16px;
}

.topbar{
  display:flex;
  flex-wrap:wrap;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  padding:14px 14px;
  border:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
  border-radius:16px;
  box-shadow:var(--shadow);
}

.brand__title{
  font-weight:800;
  letter-spacing:0.3px;
  font-size:20px;
}
.brand__subtitle{
  margin-top:3px;
  font-size:12px;
  color:var(--muted);
}

.controls{
  display:flex;
  align-items:flex-end;
  flex-wrap:wrap;
  gap:10px;
}

.btn{
  border:1px solid var(--line);
  background:rgba(255,255,255,0.06);
  color:var(--text);
  padding:9px 12px;
  border-radius:12px;
  cursor:pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.btn:hover{ transform: translateY(-1px); background:rgba(255,255,255,0.09); border-color:rgba(255,255,255,0.18); }
.btn:active{ transform: translateY(0px); }
.btn--primary{
  border-color: rgba(183,255,106,0.40);
  background: linear-gradient(180deg, rgba(183,255,106,0.24), rgba(183,255,106,0.10));
}
.btn--ghost{
  border-color: rgba(88,216,255,0.40);
  background: linear-gradient(180deg, rgba(88,216,255,0.18), rgba(88,216,255,0.07));
}
.btn:disabled{
  opacity:0.45;
  cursor:not-allowed;
  transform:none;
}

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:12px;
  background:rgba(255,255,255,0.04);
}
.field__label{
  font-size:11px;
  color:var(--muted);
  letter-spacing:0.2px;
}
.field__select{
  appearance:none;
  border:1px solid rgba(255,255,255,0.14);
  border-radius:10px;
  background:rgba(0,0,0,0.18);
  color:var(--text);
  padding:8px 10px;
  outline:none;
}
.field--range{ min-width:170px; }
.field__range{ width:170px; }
.field--check{ min-width:88px; }
.field__check{
  width:18px;
  height:18px;
  accent-color: var(--accent2);
}

.stage{
  display:grid;
  grid-template-columns: 1fr 240px;
  gap:14px;
  align-items:stretch;
  flex: 1 1 auto;
  min-height: 0;
}

.canvasWrap{
  min-height: 0;
}

canvas{
  display:block;
  width:100%;
  height:auto;
  border-radius:18px;
  border:1px solid rgba(88,216,255,0.52);
  background:
    radial-gradient(900px 520px at 50% 36%, rgba(255,120,220,0.08), transparent 60%),
    radial-gradient(900px 520px at 55% 46%, rgba(88,216,255,0.06), transparent 62%),
    radial-gradient(900px 520px at 45% 58%, rgba(183,255,106,0.05), rgba(0,0,0,0.14));
  box-shadow:
    var(--shadow),
    0 0 0 1px rgba(255,120,220,0.12),
    0 0 26px rgba(88,216,255,0.22),
    0 0 64px rgba(255,120,220,0.10);
}

.touch{
  margin-top:10px;
  display:none;
  gap:10px;
  align-items:center;
  justify-content:space-between;
}
.dpad{
  display:grid;
  grid-template-columns:56px 56px 56px;
  grid-template-rows:56px 56px 56px;
  gap:8px;
}
.tbtn{
  border:1px solid rgba(88,216,255,0.48);
  background: linear-gradient(180deg, rgba(88,216,255,0.20), rgba(0,0,0,0.24));
  color:rgba(255,255,255,0.88);
  border-radius:14px;
  width:56px;
  height:56px;
  font-size:22px;
  box-shadow:
    0 0 0 1px rgba(255,120,220,0.10),
    0 10px 30px rgba(0,0,0,0.35),
    0 0 22px rgba(88,216,255,0.16);
  user-select:none;
  touch-action:manipulation;
}
.tbtn--up{ grid-column:2; grid-row:1; }
.tbtn--left{ grid-column:1; grid-row:2; }
.tbtn--down{ grid-column:2; grid-row:3; }
.tbtn--right{ grid-column:3; grid-row:2; }
.tbtn--alt{
  width:auto;
  padding:0 14px;
  font-size:14px;
  letter-spacing:0.2px;
}

.hud{
  display:flex;
  flex-direction:column;
  gap:12px;
}
.hud__card{
  border-radius:16px;
  border:1px solid var(--line);
  background:rgba(255,255,255,0.05);
  padding:12px 12px;
  box-shadow:var(--shadow);
}
.hud__label{
  font-size:11px;
  color:var(--muted);
  letter-spacing:0.2px;
}
.hud__value{
  margin-top:6px;
  font-size:26px;
  font-weight:800;
}
.hud__value--small{
  font-size:13px;
  font-weight:600;
  line-height:1.35;
  color:rgba(255,255,255,0.76);
}

.footer{
  padding:10px 12px;
  border-radius:14px;
  border:1px dashed rgba(255,255,255,0.18);
  color:rgba(255,255,255,0.70);
  background:rgba(255,255,255,0.03);
}

@media (max-width: 980px){
  .stage{ grid-template-columns: 1fr; }
  .hud{ flex-direction:row; flex-wrap:wrap; }
  .hud__card{ flex: 1 1 180px; }
}

@media (max-width: 760px){
  .touch{ display:flex; }
  .hud{ gap:10px; }
  .hud__card{ padding:10px 10px; }
  .hud__value{ font-size:22px; }
  .hud__card:nth-child(3){ display:none; }
}
