:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1b1b1f;
  background: #f4f4f6;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
  --accent: #d44b22;
  --paper: #f4f4f6;
  --muted: #717177;
  --line: #dddde1;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, select { font: inherit; color: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { cursor: pointer; }
button, select, a { outline-offset: 3px; }
:focus-visible { outline: 3px solid #3265ce; }
[hidden] { display: none !important; }
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.game-shell { width: min(100%, 420px); margin: 0 auto; padding: env(safe-area-inset-top) 16px 0; }
h1 { font-size: 17px; letter-spacing: -.4px; font-weight: 650; margin: 0; }
.icon-button { display: grid; place-items: center; border: 0; background: transparent; width: 44px; height: 44px; border-radius: 14px; padding: 0; }
.game-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; margin-bottom: 10px; }
.level-label { display: flex; align-items: center; }
.level-label select { min-height: 44px; background: transparent; border: 0; padding: 0 22px 0 0; font-size: 14px; font-weight: 600; cursor: pointer; }
.counters { display: flex; align-items: center; gap: 23px; }
.counter { display: inline-flex; align-items: center; gap: 7px; }
.counter .icon { width: 17px; height: 17px; color: var(--muted); }
.counter .flag-icon { color: var(--accent); }
.counter strong { font-size: 15px; font-weight: 550; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.timer strong { min-width: 43px; }
.board { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; user-select: none; -webkit-user-select: none; }
.cell { display: grid; place-items: center; min-width: 0; aspect-ratio: 1; padding: 0; border: 1px solid #dcdce2; border-bottom-color: #c8c8d0; border-radius: 9px; background: #fff; box-shadow: 0 1px 1px #18182c0c; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1; transition: background .12s, transform .12s; scroll-margin-block: 12px 96px; }
.cell.open { background: #e7e7eb; border-color: transparent; box-shadow: none; }
.cell[data-count="0"] { background: #eaeaee; }
.cell[data-count="1"] { color: #285dc1; }
.cell[data-count="2"] { color: #7050a1; }
.cell[data-count="3"] { color: #b34525; }
.cell[data-count="4"] { color: #254c75; }
.cell[data-count="5"], .cell[data-count="6"], .cell[data-count="7"], .cell[data-count="8"] { color: #9d3269; }
.cell.flagged { background: #fff0e9; border-color: #eebfab; color: var(--accent); }
.cell.flagged .icon { fill: currentColor; stroke-width: 1.6; width: 20px; height: 20px; }
.cell.mine { background: #e4e4e9; border-color: transparent; color: #73737d; box-shadow: none; }
.cell.exploded { background: #d44b22; border-color: transparent; color: #fff; }
.cell.wrong { color: #b72e36; background: #ffe8e8; border-color: #eec9ca; }
.cell .icon { width: 23px; height: 23px; }
.cell:focus-visible { z-index: 1; outline-offset: 1px; }
.cell[aria-disabled="true"] { cursor: default; }
.cell:not([aria-disabled="true"]):active { transform: scale(.94); }
.toolbar { position: sticky; bottom: 0; z-index: 2; display: flex; align-items: center; gap: 16px; padding: 18px 0 max(18px, env(safe-area-inset-bottom)); margin-top: 2px; background: var(--paper); }
.mode-switch { display: flex; gap: 3px; background: #e6e6ea; border-radius: 15px; padding: 4px; flex: 1; }
.mode { display: flex; align-items: center; justify-content: center; gap: 8px; flex: 1; min-height: 44px; padding: 0 10px; border: 0; border-radius: 11px; background: transparent; color: #606067; font-size: 14px; font-weight: 600; transition: background .15s, color .15s; }
.mode .icon { width: 19px; height: 19px; }
.mode.active { background: #242428; color: #fff; box-shadow: 0 1px 3px #00000015; }
.flagging #flag-mode.active { background: #d44b22; }
.restart { width: 52px; height: 52px; flex-shrink: 0; border: 1px solid var(--line); background: #fff; border-radius: 15px; }
.game-message { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0 0; }
.game-message strong { font-size: 16px; font-weight: 650; letter-spacing: -.3px; }
.game-message p { color: var(--muted); font-size: 13px; margin: 4px 0 0; line-height: 1.4; }
.game-message.lost strong { color: #ba3d1c; }
.play-again { border: 0; border-radius: 12px; background: #242428; color: #fff; padding: 0 16px; min-height: 44px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.sheet { background: #fff; color: #1b1b1f; border: 0; border-radius: 24px; padding: 24px; width: min(400px, calc(100% - 32px)); max-height: calc(100svh - 32px); box-shadow: 0 24px 80px #00000020; }
.sheet::backdrop { background: #1b1b273d; backdrop-filter: blur(4px); }
.sheet h2 { font-size: 22px; font-weight: 700; letter-spacing: -.6px; margin: 0; }
.sheet p { font-size: 15px; line-height: 1.6; color: #585860; margin: 16px 0; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-header form { margin: -8px -8px -8px 0; }
.close { background: #f0f0f3; color: #65656d; border-radius: 50%; }
.close .icon { width: 19px; }
.best-row { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 20px; margin-top: 24px; font-size: 14px; }
.best-row strong { font-variant-numeric: tabular-nums; }
.dialog-actions { display: flex; gap: 8px; margin-top: 24px; }
.dialog-actions button { flex: 1; min-height: 48px; padding: 8px; border: 0; border-radius: 12px; background: #efeff2; font-size: 14px; font-weight: 550; }
.dialog-actions .confirm-restart { background: #242428; color: #fff; }
@media (min-width: 600px) { .game-shell { padding-top: 36px; } }
@media (max-width: 374px) { .game-shell { padding-inline: 14px; } .board { gap: 4px; } .cell { border-radius: 7px; } }
@media (max-width: 350px) { .game-shell { padding-inline: 8px; } .board { gap: 3px; } .counters { gap: 16px; } }
@media (max-width: 599px) { .sheet { margin: auto 0 0; width: 100%; max-width: none; border-radius: 24px 24px 0 0; padding: 26px 24px max(28px, env(safe-area-inset-bottom)); } }
@media (hover: hover) { .cell:not([aria-disabled="true"]):hover { background: #fafaff; border-color: #a6a6b5; } .icon-button:hover { background: #e6e6eb; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
