:root{
  --bg:#0b1220;
  --panel:#0f172a;
  --panel2:#111827;
  --text:#e5e7eb;
  --muted:#94a3b8;
  --btn:#1f2937;
  --btn2:#273449;
  --primary:#22c55e;
  --danger:#ef4444;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius:16px;
}

*{box-sizing:border-box}
html,body{height:100%; margin:0;}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 20% 0%, #111b33 0%, var(--bg) 60%);
  color:var(--text);
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
  user-select: none;
  min-height: 100dvh;
  overflow: hidden;
  position: fixed;
  inset: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  touch-action: none;
}

.topbar{
  display:flex;
  flex: 0 0 auto;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:14px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), transparent);
}

.brand{display:flex; gap:10px; align-items:center}
.dot{
  width:14px; height:14px; border-radius:99px;
  background: linear-gradient(135deg, #60a5fa, #22c55e);
  box-shadow: 0 0 0 6px rgba(96,165,250,.12);
}
.title{font-weight:800; letter-spacing:.3px}

.stats{display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end}
.stat{
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 12px;
  padding: 8px 10px;
  min-width: 60px;
}
.stat .k{color:var(--muted); font-size:12px}
.stat .v{font-size:18px; font-weight:800; margin-top:2px}

.layout{
  display:grid;
  grid-template-columns: 1fr 320px;
  gap:14px;
  padding: 0 14px 12px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.panel{
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}

.game{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:12px;
  min-height: 520px;
}

#game{
  width: auto;
  height: min(72dvh, 520px);
  max-width: 92vw;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  image-rendering: pixelated;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.4));
  border: 1px solid rgba(255,255,255,.08);
  touch-action: none;
}

.overlay{
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  backdrop-filter: blur(6px);
  background: rgba(0,0,0,.45);
}
.overlay-card{
  width:min(420px, 92%);
  background: rgba(15,23,42,.92);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 18px;
  padding: 18px;
}
.overlay-title{font-weight:900; font-size:20px}
.overlay-text{color:var(--muted); margin-top:8px; line-height:1.35}
.overlay-actions{display:flex; gap:10px; margin-top:14px; flex-wrap:wrap}

.side{padding:12px}
.h{font-weight:800; color:var(--muted); font-size:12px; margin-bottom:8px; letter-spacing:.3px}

.controls{
  margin-top:12px;
  padding:10px;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px;
}

.grid{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:10px;
}

.btn{
  background: linear-gradient(180deg, var(--btn2), var(--btn));
  border: 1px solid rgba(255,255,255,.10);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(0,0,0,.25);
  -webkit-tap-highlight-color: transparent;
}
.btn:active{transform: translateY(1px); filter: brightness(1.1)}
.btn.primary{
  background: linear-gradient(180deg, rgba(34,197,94,.95), rgba(34,197,94,.75));
  border-color: rgba(34,197,94,.45);
  color:#05210f;
}
.btn.danger{
  background: linear-gradient(180deg, rgba(239,68,68,.95), rgba(239,68,68,.75));
  border-color: rgba(239,68,68,.45);
  color:#2a0606;
}
.btn.big{padding:16px 12px; font-size:20px}

.hint{
  margin-top:10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.footer{
  display:flex;
  flex: 0 0 auto;
  justify-content:center;
  align-items:center;
  gap:8px;
  padding: 10px 12px 14px;
  color: var(--muted);
  font-size: 12px;
}
.sep{opacity:.6}

@media (max-width: 920px){
  .layout{grid-template-columns: 1fr; }
  .side{display:grid; grid-template-columns: 1fr 1fr; gap:12px}
  #game{height:min(70dvh, 460px)}
}
@media (max-width: 520px){
  .side{grid-template-columns: 1fr}
}

/* Zorg dat hidden echt hidden is (override .overlay { display:flex }) */
.overlay[hidden] { display: none !important; }

/* Portrait: geef canvas prioriteit */
@media (orientation: portrait){
  .panel.side{ display: none; }
  #game{
    height: min(84dvh, 96vw);
    max-width: 100%;
  }
}

/* Phone layout */
@media (max-width: 600px) {
  .panel.side { display: none !important; }
  .layout { grid-template-columns: 1fr !important; padding: 0 10px 10px; gap: 10px; }
  .panel.game { padding: 10px; }
  #game {
    height: calc(100dvh - 170px);
    max-height: 100%;
    max-width: 96vw;
  }
  .topbar { padding: 10px 12px; }
  .stat { padding: 6px 8px; min-width: 72px; }
  .stat .v { font-size: 16px; }
  .footer { font-size: 11px; padding: 6px 8px; }
}

.assist{ margin-bottom: 10px; }

.toggle{
  display:flex;
  align-items:center;
  gap:10px;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px;
  padding: 10px 12px;
}

.toggle-text{
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
}

.toggle input{ display:none; }

.slider{
  width: 46px;
  height: 28px;
  border-radius: 999px;
  position: relative;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.14);
  flex: 0 0 auto;
}

.slider::after{
  content:"";
  width: 22px; height: 22px;
  position:absolute;
  top: 2px; left: 2px;
  border-radius: 999px;
  background: rgba(255,255,255,.85);
  transition: transform .18s ease, background .18s ease;
}

.toggle input:checked + .slider{
  background: rgba(34,197,94,.35);
  border-color: rgba(34,197,94,.45);
}

.toggle input:checked + .slider::after{
  transform: translateX(18px);
  background: rgba(34,197,94,.95);
}

.game-wrap{
  display:flex;
  align-items:center;
  justify-content:center;
  width: 100%;
}
