/* Minesweeper — obsidian-glass board on a full-bleed dark field. */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  -webkit-tap-highlight-color: transparent;
  margin: 0; height: 100%; overflow: hidden;
  background: #0a0c0f;
  font-family: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: none; overscroll-behavior: none;
}

#canvas {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  cursor: pointer; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
  touch-action: none;
}

/* ---------- HUD (mine counter + timer) ---------- */
.hud {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left));
  z-index: 5; display: inline-flex; align-items: center; gap: 10px; pointer-events: none;
}
.hud__stat {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 13px;
  border-radius: 999px; border: 1px solid rgba(255,255,255,0.09);
  background: rgba(20,23,28,0.66); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: 0.02em; font-size: 0.95rem;
  color: #e9ecf2; box-shadow: 0 6px 18px -10px rgba(0,0,0,0.8);
}
.hud__ico { font-size: 0.86rem; line-height: 1; }
#mineStat .hud__ico { color: #e5484d; text-shadow: 0 0 10px rgba(229,72,77,0.6); }
#timeStat .hud__ico { color: #8b93a1; }

/* ---------- Top buttons ---------- */
.topbtns {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  z-index: 6; display: inline-flex; align-items: center; gap: 8px;
}
.pill, .iconbtn {
  appearance: none; font-family: inherit; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.12); background: rgba(22,25,31,0.7);
  color: #e9ecf2; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 120ms ease;
}
.pill { height: 36px; padding: 0 16px; border-radius: 999px; font-size: 0.82rem; font-weight: 800; letter-spacing: 0.03em; }
.iconbtn { width: 36px; height: 36px; border-radius: 50%; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; }
.pill:hover, .iconbtn:hover { border-color: rgba(255,255,255,0.32); }
.pill:active, .iconbtn:active { transform: translateY(1px); }
.pill:focus-visible, .iconbtn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(90,157,255,0.45); }
.iconbtn[aria-pressed="false"] { color: rgba(233,236,242,0.34); }
#diffBtn { min-width: 74px; }

/* ---------- overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 40%, rgba(14,17,22,0.82), rgba(5,6,9,0.95));
  backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px);
  transition: opacity 260ms ease;
}
.overlay[hidden] { display: none; }
.overlay.is-hidden { opacity: 0; pointer-events: none; }
.panel {
  text-align: center; max-width: 452px; padding: 34px 30px 30px; border-radius: 24px;
  background: rgba(17,20,26,0.92); border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 34px 90px -22px rgba(0,0,0,0.85), inset 0 1px 0 0 rgba(255,255,255,0.05);
  color: #c7cdd7;
  animation: pop 320ms cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel__title {
  margin: 0 0 10px; font-size: clamp(2.3rem, 9vw, 3.5rem); font-weight: 900; letter-spacing: -0.03em; line-height: 0.96;
  background: linear-gradient(176deg, #eaf1ff 0%, #9cc2ff 48%, #5a9dff 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 4px 22px rgba(90,157,255,0.28));
}
.panel__title.is-win {
  background: linear-gradient(176deg, #eafff2 0%, #7ff0b6 46%, #26c281 100%);
  filter: drop-shadow(0 4px 22px rgba(62,207,142,0.32));
}
.panel__title.is-lose {
  background: linear-gradient(176deg, #ffe9ea 0%, #ff9a9d 46%, #e5484d 100%);
  filter: drop-shadow(0 4px 22px rgba(229,72,77,0.32));
}
.panel__text { margin: 0 0 22px; font-size: clamp(0.95rem, 3.2vw, 1.04rem); line-height: 1.55; font-weight: 500; color: #aeb6c2; }
.play-btn {
  appearance: none; font-family: inherit; font-size: 1.05rem; font-weight: 800; color: #071018;
  background: linear-gradient(180deg, #a9ccff, #5a9dff); border: 0; padding: 15px 42px; border-radius: 999px;
  cursor: pointer; box-shadow: 0 12px 32px -8px rgba(90,157,255,0.6);
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.play-btn:hover { transform: translateY(-2px); box-shadow: 0 18px 42px -10px rgba(90,157,255,0.72); }
.play-btn:active { transform: translateY(0); }
.play-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(90,157,255,0.5); }

/* difficulty chips inside the overlay */
.panel__diffs { display: flex; gap: 8px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.chip {
  appearance: none; font-family: inherit; cursor: pointer; display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 15px; border-radius: 13px; border: 1px solid rgba(255,255,255,0.12); background: rgba(28,32,40,0.7);
  color: #d5dbe4; font-size: 0.82rem; font-weight: 800; letter-spacing: 0.02em;
  transition: border-color 140ms ease, background 140ms ease, transform 120ms ease;
}
.chip span { font-size: 0.62rem; font-weight: 600; letter-spacing: 0.04em; color: #7d8593; }
.chip:hover { border-color: rgba(255,255,255,0.3); }
.chip:active { transform: translateY(1px); }
.chip:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(90,157,255,0.45); }
.chip.is-active { border-color: rgba(90,157,255,0.7); background: rgba(90,157,255,0.16); color: #eaf1ff; }
.chip.is-active span { color: #9cc2ff; }

/* ---------- frame + hint ---------- */
.frame { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.frame__corner {
  position: absolute; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(200, 208, 222, 0.42);
}
.frame__corner--tl { display: none; } /* top-left holds the HUD counters */
.frame__corner--tr { display: none; } /* top-right holds the controls */
.frame__corner--bl { bottom: 14px; left: 16px; }
.frame__corner a { color: inherit; text-decoration: none; pointer-events: auto; }
.frame__corner a:hover { color: #9cc2ff; }

.hint {
  position: fixed; bottom: 15px; left: 50%; transform: translateX(-50%); z-index: 4; margin: 0;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; color: rgba(200, 208, 222, 0.5);
  pointer-events: none; white-space: nowrap; transition: opacity 300ms ease; max-width: 92vw; text-align: center;
}
.hint.is-gone { opacity: 0; }

@media (max-width: 620px) {
  .frame__corner--bl { display: none; }
  .hint { font-size: 0.66rem; letter-spacing: 0.02em; }
}
@media (max-width: 430px) {
  .hint { white-space: normal; line-height: 1.4; bottom: 10px; }
}

/* Dock the shared tip-jar / fullscreen badges bottom-right so they never sit
   over a board cell (their default is right-CENTRE). Doubled classes out-specify
   the components' injected styles; silence the right-centre entrance nudge. */
.opt-tipjar.opt-tipjar {
  top: auto; bottom: max(14px, env(safe-area-inset-bottom)); transform: none;
}
.opt-fs.opt-fs {
  top: auto; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 54px); transform: none;
}
.opt-tipjar.opt-tipjar.tj-nudge { animation: none; }
