:root{
  --bg:#f7f7f8;
  --fg:#111;
  --muted:#666;
  --cell:#e8e8ec;
  --cell-revealed:#fff;
  --border:#d0d0d6;
  --accent:#0a84ff;
  --shadow:0 1px 2px rgba(0,0,0,.06);
  --radius:8px;
  --gap:4px;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
}
@media (prefers-color-scheme:dark){
  :root{
    --bg:#0f1115;
    --fg:#e8e8ee;
    --muted:#9aa0aa;
    --cell:#1c212b;
    --cell-revealed:#151a23;
    --border:#2a303b;
    --accent:#5aa0ff;
    --shadow:0 1px 2px rgba(0,0,0,.5);
  }
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--fg);
  display:flex;
  flex-direction:column;
  align-items:center;
  padding:16px;
  gap:16px;
}
header{
  width:100%;
  max-width:720px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:8px 0;
}
.header-left,.header-right{
  display:flex;
  align-items:center;
  gap:12px;
}
.mines,.timer{
  font-variant-numeric:tabular-nums;
  font-weight:600;
  min-width:64px;
  text-align:center;
  background:var(--cell);
  border:2px inset var(--border);
  border-radius:6px;
  padding:6px 8px;
}
.face{
  font-size:28px;
  width:44px;
  height:44px;
  border-radius:8px;
  border:2px solid var(--border);
  background:var(--cell);
  cursor:pointer;
  transition:transform 80ms ease;
}
.face:active{transform:scale(.96)}
.chips{display:flex;gap:8px}
.chip{
  padding:6px 12px;
  border-radius:999px;
  border:1px solid var(--border);
  background:var(--cell);
  cursor:pointer;
  font-size:14px;
}
.chip.active{background:var(--accent);color:#fff;border-color:var(--accent)}
.best{color:var(--muted);font-size:13px}
main{
  width:100%;
  max-width:720px;
  display:flex;
  justify-content:center;
}
.board{
  display:grid;
  gap:var(--gap);
  background:var(--border);
  padding:4px;
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  width:100%;
  max-width:min(90vw,720px);
}
.cell{
  aspect-ratio:1/1;
  min-width:32px;
  min-height:32px;
  border:0;
  background:var(--cell);
  font-weight:700;
  font-size:16px;
  border-radius:4px;
  cursor:pointer;
  user-select:none;
  -webkit-user-select:none;
  touch-action:manipulation;
}
.cell.covered{background:var(--cell);box-shadow:inset 0 -2px 0 rgba(0,0,0,.08)}
.cell.covered:active,.cell.covered:hover{filter:brightness(.98)}
.cell.revealed{background:var(--cell-revealed);cursor:default}
.cell.mine{background:#ff6b6b}
.cell.flagged{color:#d00}
.number-1{color:#1e90ff}
.number-2{color:#2e8b57}
.number-3{color:#dc143c}
.number-4{color:#4b0082}
.number-5{color:#b8860b}
.number-6{color:#008b8b}
.number-7{color:#000}
.number-8{color:#808080}
.overlay{
  position:fixed;inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,.4);
  backdrop-filter:blur(2px);
}
.overlay-card{
  background:var(--bg);
  color:var(--fg);
  padding:24px 32px;
  border-radius:12px;
  text-align:center;
  box-shadow:var(--shadow);
}
.overlay-card h2{margin:0 0 8px}
.overlay-card button{
  margin-top:12px;
  padding:8px 16px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--cell);
  cursor:pointer;
}
@media (prefers-reduced-motion:reduce){
  .face,.cell{transition:none}
}
@media (max-width:600px){
  body{padding:8px;gap:12px}
  .cell{font-size:14px}
  .face{width:40px;height:40px;font-size:24px}
}
