/* Values below are fallback defaults only -- applyTheme() in main.js
   overwrites these from theme.js on load, so theme.js is the single
   source of truth for both canvas and CSS.

   v2: restrained, not decorated. Reference points: Linear.app (flat
   near-monochrome, zero gradients/glow, one accent used only on functional
   elements) and NYT Games (flat, purposeful color, no neon-for-its-own-sake).
   The accent (amber) appears ONLY where it does something -- focus/hover,
   the primary CTA, the flag marker, the win flare -- never as ambient
   decoration on headings, borders, or backgrounds. */
:root {
  --bg: #0a0a0b;
  --bg-core: #18140f;
  --panel: #131313;
  --glow: #e8a33d;
  --glow-soft: #c9c9cf;
  --danger: #e5484d;
  --safe: #8b8b93;
  --text: #e8e8ea;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  text-align: center;
  padding: 24px;
  /* min-width:0 overrides the flex item default of min-width:auto -- without
     it, main refuses to shrink below the canvas's natural pixel size and the
     canvas's own max-width:100% never gets a chance to engage on narrow
     viewports. */
  min-width: 0;
}

h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.02em;
  font-weight: 700;
}

.tagline {
  margin: 4px 0 20px;
  color: var(--safe);
  font-size: 0.9rem;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 16px;
}

.stat {
  background: var(--panel);
  border: 1px solid #232324;
  border-radius: 8px;
  padding: 6px 14px;
  font-variant-numeric: tabular-nums;
}

.stat .label {
  color: var(--safe);
  margin-right: 6px;
  font-size: 0.8rem;
}

button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid #2a2a2c;
  border-radius: 8px;
  padding: 6px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

button:hover,
button:focus-visible {
  border-color: var(--glow);
}

canvas {
  background: var(--panel);
  border: 1px solid #202020;
  border-radius: 12px;
  touch-action: none;
  max-width: 100%;
  height: auto;
}

.share-row {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: center;
}

.share-row input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid #2a2a2c;
  border-radius: 8px;
  padding: 6px 10px;
  width: 300px;
  text-align: center;
}

.board-wrap {
  position: relative;
  display: inline-block;
}

/* Gravity-well win cue: a brief warm pulse from the same corner mines drift
   toward -- functional (marks the win), not decorative confetti. */
.win-flare {
  position: absolute;
  top: 0;
  left: 0;
  width: 40%;
  height: 40%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle at 0% 0%, rgba(232, 163, 61, 0.85), rgba(232, 163, 61, 0.2) 40%, transparent 70%);
  opacity: 0;
  transform: scale(0.3);
}

.win-flare.play {
  animation: flare-pulse 900ms ease-out;
}

@keyframes flare-pulse {
  0% { opacity: 0; transform: scale(0.2); }
  35% { opacity: 1; transform: scale(1.3); }
  100% { opacity: 0; transform: scale(2.2); }
}

/* Result overlay: dim backdrop + scale-in card, shown on win or loss.
   Dismissible (backdrop click or Escape) per standard modal UX, so it never
   traps the player -- they can look at the board underneath if they want. */
.result-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.result-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.result-card {
  background: var(--panel);
  border: 1px solid #2a2a2c;
  border-radius: 16px;
  padding: 28px 32px;
  text-align: center;
  min-width: 280px;
  transform: scale(0.92);
  transition: transform 0.2s ease;
}

.result-overlay.visible .result-card {
  transform: scale(1);
}

.result-card h2 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 700;
}

.result-card p {
  margin: 0 0 16px;
  color: var(--safe);
  font-size: 0.9rem;
}

.result-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 12px;
}

.continuity {
  margin: 0 0 16px;
  font-size: 0.85rem;
  color: var(--safe);
}

#playAgainBtn {
  margin-top: 14px;
  background: var(--glow);
  color: #171104;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  cursor: pointer;
}

#playAgainBtn:hover {
  filter: brightness(1.08);
}

.hint {
  max-width: 420px;
  margin: 16px auto 0;
  color: var(--safe);
  font-size: 0.8rem;
  line-height: 1.4;
}
