/* Saper in the AleGry look: paper background, ink outlines, hard shadows; closed fields are raised tiles. */
:root {
  --paper: #FFF7EA;
  --ink: #1D1533;
  --muted: #574D6E;
  --primary: #D93D22;
  --lemon: #FFD23F;
  --lemon-light: #FFF3C4;
  --mint: #20B69A;
  --mint-light: #D7F5EC;
  --sky-light: #E3F4FF;
  --tomato-light: #FFE1D9;
  --line: 3px solid var(--ink);
  --radius: 18px;
  --radius-sm: 10px;
  --font-heading: 'Fredoka', 'Trebuchet MS', 'Segoe UI', sans-serif;
  --font-body: 'Nunito', 'Segoe UI', Verdana, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--paper); color: var(--ink); }
body { margin: 0; padding: 4px 8px 12px 4px; font: 16px/1.5 var(--font-body); }
h2 { font-family: var(--font-heading); line-height: 1.15; }
:focus-visible { outline: 3px solid #7A5CFA; outline-offset: 2px; }
.notice { margin: 1rem; padding: .75rem 1rem; border: 2px solid var(--ink); border-radius: var(--radius-sm); background: var(--lemon-light); }

.button { font: 700 1rem var(--font-heading); padding: .6rem 1.1rem; border: var(--line); border-radius: 999px; background: var(--primary); color: #fff; box-shadow: 3px 3px 0 var(--ink); cursor: pointer; }
.button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.button--ghost { background: #fff; color: var(--ink); }

.board { background: #fff; border: var(--line); border-radius: var(--radius); box-shadow: 5px 5px 0 var(--ink); overflow: hidden; }
.board__bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; padding: .75rem 1rem; background: var(--mint-light); border-bottom: var(--line); }
.board__counters { margin: 0; display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-weight: 700; font-size: .9rem; }
.board__counters strong { font: 700 1.15rem var(--font-heading); }
.segmented { display: inline-flex; border: var(--line); border-radius: 999px; overflow: hidden; background: #fff; }
.segmented button { font: 600 .95rem var(--font-heading); border: 0; background: transparent; color: var(--ink); padding: .45rem .9rem; cursor: pointer; }
.segmented button + button { border-left: 2px solid var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.tools { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; padding: .9rem 1rem 0; }
.tool { padding: .45rem .9rem; border: var(--line); border-radius: 999px; background: #fff; color: var(--ink); box-shadow: 2px 2px 0 var(--ink); font: 700 .95rem var(--font-heading); cursor: pointer; }
.tool:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.tool[aria-pressed="true"] { background: var(--primary); color: #fff; }

.field-wrap { display: flex; justify-content: center; padding: 1rem; overflow-x: auto; }
.field { display: grid; gap: 0; width: min(100%, 26rem); border: var(--line); border-radius: 8px; overflow: hidden; background: var(--ink); box-shadow: 4px 4px 0 var(--ink); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.field--medium { width: min(100%, 34rem); }
.field--wide { width: min(100%, 52rem); }
.field__row { display: contents; }
.cell { display: grid; place-items: center; aspect-ratio: 1; min-width: 0; padding: 0; border: 0; border-right: 1px solid #B9AED0; border-bottom: 1px solid #B9AED0; background: #D9D0F2; box-shadow: inset 2px 2px 0 rgba(255, 255, 255, .85), inset -2px -2px 0 #B3A4DE; color: var(--ink); font: 700 clamp(.7rem, 3.2vw, 1.15rem)/1 var(--font-heading); cursor: pointer; }
.field--small .cell { font-size: clamp(1rem, 5vw, 1.45rem); }
.field--wide .cell { font-size: clamp(.6rem, 1.6vw, 1rem); }
.cell:hover { background: #E6DFFA; }
.cell:focus-visible { outline: 3px solid #7A5CFA; outline-offset: -3px; position: relative; z-index: 1; }
.cell.is-open { background: var(--paper); box-shadow: none; cursor: default; }
.cell.is-flag { background: #FFE58A; }
.cell.is-wrong { background: var(--tomato-light); text-decoration: line-through; }
.cell.is-mine { background: #F3EEFA; box-shadow: none; }
.cell.is-boom { background: var(--primary); box-shadow: none; }
.cell.n1 { color: #2F6FD6; }
.cell.n2 { color: #12806B; }
.cell.n3 { color: #D93D22; }
.cell.n4 { color: #4B2FA8; }
.cell.n5 { color: #9A3412; }
.cell.n6 { color: #0E7490; }
.cell.n7 { color: var(--ink); }
.cell.n8 { color: #6B6280; }
.field.is-over .cell { cursor: default; }

.tip { margin: 0 1rem 1rem; text-align: center; font-size: .85rem; color: var(--muted); }

.result { display: none; margin: 0 1.25rem 1.25rem; padding: 1rem 1.25rem; border: var(--line); border-radius: var(--radius); background: var(--lemon); }
.result.is-visible { display: block; }
.result.is-lost { background: var(--tomato-light); }
.result h2 { margin: 0 0 .25rem; font-size: 1.4rem; }
.result p { margin: 0; }
.result__actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem !important; }

.mg-toast { position: fixed; left: 50%; top: 1rem; z-index: 50; max-width: calc(100% - 2rem); transform: translate(-50%, -6rem); visibility: hidden; padding: .6rem 1.1rem; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 800; text-align: center; transition: transform .25s ease, visibility .25s; }
.mg-toast.is-visible { transform: translate(-50%, 0); visibility: visible; }

@media (max-width: 640px) {
  .board__bar { padding: .6rem .75rem; }
  .segmented button { padding: .4rem .7rem; font-size: .9rem; }
  .field-wrap { padding: .75rem .5rem; }
  .field { border-width: 2px; box-shadow: 3px 3px 0 var(--ink); }
  .field--wide .cell { font-size: .8rem; }
  .tip { font-size: .8rem; }
  .result { margin: 0 .75rem 1rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
