:root {
  color-scheme: dark;
  font-family: "Courier Prime", "Courier New", monospace;
  background: #090909;
  color: #e9e9e9;
  --panel: #101010;
  --line: #353535;
  --muted: #aaaaaa;
  --accent: #e2e2e2;
  --yellow: #ffd36d;
  --cell: clamp(26px, calc((100vw - 76px) / var(--cols)), 46px);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: #090909; }
body { margin: 0; min-width: 300px; background: #090909; color: #e9e9e9; }
button, select { font: inherit; }
button, select, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.app { width: min(1120px, calc(100% - 48px)); min-height: 100vh; margin-inline: auto; padding-bottom: 64px; }
.topbar { min-height: 67px; display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.brand { color: inherit; font-size: 14px; font-weight: bold; text-transform: uppercase; letter-spacing: .13em; text-decoration: none; }
.brand-mark { color: var(--accent); margin-right: 9px; }
.intro { position: relative; isolation: isolate; overflow: hidden; display: grid; grid-template-columns: 1.35fr .65fr; align-items: end; gap: 32px; padding: clamp(45px, 8vw, 95px) 0; border-bottom: 1px solid var(--line); }
.intro::before { content: ""; position: absolute; z-index: -1; width: min(64vw, 620px); aspect-ratio: 1; top: 50%; right: 2%; transform: translateY(-50%); background: linear-gradient(90deg, transparent 49.8%, #494949 50%, transparent 50.2%), linear-gradient(transparent 49.8%, #494949 50%, transparent 50.2%), repeating-radial-gradient(circle closest-side, transparent 0 19.6%, #383838 19.8% 20%, transparent 20.2%); mask-image: linear-gradient(90deg, transparent, black 52%); }
.eyebrow { color: var(--accent); font-size: 12px; letter-spacing: .09em; text-transform: uppercase; margin: 0 0 8px; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
h1 { margin: 0; font-size: clamp(70px, 12vw, 145px); line-height: .9; letter-spacing: -.045em; }
h1 em { color: inherit; font-style: normal; }
.intro-copy, p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.intro-copy { max-width: 37ch; margin: 0; }
.game-shell { margin-top: 18px; padding: clamp(12px, 2.3vw, 25px); border: 1px solid var(--line); border-radius: 3px; background: var(--panel); }
.game-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.field-label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.select-wrap { position: relative; }
.select-wrap::after { content: "⌄"; position: absolute; right: 13px; top: 50%; translate: 0 -58%; pointer-events: none; color: var(--accent); }
button, select { min-height: 44px; padding: 8px 13px; border: 1px solid #595959; border-radius: 3px; background: #141414; color: inherit; font-size: 13px; }
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
select { display: block; min-width: 220px; padding-right: 38px; appearance: none; cursor: pointer; }
.new-game { background: var(--accent); border-color: var(--accent); color: #151515; font-weight: bold; }
.new-game:hover:not(:disabled) { background: #f5f5f5; color: #151515; }
.status-panel { width: min(420px, 100%); margin: 24px auto 10px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 11px 16px; border: 1px solid var(--line); border-radius: 3px; background: #141414; }
.stat { display: grid; justify-items: center; gap: 4px; }
.stat-label { color: var(--muted); font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
.stat strong { font: 25px/1 Georgia, "Times New Roman", serif; color: var(--accent); }
.face { width: 44px; height: 44px; min-height: 0; padding: 0; border-radius: 3px; color: var(--accent); }
.game-status { min-height: 1.5em; margin: 10px 0 14px; text-align: center; }
.board-viewport { max-width: 100%; overflow: visible; padding: 4px 4px 10px; }
.board { --grid-line: 2px; --grid-color: #555; width: max-content; margin: 0 auto; display: grid; grid-template-columns: repeat(var(--cols), var(--cell)); border-top: var(--grid-line) solid var(--grid-color); border-left: var(--grid-line) solid var(--grid-color); touch-action: manipulation; user-select: none; }
.cell { position: relative; width: var(--cell); height: var(--cell); min-width: 0; min-height: 0; display: grid; place-items: center; padding: 0; border: 0; border-right: var(--grid-line) solid var(--grid-color); border-bottom: var(--grid-line) solid var(--grid-color); border-radius: 0; background: #e9e9e9; color: #101010; font: 700 calc(var(--cell) * .5)/1 Georgia, serif; cursor: pointer; }
.cell:hover:not(.revealed), .cell:focus-visible { background: #fff; outline: 2px solid var(--yellow); outline-offset: -3px; z-index: 2; }
.cell.revealed { background: #161616; cursor: default; }
.cell.flagged { color: #5b3b00; }
.cell.mine { color: #f2f2f2; background: #202020; }
.cell.exploded { color: #090909; background: var(--accent); }
.cell.wrong::after { content: "×"; position: absolute; color: #fff; font-size: 1.2em; }
.n1 { color: #d9e9ff; }.n2 { color: #d9ffde; }.n3 { color: #ffd4d4; }.n4 { color: #e4d7ff; }.n5 { color: #ffe0c2; }.n6 { color: #cffffb; }.n7 { color: #fff; }.n8 { color: #bbb; }
.touch-controls { display: none; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.touch-controls button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #151515; font-weight: bold; }
.hint { margin: 12px 0 0; text-align: center; font-size: 12px; }
.mobile-hint { display: none; }
.rules { padding: clamp(55px, 8vw, 90px) 0 0; }
.rules h2 { margin: 0 0 24px; font-size: clamp(25px, 4vw, 38px); line-height: 1.06; }
.rules ol { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; background: var(--line); }
.rules li { min-height: 165px; display: flex; gap: 16px; padding: 24px; background: var(--panel); }
.rules li > span { color: var(--accent); font-size: 12px; }
.rules strong { display: block; margin-bottom: 7px; font-family: Georgia, "Times New Roman", serif; font-size: 20px; font-weight: 400; }
.rules p { margin: 0; }
.result-dialog { width: min(470px, calc(100% - 24px)); padding: 28px; border: 1px solid #595959; border-radius: 3px; color: inherit; background: #141414; text-align: center; }
.result-dialog::backdrop { background: #000b; }
.dialog-close { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; min-height: 0; padding: 0; }
.result-symbol { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 18px; border: 2px solid currentColor; border-radius: 50%; color: var(--yellow); font: 42px/1 Georgia, serif; }
.result-dialog h2 { margin: 0; font-size: 38px; }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 24px 0; background: var(--line); }
.result-stats div { display: grid; gap: 7px; padding: 13px 6px; background: #151515; }
.result-stats span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.result-stats strong { font: 25px/1 Georgia, serif; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
#visionToggle { position: fixed; z-index: 10; left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); width: 44px; height: 44px; min-height: 0; padding: 0; font-size: 21px; line-height: 1; }
#visionToggle[aria-pressed="true"] { color: #101010; background: var(--yellow); border: 2px solid var(--yellow); }
.high-visibility { --cell: clamp(40px, calc((100vw - 60px) / min(var(--cols), 9)), 62px); }
.high-visibility .board { --grid-line: 4px; --grid-color: #a0a0a0; }
.high-visibility body, .high-visibility button, .high-visibility select, .high-visibility p, .high-visibility label, .high-visibility span, .high-visibility .eyebrow { font-weight: 700; }
.high-visibility h1, .high-visibility h2, .high-visibility strong { font-weight: 800; }
.high-visibility .game-shell, .high-visibility .status-panel, .high-visibility .rules ol, .high-visibility .rules li, .high-visibility select, .high-visibility button:not(.cell), .high-visibility .result-dialog { border-width: 3px; }
.high-visibility .cell { font-size: calc(var(--cell) * .72); font-weight: 900; -webkit-text-stroke: .45px currentColor; }
.high-visibility .cell.revealed.n1 { color: #58a6ff; }
.high-visibility .cell.revealed.n2 { color: #52e879; }
.high-visibility .cell.revealed.n3 { color: #ff6262; }
.high-visibility .cell.revealed.n4 { color: #c38bff; }
.high-visibility .cell.revealed.n5 { color: #ff9b4a; }
.high-visibility .cell.revealed.n6 { color: #45e5dd; }
.high-visibility .cell.revealed.n7 { color: #ffffff; }
.high-visibility .cell.revealed.n8 { color: #d0d0d0; }
.high-visibility .game-status, .high-visibility .hint, .high-visibility .intro-copy { color: #fff; }
.high-visibility .mobile-hint { display: inline-block; padding: 10px 12px; border: 3px solid #fff; background: #090909; color: #fff; font-size: 15px; line-height: 1.45; font-weight: 800; }
@media (max-width: 700px) {
  .app { width: calc(100% - 24px); }
  .topbar { min-height: 53px; }
  .intro { grid-template-columns: 1fr; gap: 18px; }
  .intro::before { width: 88vw; right: -19%; }
  h1 { font-size: clamp(64px, 21vw, 110px); }
  .game-toolbar { align-items: stretch; }
  .field-label { flex: 1; }
  select { width: 100%; min-width: 0; }
  .touch-controls { display: flex; flex-wrap: wrap; }
  .board { margin-left: 0; }
  .desktop-hint { display: none; }
  .mobile-hint { display: inline; }
  .rules ol { grid-template-columns: 1fr; }
  .rules li { min-height: 0; }
}
@media (max-width: 420px) {
  .game-toolbar { display: grid; grid-template-columns: 1fr; }
  .new-game { width: 100%; }
  .touch-controls > span { width: 100%; text-align: center; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
