:root{
  --bg0:#070A12;
  --bg1:#0B1020;
  --card:#0E1630CC;
  --stroke:#243055;
  --text:#EAF0FF;
  --muted:#9FB0D8;
  --accent:#7C5CFF;
  --accent2:#2DE2E6;
  --danger:#FF4D6D;
  --shadow: 0 20px 60px rgba(0,0,0,.55);
  --radius: 18px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(1200px 700px at 20% 15%, rgba(124,92,255,.25), transparent 55%),
    radial-gradient(900px 600px at 80% 25%, rgba(45,226,230,.18), transparent 60%),
    radial-gradient(900px 800px at 55% 100%, rgba(255,77,109,.10), transparent 60%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  color:var(--text);
}

body.reduce-motion{
  background: linear-gradient(180deg, var(--bg0), var(--bg1));
}

.app{
  max-width: 1100px;
  padding: 22px;
  margin: 0 auto;
  min-height: 100%;
  display:flex;
  flex-direction:column;
  gap:18px;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding: 14px 16px;
  border:1px solid var(--stroke);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(14,22,48,.78), rgba(14,22,48,.55));
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand{ display:flex; align-items:center; gap:12px; }
.logo{
  width:42px; height:42px; border-radius:14px;
  background: radial-gradient(circle at 30% 30%, rgba(45,226,230,.9), rgba(124,92,255,.9));
  box-shadow: 0 12px 26px rgba(124,92,255,.25);
}
.title{ font-weight:800; letter-spacing:-.03em; font-size: 18px; }
.subtitle{ color:var(--muted); font-size: 13px; margin-top: 2px; }

.stats{ display:flex; gap:10px; }
.pill{
  border:1px solid var(--stroke);
  border-radius: 999px;
  padding: 10px 12px;
  min-width: 92px;
  background: rgba(9,13,28,.5);
}
.pill-label{ color: var(--muted); font-size: 12px; }
.pill-value{ font-size: 18px; font-weight: 800; margin-top:2px; }

.main{
  flex:1;
  display:flex;
  align-items:flex-start;
  justify-content:center;
}

.board-card{
  width:min(920px, 100%);
  display:grid;
  grid-template-columns: 1fr 280px;
  gap: 14px;
  align-items:start;
}

.board-wrap{
  position:relative;
  border:1px solid var(--stroke);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(10,14,30,.75), rgba(7,10,18,.65));
  box-shadow: var(--shadow);
  overflow:hidden;
}

canvas#board{
  width:100%;
  aspect-ratio: 1 / 1;
  display:block;
  touch-action: none;
}

.overlay{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 18px;
  background: radial-gradient(900px 700px at 50% 40%, rgba(10,14,30,.65), rgba(7,10,18,.85));
}
.overlay[hidden]{ display:none; }
.overlay-card{
  width:min(520px, 100%);
  border:1px solid var(--stroke);
  border-radius: 18px;
  padding: 16px;
  background: rgba(14,22,48,.65);
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
  backdrop-filter: blur(10px);
}
.overlay-title{
  font-size: 22px;
  font-weight: 900;
  letter-spacing:-.03em;
}
.overlay-text{
  color: var(--muted);
  margin-top:8px;
  line-height:1.5;
}
.overlay-actions{
  display:flex;
  gap:10px;
  margin-top: 14px;
  flex-wrap:wrap;
}
.overlay-help{
  margin-top: 12px;
  color: var(--muted);
}
.overlay-help ul{
  margin: 0;
  padding-left: 18px;
  line-height:1.55;
}

kbd{
  display:inline-block;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.25);
  padding: 2px 7px;
  border-radius: 7px;
  font-size: .92em;
  color: rgba(234,240,255,.95);
}

.controls{
  border:1px solid var(--stroke);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(14,22,48,.72), rgba(14,22,48,.46));
  box-shadow: var(--shadow);
  padding: 14px;
  backdrop-filter: blur(10px);
  display:flex;
  flex-direction:column;
  gap: 12px;
}

.control-row{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
}
.control-row:first-child{ justify-content:flex-start; }

.control-row-stack{
  align-items:flex-start;
  gap:12px;
}

.btn{
  appearance:none;
  border:1px solid var(--stroke);
  background: rgba(9,13,28,.55);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor:pointer;
  font-weight: 700;
  letter-spacing: -.01em;
  transition: transform .08s ease, background .12s ease, border-color .12s ease;
}
.btn:hover{ border-color: rgba(124,92,255,.55); background: rgba(9,13,28,.70); }
.btn:active{ transform: translateY(1px); }
.btn.primary{
  border-color: rgba(124,92,255,.65);
  background: linear-gradient(180deg, rgba(124,92,255,.30), rgba(124,92,255,.15));
}

.select{ display:flex; flex-direction:column; gap:6px; width: 100%; }
.select span{ color: var(--muted); font-size: 12px; }
select{
  width:100%;
  border-radius: 12px;
  border:1px solid var(--stroke);
  background: rgba(9,13,28,.55);
  color: var(--text);
  padding: 10px 10px;
  outline:none;
}

.toggle{
  display:flex;
  align-items:center;
  gap:10px;
  user-select:none;
  width: 100%;
  justify-content:flex-start;
  padding: 8px 10px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: rgba(9,13,28,.45);
}
.toggle input{ width: 18px; height: 18px; accent-color: var(--accent); }

.toggle.small{
  padding: 6px 8px;
  font-size: 11px;
}

.settings{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  flex:1;
}

.theme-select{
  max-width: 150px;
}

.panels{
  display:flex;
  flex-direction:column;
  gap:10px;
  border-top: 1px solid rgba(36,48,85,.8);
  padding-top: 10px;
  margin-top: 2px;
}

.panel-section{
  border-radius: 12px;
  background: rgba(6,9,20,.75);
  border: 1px solid rgba(36,48,85,.9);
  padding: 8px 10px;
}

.panel-title{
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .13em;
  color: var(--muted);
  margin-bottom: 4px;
}

.panel-list{
  margin: 0;
  padding-left: 20px;
  font-size: 12px;
  color: var(--text);
}

.panel-body{
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
}

.pad{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:4px;
}
.pad[hidden]{ display:none; }
.pad-row{
  display:flex;
  gap:4px;
}
.pad-btn{
  padding: 6px 10px;
  min-width: 40px;
}

.hint{ color: var(--muted); font-size: 12px; line-height:1.35; }

.footer{
  color: rgba(159,176,216,.8);
  font-size: 12px;
  text-align:center;
  padding: 6px 0 2px;
}

@media (max-width: 920px){
  .board-card{ grid-template-columns: 1fr; }
  .control-row{ justify-content:flex-start; flex-wrap:wrap; }
  .toggle{ width: auto; }
}
