/* EwrekaGames — Minesweeper board (assets/js/solo/mayin.js). Shell styles: assets/css/solo.css.
 * The board is sized once in px by mayin.js (fit) and never changes size or position while playing: everything that
 * can appear (status text, notices, result cards, hint marks) is fixed-height or an overlay. */

/* ---------- page tweaks for this game only ---------- */
#soloMain[data-game="mayin"] .solo-board { max-width: none; }
/* the status line keeps one line forever (a wrap would push the board down) */
#soloMain[data-game="mayin"] #status { display: block; height: 22px; min-height: 22px; line-height: 22px; width: 100%; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; contain: inline-size; }   /* contain: a long one-line text must not widen the page */
/* phones: two fixed lines, so hint explanations are not cut (the height never changes, whatever the text) */
@media (max-width: 560px) {
  #soloMain[data-game="mayin"] #status { height: 38px; min-height: 38px; line-height: 19px; font-size: 13px; white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; text-overflow: clip; }
}
/* daily: the midnight notice floats over the top of the stage instead of pushing the board */
#soloMain[data-game="mayin"] .daily-new { position: absolute; left: 10px; right: 10px; top: 10px; z-index: 30; width: auto; box-shadow: var(--shadow); }

/* ---------- colours ---------- */
.ms {
  --ms-frame: #3a4558; --ms-frame-2: #262e3c;
  --ms-tile: #ffe7c7; --ms-tile-hi: #fff6ea; --ms-tile-sh: #e0b98a; --ms-tile-hover: #fff0dc;
  --ms-open: #fffaf3; --ms-open-line: #f0e2cf;
  --ms-1: #1a9e95; --ms-2: #3d7bf7; --ms-3: #8455f2; --ms-4: #d23f8c; --ms-5: #f2552f; --ms-6: #c98400; --ms-7: #7c5433; --ms-8: #172033;
  --ms-ink: #1e2636; --ms-flag: #ff6b4a; --ms-boom: #ff6b4a;
}
:root[data-theme="dark"] .ms {
  --ms-frame: #0d1118; --ms-frame-2: #06080c;
  --ms-tile: #3a4559; --ms-tile-hi: #4c5a72; --ms-tile-sh: #232a37; --ms-tile-hover: #45526a;
  --ms-open: #1b212c; --ms-open-line: #262e3c;
  --ms-1: #3fd0c4; --ms-2: #7aa5ff; --ms-3: #b293ff; --ms-4: #ff7fbf; --ms-5: #ff8a68; --ms-6: #f5bf45; --ms-7: #d9a27a; --ms-8: #eef1f6;
  --ms-ink: #0b0e14; --ms-flag: #ff7656; --ms-boom: #ff7656;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ms {
    --ms-frame: #0d1118; --ms-frame-2: #06080c;
    --ms-tile: #3a4559; --ms-tile-hi: #4c5a72; --ms-tile-sh: #232a37; --ms-tile-hover: #45526a;
    --ms-open: #1b212c; --ms-open-line: #262e3c;
    --ms-1: #3fd0c4; --ms-2: #7aa5ff; --ms-3: #b293ff; --ms-4: #ff7fbf; --ms-5: #ff8a68; --ms-6: #f5bf45; --ms-7: #d9a27a; --ms-8: #eef1f6;
    --ms-ink: #0b0e14; --ms-flag: #ff7656; --ms-boom: #ff7656;
  }
}

/* ---------- layout ---------- */
.ms { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 0 auto; max-width: 100%; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ms-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.ms-hud { width: 100%; height: 48px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ms-count { flex: none; display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 12px 0 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.ms-ci { width: 22px; height: 22px; display: inline-grid; }
.ms-ci svg { width: 22px; height: 22px; }
.ms-count .ms-num { min-width: 3ch; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; color: var(--ink); }
.ms-modes { flex: 0 1 auto; min-width: 0; display: inline-flex; gap: 3px; padding: 3px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line); }
.ms-mbtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; min-width: 52px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; touch-action: manipulation; }
.ms-mbtn .ms-mi { width: 22px; height: 22px; display: inline-grid; flex: none; }
.ms-mbtn .ms-mi svg { width: 22px; height: 22px; }
.ms-mbtn .ms-ml { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-mbtn.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 0 var(--line-2), 0 0 0 1px var(--line); }
.ms-mbtn[data-m="flag"].on { color: var(--brand); box-shadow: 0 1px 0 var(--line-2), 0 0 0 2px var(--brand); }
.ms-mbtn:focus-visible, .ms-zbtn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.ms-zbtn { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); box-shadow: var(--press); cursor: pointer; padding: 0; touch-action: manipulation; }
.ms-zbtn svg { width: 22px; height: 22px; }
.ms-zbtn:active { transform: translateY(2px); box-shadow: none; }
.ms-zbtn.off { visibility: hidden; }   /* keeps its place: the HUD never reflows */
@media (max-width: 420px) {
  .ms-hud { gap: 6px; }
  .ms-mbtn { padding: 0 8px; gap: 4px; font-size: 13px; min-width: 0; }
  .ms-mbtn .ms-mi, .ms-mbtn .ms-mi svg { width: 19px; height: 19px; }
  .ms-count { padding: 0 8px 0 7px; gap: 5px; }
  .ms-ci, .ms-ci svg { width: 19px; height: 19px; }
  .ms-count .ms-num { min-width: 2ch; font-size: 17px; }
}
@media (max-width: 335px) { .ms-mbtn .ms-ml { display: none; } .ms-mbtn { min-width: 50px; } }

/* short landscape screens: the controls stand in a compact block beside the board (≤ 142 px tall) */
.ms.side { flex-direction: row; align-items: flex-start; gap: 12px; }
.ms.side .ms-hud { width: 94px; height: auto; display: grid; grid-template-columns: 44px 44px; gap: 6px; align-content: start; }
.ms.side .ms-count { grid-column: 1 / span 2; height: 40px; padding: 0 8px; justify-content: center; }
.ms.side .ms-count .ms-num { min-width: 0; font-size: 17px; }
.ms.side .ms-modes { grid-column: 1 / span 2; display: grid; grid-template-columns: 1fr 1fr; }
.ms.side .ms-mbtn { min-width: 0; padding: 0; height: 40px; }
.ms.side .ms-mbtn .ms-ml { display: none; }
.ms.side .ms-zbtn { grid-column: 1 / span 2; width: 100%; }

.ms-stage { position: relative; flex: none; }
.ms-view {
  position: relative; overflow: hidden; border-radius: 10px; background: var(--ms-open-line);
  box-shadow: 0 0 0 5px var(--ms-frame), 0 7px 0 5px var(--ms-frame-2);
  margin: 5px 5px 12px;
}
.ms-view.zoomed { overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.ms-grid { display: grid; grid-template-columns: repeat(var(--cols), var(--cs)); grid-auto-rows: var(--cs); width: max-content; outline: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.ms-view.zoomed .ms-grid { touch-action: pan-x pan-y; }
.ms-row { display: contents; }

/* ---------- cells ---------- */
.ms-c { position: relative; width: var(--cs); height: var(--cs); display: grid; place-items: center; cursor: pointer; font-size: calc(var(--cs) * .58); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; contain: layout paint; }
.ms-c::before { content: ""; position: absolute; inset: 0; background: var(--ms-open); box-shadow: inset 0 0 0 .5px var(--ms-open-line); }
.ms-c > * { position: relative; z-index: 1; pointer-events: none; }
.ms-c svg { width: 70%; height: 70%; }
/* hidden tile: a raised, slightly rounded block */
.ms-c.hd::before, .ms-c.f::before {
  inset: max(1px, calc(var(--cs) * .045)); border-radius: max(3px, calc(var(--cs) * .2));
  background: linear-gradient(var(--ms-tile-hi), var(--ms-tile) 45%);
  box-shadow: inset 0 calc(var(--cs) * -.09) 0 var(--ms-tile-sh), 0 1px 0 rgba(0, 0, 0, .06);
  transition: transform .08s, box-shadow .08s;
}
@media (hover: hover) { .ms:not(.done) .ms-c.hd:hover::before { background: linear-gradient(var(--ms-tile-hi), var(--ms-tile-hover) 45%); } }
.ms-c.pr::before { transform: translateY(1px); box-shadow: inset 0 calc(var(--cs) * -.04) 0 var(--ms-tile-sh); }
.ms.flagmode .ms-c.hd::before { box-shadow: inset 0 calc(var(--cs) * -.09) 0 var(--ms-tile-sh), inset 0 0 0 1.5px color-mix(in srgb, var(--brand) 28%, transparent); }
.ms-c.n1 { color: var(--ms-1); } .ms-c.n2 { color: var(--ms-2); } .ms-c.n3 { color: var(--ms-3); } .ms-c.n4 { color: var(--ms-4); }
.ms-c.n5 { color: var(--ms-5); } .ms-c.n6 { color: var(--ms-6); } .ms-c.n7 { color: var(--ms-7); } .ms-c.n8 { color: var(--ms-8); }
.ms-c.o { cursor: default; }
.ms-c.o:not(.n0) { cursor: pointer; }

/* icons (symbols in .ms-defs): main colour = currentColor, second colour = --ms-c2 (both inherited) */
.ms-ci { color: var(--ink); --ms-c2: var(--surface-2); }
.ms-mbtn[data-m="flag"] .ms-mi { --ms-c2: var(--brand); }
.ms-c.f { color: var(--ms-ink); --ms-c2: var(--ms-flag); }
:root[data-theme="dark"] .ms-c.f { color: #eef1f6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ms-c.f { color: #eef1f6; } }
.ms-c.mx { color: var(--ms-ink); --ms-c2: rgba(255, 255, 255, .85); }
:root[data-theme="dark"] .ms-c.mx { color: #dfe5ef; --ms-c2: #1b212c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ms-c.mx { color: #dfe5ef; --ms-c2: #1b212c; } }
.ms-c.bm::before { background: var(--ms-boom); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .12); }
.ms-c.bm { color: #1e2636; --ms-c2: #ffd9cf; }
.ms-c.wf::after { content: ""; position: absolute; inset: 18%; z-index: 2; background:
  linear-gradient(45deg, transparent 44%, var(--bad) 44%, var(--bad) 56%, transparent 56%),
  linear-gradient(-45deg, transparent 44%, var(--bad) 44%, var(--bad) 56%, transparent 56%); }
.ms-c.mx::before { background: color-mix(in srgb, var(--ms-tile) 55%, var(--ms-open)); box-shadow: none; }

/* start marker, keyboard focus, hints */
.ms-c.st::after { content: ""; position: absolute; inset: 18%; border-radius: 50%; border: 2.5px solid var(--blue); z-index: 2; animation: ms-st 1.8s var(--ease) infinite; pointer-events: none; }
.ms.kbd .ms-grid:focus .ms-c.kf { z-index: 3; }
.ms.kbd .ms-grid:focus .ms-c.kf::after { content: ""; position: absolute; inset: 0; border-radius: 4px; box-shadow: inset 0 0 0 3px var(--blue); z-index: 3; animation: none; }
.ms-c.hl::after { content: ""; position: absolute; inset: -1px; border-radius: 6px; box-shadow: inset 0 0 0 3px var(--brand), 0 0 0 3px color-mix(in srgb, var(--brand) 30%, transparent); z-index: 4; animation: ms-hl 1.5s var(--ease) both; pointer-events: none; }
.ms-c.src::after { content: ""; position: absolute; inset: 0; border-radius: 6px; box-shadow: inset 0 0 0 2.5px var(--blue); z-index: 4; animation: ms-hl 1.5s var(--ease) both; pointer-events: none; }
.ms-c.pk::before { animation: ms-pk .45s var(--ease); }

/* ---------- animations ---------- */
.ms-c.rv::before { animation: ms-open .3s var(--ease) var(--d, 0ms) backwards; }
.ms-c.rv > span { animation: ms-num .32s var(--spring) var(--d, 0ms) backwards; }
.ms-c.pop > svg { animation: ms-flag .32s var(--spring); }
.ms-c.ex > svg, .ms-c.ex.wf::after { animation: ms-mine .35s var(--spring) var(--d, 0ms) backwards; }
.ms-c.bm > svg { animation: ms-boom .5s var(--spring); }
.ms-c.wn > svg { animation: ms-win .5s var(--spring) var(--d, 0ms) backwards; }
@keyframes ms-open { from { background: var(--ms-tile); transform: scale(.94); border-radius: 22%; } 60% { transform: scale(.9); } to { transform: none; } }
@keyframes ms-num { from { transform: scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ms-flag { from { transform: translateY(-30%) scale(.5); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ms-mine { from { transform: scale(.2) rotate(-40deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ms-boom { 0% { transform: scale(.4); } 50% { transform: scale(1.35); } 100% { transform: none; } }
@keyframes ms-win { 0% { transform: none; } 40% { transform: translateY(-18%) scale(1.15); } 100% { transform: none; } }
@keyframes ms-st { 0% { transform: scale(.7); opacity: .95; } 70% { transform: scale(1.12); opacity: .25; } 100% { transform: scale(.7); opacity: .95; } }
@keyframes ms-hl { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }
@keyframes ms-pk { 0%, 100% { filter: none; } 50% { filter: brightness(1.12) saturate(1.3); } }

/* ---------- result card (loss) — reuses the shell's .result look, inside the board ---------- */
.ms-over { border-radius: 14px; inset: -4px -4px 4px; padding: 8px; }
/* one column always (the shell's two-column landscape card is too wide for a board-sized card) */
.result.ms-over .box { display: block; width: 100%; max-width: 360px; max-height: 100%; overflow: auto; }
.result.ms-over .row { margin-top: 12px; }
.ms-two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ms-two.one { grid-template-columns: 1fr; }
.ms-two .btn { padding: 0 10px; min-width: 0; }
.ms-over.compact .box { padding: 12px 14px 12px; }
.ms-over.compact .sub { margin-top: 2px; font-size: 13px; }
.ms-over.compact .row { margin-top: 8px; gap: 6px; }
.ms-over.compact .btn.big { height: 44px; }
.ms-over.compact .medal { display: none; }
.ms-over.compact h2 { margin: 0; font-size: 24px; }
.ms-over.compact .sub + .row { margin-top: 10px; }
.ms-over .ms-medal { background: var(--ms-boom); color: #fff; box-shadow: 0 4px 0 #c94a2c; }
.ms-over .ms-medal svg { width: 34px; height: 34px; }
.ms-over .ms-medal { color: #1e2636; --ms-c2: #ffd9cf; }
.ms-over h2 { color: var(--ink); }
.ms-over .ms-st { font-weight: 600; }
.ms-over .sub + .row { margin-top: 14px; }
.ms-peek { position: absolute; right: 10px; bottom: 20px; z-index: 6; box-shadow: var(--shadow); }

@media (prefers-reduced-motion: reduce) {
  .ms *, .ms *::before, .ms *::after { animation: none !important; transition: none !important; }
}
