* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, #1e293b 0%, #334155 60%, #1e293b 100%);
  color: #e2e8f0; user-select: none; -webkit-user-select: none;
  touch-action: none; overflow: hidden;
}
#app { height: 100%; display: flex; flex-direction: column; max-width: min(100%, 860px); margin: 0 auto; }

#hdr { display: flex; align-items: center; gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
#hdr .pill { background: rgba(0,0,0,0.24); border: 2px solid rgba(255,255,255,0.14); border-radius: 999px; padding: 6px 11px; font-weight: 800; font-size: 15px; min-width: 44px; min-height: 44px; display: flex; align-items: center; cursor: pointer; justify-content: center; color: inherit; font-family: inherit; }
#hdrHome { border: none; background: #f59e0b; color: #1e293b; font-size: 18px; }
#hdrStatus { flex: 1; min-width: 0; text-align: center; font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #94a3b8; }

.scr { flex: 1; display: none; flex-direction: column; overflow-y: auto; padding: 6px 14px 18px; }
/* The field gets the full width — the cell size divides whatever is left, so
   padding here comes straight off every square. Menu and help keep theirs. */
#scr-play { padding: 6px 4px 6px; }
.scr.on { display: flex; }

#scr-menu { align-items: center; text-align: center; gap: 12px; justify-content: center; }
#scr-menu h1 { font-size: clamp(30px, 8.5vw, 44px); color: #f8fafc; }
#scr-menu .sub { color: #94a3b8; font-weight: 600; margin-bottom: 4px; }
#tierRow { display: flex; gap: 8px; width: 100%; }
.tierCard { flex: 1; background: rgba(0,0,0,0.22); border: 3px solid rgba(255,255,255,0.13); border-radius: 16px; padding: 10px 4px; font-weight: 800; font-size: 14px; line-height: 1.35; cursor: pointer; color: #e2e8f0; font-family: inherit; }
.tierCard small { display: block; color: #94a3b8; font-weight: 700; font-size: 11.5px; }
.tierCard .te { font-size: 26px; display: block; }
.tierCard.sel { border-color: #f59e0b; background: rgba(245,158,11,0.14); }
button.big { width: 100%; border-radius: 16px; min-height: 56px; font-size: 19px; font-weight: 800; background: rgba(0,0,0,0.22); color: #e2e8f0; border: 3px solid rgba(255,255,255,0.13); cursor: pointer; font-family: inherit; }
button.big:active { transform: translateY(2px); }
button.big.primary { background: #f59e0b; border-color: #d97706; color: #1e293b; min-height: 44px;}
#statsLine { color: #94a3b8; font-weight: 700; font-size: 13px; }

/* play */
#playTop { display: flex; align-items: center; justify-content: space-between; font-weight: 800; padding: 2px 6px 6px; font-size: 16px; min-height: 22px; }
#minesOut { color: #fca5a5; }
#timeOut { color: #cbd5e1; font-variant-numeric: tabular-nums; }

#stageWrap { flex: 1; position: relative; min-height: 0; }
canvas#stage { display: block; touch-action: none; }

/* The board is not generated until the first tap, because the no-guess proof
   is a proof FROM that opening square. This line is what makes that visible
   rather than feeling like a dead tap. */
#note { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #94a3b8; pointer-events: none; text-align: center; padding: 20px; font-size: 15px; }
#note:empty { display: none; }

#pad { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px 4px max(4px, env(safe-area-inset-bottom)); }
.pb { min-height: 54px; border-radius: 14px; background: rgba(0,0,0,0.24); border: 3px solid rgba(255,255,255,0.13); color: #e2e8f0; font-size: 20px; font-weight: 800; font-family: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; touch-action: manipulation; }
.pb span { font-size: 11px; font-weight: 800; color: #94a3b8; }
.pb:active { transform: translateY(2px); }
/* The mode button is the one control whose STATE matters, so it looks
   different in each state rather than only saying so in words. */
#modeBtn.flagging { background: #7f1d1d; border-color: #dc2626; }
#modeBtn.flagging span { color: #fecaca; }

.ovl { position: absolute; inset: 0; display: none; align-items: flex-start; justify-content: center; background: rgba(2,6,23,0.9); border-radius: 12px; padding: 16px; overflow-y: auto; overscroll-behavior: contain;}
.ovl.on { display: flex; }
.ovlCard { text-align: center; width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 10px; margin: auto;}
#ovlTitle { font-size: 26px; font-weight: 800; color: #f8fafc; }
#ovlSub { color: #94a3b8; font-weight: 700; min-height: 22px; line-height: 1.45; }

#scr-how .card { background: rgba(0,0,0,0.22); border: 3px solid rgba(255,255,255,0.12); border-radius: 16px; padding: 14px; margin-bottom: 10px; font-size: 15px; line-height: 1.55; font-weight: 600; }
#scr-how h2 { margin-bottom: 8px; color: #f8fafc; }

/* The legend (R-L1). The number swatches are generated from the same NUM
   table the board paints with, so a recoloured number cannot leave a stale
   swatch behind here. */
.lgSub { font-weight: 800; font-size: 13.5px; color: #94a3b8; margin: 10px 0 5px; }
.legend { display: flex; flex-direction: column; gap: 6px; }
.lgRow { display: flex; align-items: center; gap: 10px; }
.lgArt { flex: none; width: 42px; display: flex; align-items: center; justify-content: center; }

.lgCell { width: 28px; height: 28px; border-radius: 3px; background: #e2e8f0; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px; }
.lgClosed { width: 28px; height: 28px; border-radius: 3px; background: #64748b; box-shadow: inset 0 2px 0 rgba(255,255,255,0.18); display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.lgOpen { width: 28px; height: 28px; border-radius: 3px; background: #eef2f7; display: inline-block; }
.lgMine { width: 28px; height: 28px; border-radius: 3px; background: #7f1d1d; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.lgRing { width: 28px; height: 28px; border-radius: 3px; background: #64748b; box-shadow: inset 0 0 0 3px #38bdf8; display: inline-block; }

.lgTxt { display: flex; flex-direction: column; min-width: 0; }
.lgTxt b { font-size: 14px; font-weight: 800; }
.lgTxt small { font-size: 12.5px; color: #94a3b8; line-height: 1.3; font-weight: 600; }

#toast { position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%); background: #f8fafc; color: #0f172a; font-weight: 800; padding: 10px 16px; border-radius: 14px; opacity: 0; transition: opacity 0.25s; pointer-events: none; z-index: 40; max-width: calc(100vw - 28px); text-align: center; line-height: 1.35; }
#toast.on { opacity: 1; }

/* docs/offline-pwa.md R-C15 — the PAGE must never scroll. */
html, body { overflow: hidden; overscroll-behavior: none; }
.scr { overscroll-behavior: contain; }
