:root {
  color-scheme: light;
  --paper: #f5f3ec;
  --panel: #fcfbf6;
  --well: #e9ede2;
  --ink: #30382f;
  --muted: #73786b;
  --line: #d7dccf;
  --green: #42654e;
  --green-dark: #314e3a;
  --red: #a24535;
  font: 14px/1.5 "Segoe UI", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button, select { min-height: 34px; border: 1px solid var(--line); border-radius: 5px; padding: 6px 12px; background: var(--panel); }
button:hover { background: #e7ecdf; border-color: #acbca2; }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
.svg-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.app-shell { width: min(1140px, 100%); min-height: 100svh; margin: 0 auto; padding: 0 12px; display: flex; flex-direction: column; }
.game-controls { display: flex; align-items: center; gap: 6px; }
select { width: 126px; max-width: 100%; min-height: 30px; padding: 4px 7px; font-size: 12px; color: var(--ink); }
#new-game, #flag-mode { display: flex; align-items: center; justify-content: center; flex: none; width: 30px; min-height: 30px; padding: 3px; color: var(--green-dark); }
#new-game { font-size: 23px; line-height: 1; }
.game-panel { width: max-content; max-width: 100%; margin: 12px auto; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.game-toolbar { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: #f0f2e9; }
.game-stats { display: flex; align-items: center; gap: 12px; }
.stat { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.stat svg { width: 14px; height: 14px; color: var(--muted); }
.stat-label { color: var(--muted); font-size: 10px; }
/* Changing counters must not change the desktop window's preferred size. */
.stat output { flex: none; width: 5ch; overflow: hidden; text-align: right; white-space: nowrap; color: var(--green-dark); font: 13px/1.2 "Cascadia Mono", Consolas, monospace; font-variant-numeric: tabular-nums; }
#mines-left { width: 4ch; }
#flag-mode svg { width: 16px; height: 16px; color: var(--red); }
#flag-mode[aria-pressed="true"] { background: #f5e5df; border-color: #c49486; color: var(--red); }
.board-scroll { max-width: 100%; padding: 10px; overflow: auto; scrollbar-width: thin; scrollbar-color: #b5c1aa #f0f2e9; }
.board { --cell: 32px; display: grid; grid-template-columns: repeat(var(--columns, 9), var(--cell)); gap: 2px; width: max-content; padding: 3px; margin: 0 auto; border: 1px solid #8da17d; border-radius: 3px; background: #b7c1ac; user-select: none; }
.board-row { display: contents; }
.cell { display: flex; align-items: center; justify-content: center; width: var(--cell); height: var(--cell); min-height: 0; border: 0; border-top: 1px solid #c1cfb4; border-left: 1px solid #bccbae; border-right: 1px solid #7d926a; border-bottom: 1px solid #72875f; border-radius: 2px; padding: 0; background: #98aa88; color: var(--green); font: 700 18px/1 Consolas, monospace; touch-action: manipulation; }
.cell:hover { background: #889f76; border-color: #6d8659; }
.cell:active { background: #7f956e; }
.cell:focus-visible { position: relative; z-index: 1; outline: 2px solid #263f2d; outline-offset: -2px; }
.cell svg { width: 20px; height: 20px; pointer-events: none; }
.cell.revealed { border: 1px solid transparent; background: #fffef7; }
.cell.revealed:hover { background: #f0f0e7; }
.cell.flagged { color: #8f3027; }
.cell[data-number="1"] { color: #3e638b; }
.cell[data-number="2"] { color: #427246; }
.cell[data-number="3"] { color: #a34a3d; }
.cell[data-number="4"] { color: #675581; }
.cell[data-number="5"] { color: #87523f; }
.cell[data-number="6"] { color: #36767a; }
.cell[data-number="7"] { color: #393e37; }
.cell[data-number="8"] { color: #7c7d70; }
.cell.mine { color: #68725c; }
.cell.exploded { color: #84392c; background: #e6b6a5; }
.cell.wrong-flag { position: relative; color: #a24535; background: #f4e4da; }
.cell.wrong-flag::after { content: ""; position: absolute; width: 23px; height: 2px; background: var(--red); transform: rotate(-45deg); box-shadow: 0 1px #f4e4da; }
.board[data-state="won"] { border-color: #56774b; background: #749368; }
.game-status { height: 28px; min-height: 28px; margin: 0; padding: 5px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.game-status[data-state="won"] { color: var(--green-dark); background: #e9f0e1; }
.game-status[data-state="lost"] { color: var(--red); background: #f8eee5; }
.app-footer { margin-top: auto; padding: 12px 0 14px; border-top: 1px solid var(--line); font-size: 11px; }
.app-footer a { color: var(--muted); }
@media (max-width: 460px) {
  .game-stats { flex-basis: 100%; justify-content: space-between; padding: 2px 0; }
  .game-controls { width: 100%; }
  select { flex: 1; width: auto; }
}
@media (max-width: 380px) {
  .app-shell { padding-inline: 8px; }
  .board-scroll { padding: 8px; }
  .board { --cell: 30px; }
}
.is-embedded, .is-embedded body { height: 100%; overflow: hidden; }
.is-embedded body { min-width: 0; }
.is-embedded .app-shell { width: 100%; height: 100dvh; min-height: 0; padding: 0 8px; }
.is-embedded .app-footer { display: none; }
.is-embedded .game-panel { flex: 0 1 auto; min-height: 0; margin: 8px auto; display: flex; flex-direction: column; }
.is-embedded .game-toolbar, .is-embedded .game-status { flex: none; }
.is-embedded .game-controls, .is-embedded .game-stats { flex: 0 0 auto; width: max-content; padding: 0; justify-content: flex-start; }
.is-embedded select { flex: none; width: 126px; max-width: none; }
.is-embedded .board-scroll { flex: 0 1 auto; min-height: 0; padding: 8px; scrollbar-gutter: stable; }
.is-embedded .board { --cell: 32px; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
