:root{
  --bg:#0b1220;
  --panel:#0f1b31;
  --ink:#e9eefc;
  --muted:#a8b0c6;
  --brand:#5aa2ff;
  --ok:#22c55e;
  --bad:#ef4444;
  --warn:#f59e0b;
}
*{box-sizing:border-box}
body{
  margin:0; font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Inter,Arial;
  background: radial-gradient(1200px 600px at 20% -10%, #0f2749 0%, transparent 60%),
              radial-gradient(1000px 600px at 120% 0%, #1a2d52 0%, transparent 60%),
              var(--bg);
  color:var(--ink);
  min-height:100vh;
  display:flex; align-items:center; justify-content:center; padding:24px;
}
.app{ width:min(760px,100%); }
header{ display:flex; gap:12px; align-items:center; justify-content:space-between; margin-bottom:16px; flex-wrap:wrap }
.title{ font-weight:800; letter-spacing:.5px; font-size:clamp(18px,3vw,28px) }
.toolbar{ display:flex; flex-wrap:wrap; gap:10px; align-items:center }
.card{
  background:linear-gradient(180deg, rgba(255,255,255,.04), rgba(0,0,0,.05));
  border:1px solid rgba(255,255,255,.08);
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  border-radius:18px; padding:16px;
}
select{
  background:#091226; color:var(--ink); border:1px solid rgba(255,255,255,.12);
  border-radius:10px; padding:10px 12px; outline:none;
}
button{
  background:linear-gradient(180deg, #7bb2ff, #3b82f6); color:white; border:0; border-radius:12px;
  padding:10px 14px; font-weight:700; cursor:pointer; box-shadow:0 8px 16px rgba(59,130,246,.35);
}
button.secondary{ background:#16223a; border:1px solid rgba(255,255,255,.12); box-shadow:none; color:var(--ink) }
button:disabled{ opacity:.6; cursor:not-allowed }
a.btn{display:inline-block;background:#16223a;border:1px solid rgba(255,255,255,.18);color:var(--ink);padding:8px 10px;border-radius:10px;text-decoration:none}

.grid{ display:grid; grid-template-columns: 1fr; gap:14px; margin-bottom:16px }
.stats{ display:grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap:10px; }
.metric{ background:var(--panel); border:1px solid rgba(255,255,255,.08); border-radius:14px; padding:12px 10px; text-align:center }
.metric .label{ color:var(--muted); font-size:12px; margin-bottom:6px }
.metric .value{ font-size:clamp(18px,4vw,28px); font-weight:800 }

.board-wrap{ position:relative; display:flex; flex-direction:column; gap:12px; align-items:center; }
.board{
  width:min(520px, 92%);
  aspect-ratio:1/1;
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:10px;
}
.cell{
  background:linear-gradient(160deg, rgba(255,255,255,.06), rgba(0,0,0,.08));
  border:1px solid rgba(255,255,255,.12);
  border-radius:16px;
  display:grid; place-items:center;
  font-size:clamp(36px, 8vw, 64px);
  font-weight:900;
  color:#dfe7ff;
  cursor:pointer;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease, background .14s ease;
  user-select:none;
}
.cell:hover{ transform: translateY(-2px); box-shadow:0 12px 24px rgba(0,0,0,.28); border-color:rgba(255,255,255,.2) }
.cell.taken{ cursor:not-allowed; opacity:.95 }
.cell.win{ background: rgba(34,197,94,.14); border-color: rgba(34,197,94,.4) }

.status{ min-height:24px; font-weight:700; text-align:center }
.status.ok{ color:var(--ok) }
.status.bad{ color:var(--bad) }
.status.info{ color:var(--muted) }

.timerbar{ position:absolute; top:10px; width:min(520px, 92%); height:8px; border-radius:6px; background:rgba(255,255,255,.08); overflow:hidden; }
.timerbar > div{ height:100%; width:0%; background:linear-gradient(90deg, #7bb2ff, #22c55e); transition: width .2s linear }

.float-emoji{
  position:absolute; left:50%; top:50%; transform:translate(-50%,-50%) scale(0.6);
  font-size:clamp(48px, 10vw, 100px); pointer-events:none; opacity:0; z-index:5;
  animation:popfade 1.2s ease forwards;
}
@keyframes popfade{
  0%{ opacity:0; transform:translate(-50%,-50%) scale(0.6) rotate(-8deg) }
  20%{ opacity:1; transform:translate(-50%,-50%) scale(1.05) rotate(6deg) }
  70%{ opacity:1; transform:translate(-50%,-50%) scale(1) rotate(0deg) }
  100%{ opacity:0; transform:translate(-50%,-60%) scale(1) }
}

/* Confetti bintang */
.confetti{ position:fixed; pointer-events:none; z-index:60; width:10px; height:10px; opacity:.95; will-change:transform,opacity; }
.confetti::before{ content:"⭐"; font-size:14px; display:block; }

/* SR-only for aria-live */
.sr-only{ position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0 }

@media(max-width:480px){
  .metric .value{ font-size:22px }
  .cell{ border-radius:14px }
}
