/* Minele — Minesweeper (js/minele.js). Theme-aware like the other game pages:
   tokens on :root, redefined under body.dark-theme. */
:root {
    --mn-accent: #1d4ed8;
    --mn-accent-2: #2563eb;
    --mn-accent-soft: #e5edff;
    --mn-page-bg: #f2f5fb;
    --mn-card-bg: #ffffff;
    --mn-card-border: #d9e1ee;
    --mn-muted: #5b6577;
    --mn-shadow: 0 10px 30px rgba(20, 40, 90, .10);
    --mn-board-bg: #c9d4e6;
    --mn-tile: #4f7be8;
    --mn-tile-2: #3561d1;
    --mn-tile-hi: rgba(255, 255, 255, .38);
    --mn-tile-lo: rgba(10, 25, 80, .35);
    --mn-open: #f4f6fa;
    --mn-open-2: #e9edf4;
    --mn-flag: #e11d48;
    --mn-mine: #1f2937;
    --mn-boom: #ef4444;
    --mn-good: #15803d;
    --mn-bad: #dc2626;
    --mn-warn: #b45309;
    --mn-gold: #f59e0b;
    --mn-n1: #1d4ed8;
    --mn-n2: #15803d;
    --mn-n3: #dc2626;
    --mn-n4: #4c1d95;
    --mn-n5: #9a3412;
    --mn-n6: #0f766e;
    --mn-n7: #111827;
    --mn-n8: #6b7280;
    --mn-cell: 32px;
}

body.dark-theme {
    --mn-accent: #7aa2ff;
    --mn-accent-2: #93b4ff;
    --mn-accent-soft: #17233f;
    --mn-page-bg: #0d1220;
    --mn-card-bg: #161d2e;
    --mn-card-border: #2a3550;
    --mn-muted: #a2adc4;
    --mn-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    --mn-board-bg: #0a0f1c;
    --mn-tile: #3a5cc0;
    --mn-tile-2: #2b479d;
    --mn-tile-hi: rgba(255, 255, 255, .22);
    --mn-tile-lo: rgba(0, 0, 0, .45);
    --mn-open: #1f2940;
    --mn-open-2: #1a2336;
    --mn-flag: #fb7185;
    --mn-mine: #e5e7eb;
    --mn-boom: #dc2626;
    --mn-good: #4ade80;
    --mn-bad: #f87171;
    --mn-warn: #fbbf24;
    --mn-n1: #7aa7ff;
    --mn-n2: #4ade80;
    --mn-n3: #f87171;
    --mn-n4: #c4a7ff;
    --mn-n5: #fb923c;
    --mn-n6: #2dd4bf;
    --mn-n7: #f3f4f6;
    --mn-n8: #9ca3af;
}

/* clip, not hidden: the site-wide `body { overflow-x: hidden }` would kill position: sticky. */
.mn-body, body.mn-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--mn-page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: clip;
}
.mn-main { padding-top: 92px; padding-bottom: 40px; }
.mn-game .container, .mn-hero .container { max-width: 1000px; }

/* ---- hero ---- */
.mn-hero { text-align: center; padding: 4px 0 8px; }
.mn-hero h1 { font-weight: 800; font-size: clamp(1.6rem, 5vw, 2.2rem); margin-bottom: 4px; }
.mn-hero-icon { color: var(--mn-accent); }
.mn-lead { margin: 0 auto; max-width: 560px; color: var(--mn-muted); font-size: .98rem; line-height: 1.45; }

/* ---- level + options ---- */
.mn-panel { max-width: 640px; margin: 6px auto 10px; }
.mn-levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 5px; border-radius: 16px; background: var(--mn-card-bg); border: 1px solid var(--mn-card-border); box-shadow: var(--mn-shadow); }
.mn-chip { min-height: 52px; padding: 4px 4px; border: 0; border-radius: 12px; background: transparent; color: inherit; font-weight: 800; font-size: .92rem; line-height: 1.15; cursor: pointer; touch-action: manipulation; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.mn-chip small { font-weight: 600; font-size: .74rem; opacity: .75; white-space: nowrap; }
.mn-chip[aria-checked="true"] { background: var(--mn-accent); color: #fff; }
body.dark-theme .mn-chip[aria-checked="true"] { color: #0b1430; }
.mn-custom { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 8px; align-items: end; margin-top: 8px; padding: 10px; border-radius: 14px; background: var(--mn-card-bg); border: 1px solid var(--mn-card-border); }
.mn-custom[hidden] { display: none; }
.mn-num { display: flex; flex-direction: column; gap: 3px; margin: 0; font-weight: 700; font-size: .85rem; }
.mn-num small { font-weight: 600; color: var(--mn-muted); }
.mn-num input { width: 100%; min-height: 44px; padding: 6px 8px; border-radius: 10px; border: 2px solid var(--mn-card-border); background: var(--mn-page-bg); color: inherit; font-weight: 800; font-size: 1rem; }
.mn-num input:focus { outline: none; border-color: var(--mn-accent); }
.mn-opts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin-top: 10px; }
.mn-switch { display: inline-flex; align-items: center; gap: 8px; margin: 0; min-height: 40px; font-weight: 700; cursor: pointer; user-select: none; }
.mn-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mn-switch-ui { position: relative; width: 44px; height: 26px; border-radius: 13px; background: var(--mn-card-border); transition: background .2s; flex: none; }
.mn-switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.mn-switch input:checked + .mn-switch-ui { background: var(--mn-accent); }
.mn-switch input:checked + .mn-switch-ui::after { transform: translateX(18px); }
.mn-switch input:focus-visible + .mn-switch-ui { outline: 3px solid var(--mn-gold); outline-offset: 2px; }

/* ---- counters ---- */
.mn-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; max-width: 520px; margin: 0 auto 8px; }
.mn-counter { justify-self: start; display: inline-flex; align-items: center; gap: 8px; min-width: 96px; min-height: 46px; padding: 6px 14px; border-radius: 14px; background: var(--mn-card-bg); border: 1px solid var(--mn-card-border); font-variant-numeric: tabular-nums; }
.mn-counter b { font-size: 1.3rem; font-weight: 900; letter-spacing: .02em; }
.mn-counter-icon { color: var(--mn-flag); }
.mn-clock { justify-self: end; }
.mn-clock .mn-counter-icon { color: var(--mn-accent); }
.mn-face { width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--mn-card-border); background: var(--mn-card-bg); color: var(--mn-gold); font-size: 1.9rem; display: grid; place-items: center; cursor: pointer; touch-action: manipulation; box-shadow: var(--mn-shadow); }
.mn-face span[hidden] { display: none; }
.mn-face:active { transform: scale(.94); }

/* ---- the board ---- */
.mn-stage-wrap { display: flex; justify-content: center; width: 100%; }
.mn-stage { position: relative; max-width: 100%; max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); overflow: auto; margin: 0 auto; padding: 8px; border-radius: 16px; background: var(--mn-board-bg); box-shadow: inset 0 2px 10px rgba(0, 0, 0, .18), var(--mn-shadow); touch-action: none; overscroll-behavior: contain; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; scrollbar-width: thin; width: fit-content; }
.mn-stage:focus { outline: none; }
.mn-stage:focus-visible { box-shadow: 0 0 0 3px var(--mn-gold), inset 0 2px 10px rgba(0, 0, 0, .18); }
.mn-stage.is-shake { animation: mn-shake .45s ease-out; }
@keyframes mn-shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.mn-board { display: grid; grid-template-columns: repeat(var(--mn-cols, 9), var(--mn-cell)); grid-auto-rows: var(--mn-cell); gap: 2px; width: max-content; }
.mn-c { position: relative; display: grid; place-items: center; border-radius: calc(var(--mn-cell) * .16); background: linear-gradient(160deg, var(--mn-tile) 0%, var(--mn-tile-2) 100%); box-shadow: inset 0 2px 0 var(--mn-tile-hi), inset 0 -2px 0 var(--mn-tile-lo); font-weight: 900; font-size: calc(var(--mn-cell) * .58); line-height: 1; cursor: pointer; font-variant-numeric: tabular-nums; -webkit-tap-highlight-color: transparent; }
.mn-c svg { width: 68%; height: 68%; display: block; }
.mn-c.is-open { background: linear-gradient(160deg, var(--mn-open) 0%, var(--mn-open-2) 100%); box-shadow: none; cursor: default; }
.mn-c.n1 { color: var(--mn-n1); } .mn-c.n2 { color: var(--mn-n2); } .mn-c.n3 { color: var(--mn-n3); } .mn-c.n4 { color: var(--mn-n4); }
.mn-c.n5 { color: var(--mn-n5); } .mn-c.n6 { color: var(--mn-n6); } .mn-c.n7 { color: var(--mn-n7); } .mn-c.n8 { color: var(--mn-n8); }
.mn-c.is-open[class*=" n"] { cursor: pointer; }
.mn-c.is-flag { color: #fff; }
.mn-c.is-flag .mn-flagcloth { fill: var(--mn-flag); }
body.dark-theme .mn-c.is-flag { color: #e8edff; }
.mn-c.is-flag svg { animation: mn-pop .18s ease-out; }
@keyframes mn-pop { from { transform: scale(.3) translateY(4px); opacity: 0; } }
.mn-c.is-q { color: #fff; font-size: calc(var(--mn-cell) * .52); }
.mn-c.is-mine { color: var(--mn-mine); }
.mn-c.is-boom { background: var(--mn-boom); color: #1f1300; animation: mn-boom .5s ease-out; }
@keyframes mn-boom { 0% { transform: scale(1.35); box-shadow: 0 0 0 10px rgba(239, 68, 68, .45); } 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }
.mn-c.is-shown { animation: mn-reveal .3s ease-out both; animation-delay: var(--d, 0ms); }
@keyframes mn-reveal { from { transform: scale(.4); opacity: 0; } }
.mn-c.is-wrong { background: linear-gradient(160deg, var(--mn-open) 0%, var(--mn-open-2) 100%); box-shadow: none; }
.mn-c.is-wrong::after { content: ""; position: absolute; inset: 14%; background: linear-gradient(45deg, transparent 44%, var(--mn-bad) 44% 56%, transparent 56%), linear-gradient(-45deg, transparent 44%, var(--mn-bad) 44% 56%, transparent 56%); }
.mn-c.is-done { background: linear-gradient(160deg, #22c55e 0%, #15803d 100%); }
.mn-c.is-press { transform: scale(.9); filter: brightness(1.12); transition: transform .38s ease-out, filter .38s; }
.mn-c.is-cursor { outline: 3px solid var(--mn-gold); outline-offset: -1px; z-index: 1; }
.mn-c.is-hint { z-index: 2; animation: mn-hint 1s ease-in-out 3; }
.mn-c.is-hint-safe { box-shadow: 0 0 0 3px #22c55e, inset 0 2px 0 var(--mn-tile-hi); }
.mn-c.is-hint-mine { box-shadow: 0 0 0 3px var(--mn-flag), inset 0 2px 0 var(--mn-tile-hi); }
.mn-c.is-hint-bad { box-shadow: 0 0 0 3px var(--mn-gold); }
@keyframes mn-hint { 50% { transform: scale(1.14); } }
.mn-board.is-tiny .mn-c { border-radius: 3px; }
@media (hover: hover) {
    .mn-c:not(.is-open):not(.is-flag):hover { filter: brightness(1.12); }
}

.mn-status { margin: 8px 2px 0; min-height: 1.5em; font-weight: 700; text-align: center; color: var(--mn-muted); line-height: 1.4; }
.mn-status.is-good { color: var(--mn-good); }
.mn-status.is-bad { color: var(--mn-bad); }
.mn-status.is-warn { color: var(--mn-warn); }

/* ---- tools ---- */
.mn-tools { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 12px; margin: 8px auto 0; max-width: 640px; }
.mn-taps { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--mn-card-bg); border: 1px solid var(--mn-card-border); flex: 1 1 220px; max-width: 300px; }
.mn-tap { min-height: 46px; border: 0; border-radius: 11px; background: transparent; color: inherit; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; touch-action: manipulation; }
.mn-tap[aria-checked="true"] { background: var(--mn-accent); color: #fff; }
.mn-tap[data-tap="flag"][aria-checked="true"] { background: var(--mn-flag); }
body.dark-theme .mn-tap[aria-checked="true"] { color: #0b1430; }
.mn-round-group { display: flex; gap: 6px; }
.mn-round { width: 50px; height: 50px; border-radius: 14px; border: 1px solid var(--mn-card-border); background: var(--mn-card-bg); color: inherit; font-size: 1.15rem; display: grid; place-items: center; cursor: pointer; touch-action: manipulation; }
.mn-round:hover:not(:disabled) { border-color: var(--mn-accent); }
.mn-round:disabled { opacity: .4; cursor: not-allowed; }
.mn-round span[hidden] { display: none; }
#mn-hint { color: var(--mn-gold); }

.mn-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; max-width: 420px; margin: 12px auto 0; }
.mn-btn { min-height: 48px; padding: 8px 14px; border: 1px solid var(--mn-card-border); border-radius: 14px; background: var(--mn-card-bg); color: inherit; font-weight: 700; font-size: .95rem; cursor: pointer; touch-action: manipulation; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.mn-btn:hover:not(:disabled) { border-color: var(--mn-accent); }
.mn-btn-primary { background: var(--mn-accent); border-color: var(--mn-accent); color: #fff; }
body.dark-theme .mn-btn-primary { color: #0b1430; }
.mn-chip:focus-visible, .mn-btn:focus-visible, .mn-round:focus-visible, .mn-tap:focus-visible, .mn-face:focus-visible, .mn-x:focus-visible, .mn-link:focus-visible { outline: 3px solid var(--mn-gold); outline-offset: 2px; }
.mn-record { text-align: center; color: var(--mn-muted); font-size: .88rem; margin: 10px 0 0; min-height: 1.3em; }
.mn-record b { color: var(--text-color); }

.mn-help { max-width: 760px; margin: 14px auto 0; padding: 12px 16px; border-radius: 14px; background: var(--mn-card-bg); border: 1px solid var(--mn-card-border); }
.mn-help summary { cursor: pointer; font-weight: 700; }
.mn-help ol { margin: 10px 0 0; padding-left: 20px; color: var(--mn-muted); line-height: 1.55; }
.mn-help li { margin-bottom: 4px; }
.mn-help strong { color: var(--text-color); }
.mn-help p { color: var(--mn-muted); margin: 10px 0 0; line-height: 1.55; font-size: .93rem; }
.mn-help p.mn-credit { font-size: .8rem; }
.mn-help a { color: var(--mn-accent); }
.mn-powered { text-align: center; color: var(--mn-muted); font-size: .85rem; margin: 26px 0 0; }
.mn-powered a { color: var(--mn-accent); }

/* ---- dialogs ---- */
.mn-overlay { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .5); animation: mn-fade .2s ease-out; }
.mn-overlay[hidden] { display: none; }
@keyframes mn-fade { from { opacity: 0; } }
.mn-dialog { width: 100%; max-width: 400px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; padding: 20px 16px 16px; border-radius: 22px; background: var(--mn-card-bg); color: var(--text-color); text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); animation: mn-rise .25s ease-out; }
@keyframes mn-rise { from { transform: translateY(16px) scale(.97); opacity: 0; } }
.mn-dialog h2 { font-weight: 800; font-size: 1.4rem; margin: 2px 0 6px; }
.mn-dialog-icon { font-size: 34px; color: var(--mn-gold); }
.mn-dialog-icon.is-bad { color: var(--mn-bad); }
.mn-dialog-icon span[hidden] { display: none; }
.mn-dialog-sub { color: var(--mn-muted); margin: 0 0 6px; line-height: 1.45; }
.mn-dialog-sub b { color: var(--text-color); }
.mn-dialog-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; margin-top: 14px; }
.mn-recs-card { max-width: 520px; text-align: left; }
.mn-recs-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mn-x { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--mn-card-border); background: var(--mn-card-bg); color: inherit; font-size: 1.1rem; cursor: pointer; }
.mn-rec-wrap { overflow-x: auto; margin-top: 8px; }
.mn-rec-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.mn-rec-table th, .mn-rec-table td { padding: 8px 6px; border-top: 1px solid var(--mn-card-border); white-space: nowrap; }
.mn-rec-table thead th { border-top: 0; font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--mn-muted); }
.mn-rec-table td { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.mn-rec-table thead th:not(:first-child) { text-align: right; }
.mn-rec-note { color: var(--mn-muted); font-size: .84rem; margin: 10px 0 4px; line-height: 1.4; }
.mn-link { border: 0; background: none; padding: 6px 0; color: var(--mn-bad); font-weight: 700; text-decoration: underline; cursor: pointer; }

@media (max-width: 420px) {
    .mn-chip { font-size: .82rem; min-height: 50px; }
    .mn-chip small { font-size: .68rem; }
    .mn-custom { grid-template-columns: repeat(3, 1fr); }
    .mn-custom .mn-btn { grid-column: 1 / -1; }
    .mn-counter { min-width: 84px; padding: 6px 10px; }
    .mn-tools { gap: 8px; }
    .mn-taps { flex-basis: 100%; max-width: none; }
    .mn-round-group { width: 100%; justify-content: space-between; }
    .mn-round { flex: 1 1 0; width: auto; }
    .mn-stage { padding: 6px; border-radius: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .mn-c, .mn-c svg, .mn-stage, .mn-dialog, .mn-overlay { animation: none !important; transition: none !important; }
}
