:root{
  --bg0:#070a18;
  --bg1:#0a1230;
  --line: rgba(255,255,255,0.12);
  --text: rgba(255,255,255,0.88);
  --muted: rgba(255,255,255,0.62);
  --accent:#58d8ff;
  --accent2:#ff3eaa;
  --accent3:#ff7c40;
  --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: linear-gradient(180deg, var(--bg0), var(--bg1));
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Helvetica, Arial;
  position: relative;
}
body::before{
  content:"";
  position:fixed;
  inset:-12% -12% -12% -12%;
  pointer-events:none;
  background:
    radial-gradient(900px 520px at 70% 16%, rgba(255,62,170,0.22), transparent 62%),
    radial-gradient(900px 520px at 24% 10%, rgba(88,216,255,0.22), transparent 60%),
    radial-gradient(1200px 740px at 50% 112%, rgba(255,124,64,0.18), transparent 62%);
  filter: blur(2px);
  opacity: 0.95;
  animation: drift 14s ease-in-out infinite alternate;
  z-index: -1;
}
body::after{
  content:"";
  position:fixed;
  left:0; right:0;
  top:56%;
  height: 12%;
  pointer-events:none;
  background: linear-gradient(90deg, rgba(255,62,170,0.12), rgba(88,216,255,0.12));
  filter: blur(18px);
  opacity: 0.55;
  z-index: -1;
}
@keyframes drift{
  from{ transform: translate3d(-1.2%, 0.6%, 0); }
  to{ transform: translate3d(1.2%, -0.8%, 0); }
}
.app{
  min-height:100%;
  min-height:100dvh;
  display:flex;
  flex-direction:column;
  gap:14px;
  padding: calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right))
    calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  position: relative;
  z-index: 0;
}
.topbar{
  display:flex; flex-wrap:wrap; align-items:flex-end; justify-content:space-between;
  gap:12px; padding:14px;
  border:1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.04)),
    linear-gradient(90deg, rgba(255,62,170,0.10), rgba(88,216,255,0.10));
  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;
}
.btn--primary{
  border-color: rgba(88,216,255,0.40);
  background: linear-gradient(180deg, rgba(88,216,255,0.26), rgba(255,62,170,0.10));
  box-shadow: 0 10px 24px rgba(0,0,0,0.34), 0 0 26px rgba(88,216,255,0.18);
}
.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--check{ min-width:96px; }
.field__check{ width:18px; height:18px; accent-color: var(--accent); }
.field--range{ min-width:170px; }
.field__range{ width:170px; }

.stage{
  display:grid;
  grid-template-columns: 1fr 260px;
  gap:14px;
  align-items:stretch;
  flex: 1 1 auto;
  min-height: 0;
}
.canvasWrap{
  position:relative;
  min-height: 0;
  border-radius:18px;
  border:1px solid rgba(88,216,255,0.52);
  box-shadow:
    var(--shadow),
    0 0 0 1px rgba(255,62,170,0.12),
    0 0 30px rgba(88,216,255,0.24),
    0 0 74px rgba(255,62,170,0.12),
    0 0 120px rgba(255,124,64,0.06);
  overflow:hidden;
}
canvas#gl{ display:block; width:100%; height:100%; }
.minimap{
  display:none;
  position:absolute;
  top:12px;
  right:12px;
  width: 220px;
  height: 440px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.20);
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.hint{
  position:absolute;
  left:12px;
  bottom:12px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.18);
  color: rgba(255,255,255,0.78);
  font-size:12px;
  line-height:1.3;
}
.filewarn{
  position:absolute;
  top:12px;
  left:12px;
  right:12px;
  padding:12px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.35);
  color: rgba(255,255,255,0.88);
  font-size:13px;
  line-height:1.35;
}
.filewarn code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: rgba(88,216,255,0.92);
}
.overlay{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,0.44);
  backdrop-filter: blur(6px);
}
.overlay[hidden]{ display:none !important; }
.overlay__card{
  border-radius:18px;
  border:1px solid rgba(255,255,255,0.14);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.07), rgba(0,0,0,0.25)),
    linear-gradient(90deg, rgba(255,62,170,0.14), rgba(88,216,255,0.14));
  box-shadow:
    0 18px 60px rgba(0,0,0,0.55),
    0 0 42px rgba(255,62,170,0.14),
    0 0 46px rgba(88,216,255,0.14);
  padding: 18px 18px 16px;
  text-align:center;
  max-width: min(420px, 86%);
}
.overlay__title{
  font-weight: 950;
  letter-spacing: 1.1px;
  font-size: 22px;
}
.overlay__sub{
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.35;
  color: rgba(255,255,255,0.78);
}
.overlay__actions{
  margin-top: 14px;
  display:flex;
  justify-content:center;
}
.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;
  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:650; line-height:1.35; color:rgba(255,255,255,0.78); }

.touchControls{
  display:none;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  padding: 0;
}
.touchControls__cluster{
  display:flex;
  gap:10px;
}
.touchControls__cluster--right{ justify-content:flex-end; flex-wrap:wrap; }
.tbtn{
  appearance:none;
  border:1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.22);
  color: rgba(255,255,255,0.90);
  border-radius:16px;
  min-width: 54px;
  height: 52px;
  padding: 0 14px;
  font-weight: 800;
  letter-spacing: 0.2px;
  box-shadow:
    0 10px 26px rgba(0,0,0,0.42),
    0 0 0 1px rgba(88,216,255,0.10),
    0 0 22px rgba(88,216,255,0.10);
  touch-action: none;
}
.tbtn:active{
  transform: translateY(1px);
  border-color: rgba(88,216,255,0.55);
  box-shadow:
    0 10px 26px rgba(0,0,0,0.42),
    0 0 24px rgba(255,62,170,0.16),
    0 0 36px rgba(88,216,255,0.18);
}
.tbtn--wide{ min-width: 92px; }

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

@media (max-width: 560px){
  .topbar{ padding:12px; border-radius:14px; }
  .brand__title{ font-size:18px; }
  .controls{ gap:8px; }
  .field--range{ min-width:140px; }
  .field__range{ width:140px; }
  .hint{ font-size:11px; padding:8px 10px; }
  .stage{ gap:12px; }
  .canvasWrap{
    border-radius:16px;
    min-height: 52dvh;
  }
  .touchControls{
    display:flex;
    padding: 0 2px;
    align-items:flex-start;
  }
  .touchControls__cluster--left{
    display:grid;
    grid-template-columns: 56px 56px;
    gap:10px;
    align-items:start;
  }
  .touchControls__cluster--right{
    display:grid;
    grid-template-columns: 56px 56px 56px;
    gap:10px;
    align-content:start;
    justify-items:stretch;
  }
  .touchControls__cluster--left .tbtn--wide{ width: 100%; grid-column: 1 / -1; }
  .tbtn{
    min-width: 56px;
    height: 54px;
    border-radius: 18px;
  }
  .tbtn--wide{ min-width: 96px; }

  /* Mobile minimap: much smaller so it doesn't cover the whole play area. */
  .minimap{
    width: min(96px, 30vw);
    height: auto;
    aspect-ratio: 1 / 2;
    top: 8px;
    right: 8px;
    opacity: 0.92;
  }
}
