@import "../css/tokens.css";

/* ==========================================================================
   Mine Field · Modern Tactical Radar Grid Theme
   Palette: Obsidian Slate (#0F172A), Slate Blue (#64748B), Radar Cyan (#06B6D4 / #38BDF8)
   ========================================================================== */

:root {
  --theme-bg: #0b1120;
  --theme-surface: #1e293b;
  --theme-surface-2: #334155;
  --theme-border: #475569;
  --theme-text: #f8fafc;
  --theme-text-muted: #94a3b8;
  --theme-accent: #38bdf8;
  --theme-accent-glow: rgba(56, 189, 248, 0.35);
  --theme-danger: #ef4444;
  --theme-danger-glow: rgba(239, 68, 68, 0.4);
  --theme-success: #22c55e;
  --theme-success-glow: rgba(34, 197, 94, 0.35);
  --theme-gold: #f59e0b;

  --board-max-width: 480px;
  --cell-radius: 6px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background-color: var(--theme-bg);
  color: var(--theme-text);
  font-family: var(--font-body);
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  background: 
    radial-gradient(circle at 50% 10%, rgba(56, 189, 248, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 50% 90%, rgba(15, 23, 42, 0.9) 0%, transparent 80%),
    var(--theme-bg);
}

/* ------------------- Hub Bar Header ------------------- */

.hub-bar {
  width: 100%;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(71, 85, 105, 0.4);
  padding: 0.625rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-xs);
  font-weight: 500;
  z-index: var(--z-nav);
}

.hub-bar a {
  color: var(--theme-accent);
  text-decoration: none;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: opacity var(--dur-micro) ease;
}

.hub-bar a:hover {
  opacity: 0.8;
}

.hub-bar span {
  color: var(--theme-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------- Ad Wells ------------------- */

.ad-rail {
  width: 100%;
  max-width: var(--board-max-width);
  margin: 0.75rem auto 0;
  padding: 0 0.75rem;
  text-align: center;
}

.ad-rail__label {
  font-size: 0.65rem;
  color: var(--theme-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.25rem;
}

.ad-well {
  min-height: 50px;
  background: rgba(30, 41, 59, 0.4);
  border: 1px dashed rgba(71, 85, 105, 0.3);
  border-radius: var(--radius-input);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ------------------- Main App Shell ------------------- */

.mine-app {
  width: 100%;
  max-width: var(--board-max-width);
  padding: 0.75rem 0.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* ------------------- Game Title & Header ------------------- */

.game-header {
  text-align: center;
  position: relative;
}

.game-kicker {
  font-family: var(--font-label);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--theme-accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

.game-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.game-sub {
  font-size: var(--text-xs);
  color: var(--theme-text-muted);
  margin-top: 0.15rem;
}

/* ------------------- Difficulty Tabs ------------------- */

.diff-tabs {
  display: flex;
  background: rgba(30, 41, 59, 0.7);
  padding: 0.25rem;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(71, 85, 105, 0.4);
  gap: 0.25rem;
}

.diff-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--theme-text-muted);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.5rem 0.25rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--dur-short) var(--ease-out);
  text-align: center;
}

.diff-tab:hover {
  color: #fff;
}

.diff-tab.is-active {
  background: var(--theme-accent);
  color: #0f172a;
  font-weight: 700;
  box-shadow: 0 2px 8px var(--theme-accent-glow);
}

/* ------------------- HUD Bar ------------------- */

.hud-panel {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-card);
  padding: 0.6rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.1),
    0 4px 14px rgba(0, 0, 0, 0.4);
}

.hud-display {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-family: var(--font-label);
  font-size: 0.65rem;
  color: var(--theme-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.15rem;
}

.digital-readout {
  font-family: var(--font-label);
  font-size: 1.45rem;
  font-weight: 800;
  background: #020617;
  color: #ef4444;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  border: 1px solid #1e293b;
  letter-spacing: 0.08em;
  line-height: 1;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
  min-width: 4rem;
  text-align: center;
}

.digital-readout--timer {
  color: var(--theme-accent);
  text-shadow: 0 0 8px var(--theme-accent-glow);
}

.btn-status {
  width: 2.85rem;
  height: 2.85rem;
  border-radius: var(--radius-pill);
  background: #334155;
  border: 2px solid #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.4rem;
  box-shadow: 
    inset 0 1px 2px rgba(255, 255, 255, 0.2),
    0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform var(--dur-micro) var(--ease-press), background var(--dur-short);
}

.btn-status:active {
  transform: scale(0.92);
}

.btn-status.is-won {
  background: rgba(34, 197, 94, 0.25);
  border-color: var(--theme-success);
  box-shadow: 0 0 12px var(--theme-success-glow);
}

.btn-status.is-lost {
  background: rgba(239, 68, 68, 0.25);
  border-color: var(--theme-danger);
  box-shadow: 0 0 12px var(--theme-danger-glow);
}

/* ------------------- Mode Switcher (Reveal vs Flag) ------------------- */

.mode-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.mode-toggle {
  flex: 1;
  display: flex;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(71, 85, 105, 0.4);
  border-radius: var(--radius-pill);
  padding: 0.2rem;
  gap: 0.25rem;
}

.mode-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--theme-text-muted);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--dur-short) var(--ease-out);
}

.mode-btn svg {
  flex-shrink: 0;
}

.mode-btn.is-active {
  background: #334155;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

#mode-reveal.is-active {
  background: var(--theme-accent);
  color: #0f172a;
}

#mode-flag.is-active {
  background: var(--theme-danger);
  color: #fff;
  box-shadow: 0 2px 8px var(--theme-danger-glow);
}

.tool-actions {
  display: flex;
  gap: 0.35rem;
}

.btn-tool {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(71, 85, 105, 0.4);
  color: var(--theme-text-muted);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  transition: all var(--dur-micro) ease;
}

.btn-tool:hover {
  background: #334155;
  color: #fff;
}

.btn-tool:active {
  transform: scale(0.95);
}

/* ------------------- Radar Board Container ------------------- */

.board-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid var(--theme-border);
  border-radius: var(--radius-card);
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.4),
    0 8px 24px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}

/* Subtle Radar Scanline Texture */
.board-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at center, rgba(56, 189, 248, 0.04) 0%, transparent 70%),
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(255, 255, 255, 0.015) 3px, rgba(255, 255, 255, 0.015) 6px);
  pointer-events: none;
}

.board-grid {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-columns: repeat(var(--cols, 8), 1fr);
  grid-template-rows: repeat(var(--rows, 8), 1fr);
  gap: 3px;
  user-select: none;
  -webkit-user-select: none;
}

/* ------------------- Grid Cells ------------------- */

.cell {
  position: relative;
  background: linear-gradient(145deg, #334155 0%, #1e293b 100%);
  border: 1px solid #475569;
  border-radius: var(--cell-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-label);
  font-weight: 800;
  font-size: clamp(0.75rem, 3.5vw, 1.25rem);
  cursor: pointer;
  padding: 0;
  transition: transform var(--dur-micro) var(--ease-press), background var(--dur-micro) ease;
  outline: none;
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.15),
    0 2px 3px rgba(0, 0, 0, 0.25);
}

.cell:focus-visible {
  box-shadow: 0 0 0 2px var(--theme-accent);
  z-index: 2;
}

.cell.is-hidden:hover {
  background: linear-gradient(145deg, #3b4c64 0%, #253347 100%);
  border-color: #64748b;
}

.cell.is-hidden:active {
  transform: scale(0.94);
}

/* Revealed Empty / Number */
.cell.is-revealed {
  background: #090e17;
  border: 1px solid rgba(51, 65, 85, 0.4);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  cursor: default;
}

.cell.is-empty {
  opacity: 0.6;
}

/* Distinct colored numbers for 1 through 8 */
.cell--1 { color: #38bdf8; text-shadow: 0 0 6px rgba(56, 189, 248, 0.4); }
.cell--2 { color: #22c55e; text-shadow: 0 0 6px rgba(34, 197, 94, 0.4); }
.cell--3 { color: #ef4444; text-shadow: 0 0 6px rgba(239, 68, 68, 0.4); }
.cell--4 { color: #818cf8; text-shadow: 0 0 6px rgba(129, 140, 248, 0.4); }
.cell--5 { color: #f43f5e; text-shadow: 0 0 6px rgba(244, 63, 94, 0.4); }
.cell--6 { color: #14b8a6; text-shadow: 0 0 6px rgba(20, 184, 166, 0.4); }
.cell--7 { color: #f59e0b; text-shadow: 0 0 6px rgba(245, 158, 11, 0.4); }
.cell--8 { color: #94a3b8; text-shadow: 0 0 6px rgba(148, 163, 184, 0.4); }

/* Flagged state */
.cell.is-flagged {
  background: linear-gradient(145deg, #334155 0%, #1e293b 100%);
}

.icon-flag {
  width: 60%;
  height: 60%;
  filter: drop-shadow(0 1px 4px rgba(239, 68, 68, 0.6));
  animation: flagPop 0.18s var(--ease-spring);
}

@keyframes flagPop {
  0% { transform: scale(0.4) rotate(-15deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Mine state */
.cell.is-mine {
  background: #0f172a;
}

.icon-mine {
  width: 65%;
  height: 65%;
}

/* Detonated mine */
.cell.is-detonated {
  background: #dc2626 !important;
  border-color: #f87171 !important;
  box-shadow: 0 0 16px var(--theme-danger-glow);
  animation: detonatedFlash 0.3s ease;
}

@keyframes detonatedFlash {
  0% { transform: scale(0.8); background: #ffffff; }
  50% { transform: scale(1.1); background: #ef4444; }
  100% { transform: scale(1); background: #dc2626; }
}

/* Wrong flag */
.cell.is-wrong-flag {
  background: rgba(239, 68, 68, 0.15);
}

.icon-wrong-flag {
  width: 65%;
  height: 65%;
}

/* ------------------- Overlay Sheet Modal ------------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 17, 32, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
  animation: fadeIn var(--dur-short) ease;
}

.overlay[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet {
  background: #1e293b;
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-card);
  width: 100%;
  max-width: 380px;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  position: relative;
  animation: slideUp var(--dur-short) var(--ease-spring);
}

@keyframes slideUp {
  from { transform: translateY(20px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.sheet--win {
  border-color: var(--theme-success);
  box-shadow: 0 0 24px var(--theme-success-glow);
}

.sheet--loss {
  border-color: var(--theme-danger);
  box-shadow: 0 0 24px var(--theme-danger-glow);
}

.sheet-kicker {
  font-family: var(--font-label);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--theme-accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sheet--loss .sheet-kicker {
  color: var(--theme-danger);
}

.sheet-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  margin: 0.25rem 0 0.75rem;
}

.overlay-hero-stat {
  background: #0f172a;
  border-radius: var(--radius-input);
  padding: 0.85rem;
  margin-bottom: 0.85rem;
  border: 1px solid rgba(71, 85, 105, 0.3);
}

.overlay-hero-stat.is-loss .hero-val {
  color: var(--theme-danger);
}

.hero-val {
  font-family: var(--font-label);
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--theme-accent);
  line-height: 1;
}

.hero-label {
  font-size: var(--text-xs);
  color: var(--theme-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

.record-badge {
  display: inline-block;
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid var(--theme-gold);
  color: var(--theme-gold);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-pill);
  margin-bottom: 0.85rem;
  animation: pulseGold 1.5s infinite;
}

@keyframes pulseGold {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.loss-note {
  font-size: var(--text-sm);
  color: var(--theme-text-muted);
  margin-bottom: 0.85rem;
}

.stat-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: #0f172a;
  padding: 0.75rem;
  border-radius: var(--radius-input);
  margin-bottom: 1.15rem;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
}

.stat-item .lbl {
  color: var(--theme-text-muted);
}

.stat-item .val {
  color: #fff;
  font-weight: 700;
  font-family: var(--font-label);
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-primary {
  width: 100%;
  background: var(--theme-accent);
  color: #0f172a;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--dur-micro) ease;
  box-shadow: 0 4px 12px var(--theme-accent-glow);
}

.sheet--loss .btn-primary {
  background: var(--theme-danger);
  color: #fff;
  box-shadow: 0 4px 12px var(--theme-danger-glow);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-secondary {
  width: 100%;
  background: #334155;
  color: var(--theme-text);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 0.65rem 1rem;
  border: 1px solid #475569;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--dur-micro) ease;
}

.btn-secondary:hover {
  background: #475569;
}

/* ------------------- HTML5 Dialog Modals (Stats & How) ------------------- */

dialog {
  background: #1e293b;
  color: var(--theme-text);
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-card);
  width: calc(100% - 2rem);
  max-width: 440px;
  padding: 1.5rem;
  margin: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  outline: none;
}

dialog::backdrop {
  background: rgba(11, 17, 32, 0.8);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.dialog-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.diff-stat-card {
  background: #0f172a;
  border: 1px solid rgba(71, 85, 105, 0.3);
  border-radius: var(--radius-input);
  padding: 0.75rem;
}

.stat-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.stat-card-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--theme-accent);
}

.stat-card-sub {
  font-size: 0.7rem;
  color: var(--theme-text-muted);
  font-family: var(--font-label);
}

.stat-card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  text-align: center;
}

.stat-cell {
  background: #1e293b;
  padding: 0.4rem 0.2rem;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
}

.sc-val {
  font-family: var(--font-label);
  font-size: var(--text-sm);
  font-weight: 700;
  color: #fff;
}

.sc-lbl {
  font-size: 0.65rem;
  color: var(--theme-text-muted);
  margin-top: 0.15rem;
}

.dialog-foot {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.btn-danger-outline {
  background: transparent;
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
  font-size: var(--text-xs);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* How to play ordered list */
.how-steps {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-left: 1.25rem;
  font-size: var(--text-sm);
  color: #cbd5e1;
  line-height: 1.45;
}

.how-steps li b {
  color: #fff;
}

/* ------------------- SEO Article & Editorial Notes ------------------- */

.game-article {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid rgba(71, 85, 105, 0.3);
  border-radius: var(--radius-card);
  padding: 1.25rem;
  margin-top: 1rem;
  color: #cbd5e1;
  font-size: var(--text-sm);
  line-height: 1.6;
}

.game-article h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
}

.game-article h3 {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--theme-accent);
  margin: 0.85rem 0 0.25rem;
}

.game-article p {
  margin-bottom: 0.5rem;
}

.game-article a {
  color: var(--theme-accent);
  text-decoration: underline;
}

.game-article code {
  font-family: var(--font-label);
  background: #0f172a;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.8em;
  color: var(--theme-accent);
}

/* ------------------- Footer ------------------- */

.game-footer {
  margin-top: auto;
  width: 100%;
  border-top: 1px solid rgba(71, 85, 105, 0.3);
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: var(--text-xs);
  color: var(--theme-text-muted);
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.footer-links a {
  color: var(--theme-text-muted);
  text-decoration: none;
  transition: color var(--dur-micro) ease;
}

.footer-links a:hover {
  color: var(--theme-accent);
}

/* ------------------- Responsive Adjustments ------------------- */

@media (max-width: 380px) {
  .digital-readout {
    font-size: 1.2rem;
    min-width: 3.4rem;
  }
  .btn-status {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.2rem;
  }
  .mode-btn {
    padding: 0.45rem 0.35rem;
    font-size: 0.7rem;
  }
}

/* ==========================================================================
   2026-09-28 ultracode pass: tabs, meta line, progress, juice, a11y
   ========================================================================== */

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.diff-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
  line-height: 1.15;
  min-height: 2.6rem;
  justify-content: center;
}
.diff-name { font-weight: 700; }
.diff-size { font-family: var(--font-label); font-size: 0.62rem; opacity: 0.8; }
.diff-tab--daily:not(.is-active) .diff-name { color: var(--theme-gold); }
.diff-tab:focus-visible,
.btn-tool:focus-visible,
.mode-btn:focus-visible,
.btn-status:focus-visible {
  outline: 2px solid var(--theme-accent);
  outline-offset: 2px;
}

.hud-meta {
  margin-top: -0.45rem;
  text-align: center;
  font-family: var(--font-label);
  font-size: 0.7rem;
  color: var(--theme-text-muted);
  letter-spacing: 0.02em;
  min-height: 1em;
}

.how-line {
  margin-top: -0.35rem;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--theme-text-muted);
  text-align: center;
}
.how-line[hidden] { display: none; }

/* Board: stop double-tap zoom and text selection; scrolling the page still works. */
.board-grid {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
}
.board-grid[data-size="m"] .cell { font-size: clamp(0.7rem, 3.4vw, 1.05rem); }
.board-grid[data-size="l"] { gap: 2px; }
.board-grid[data-size="l"] .cell { font-size: clamp(0.62rem, 2.9vw, 0.9rem); border-radius: 4px; }
.cell { -webkit-tap-highlight-color: transparent; }
.board-grid.is-flag-mode .cell.is-hidden { box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.35), 0 2px 3px rgba(0, 0, 0, 0.25); }

.progress-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: rgba(15, 23, 42, 0.6);
  z-index: 2;
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--theme-accent), var(--theme-success));
  transition: width 0.35s ease-out;
}

.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}
.spark {
  position: absolute;
  width: 6px; height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--c, #fff);
  box-shadow: 0 0 6px var(--c, #fff);
  animation: sparkFly 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
@keyframes sparkFly {
  0% { transform: translate(0, 0) scale(1.2); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

/* Staggered reveal wave from the tapped tile */
.cell.reveal-in { animation: revealIn 0.26s var(--ease-spring) both; animation-delay: var(--d, 0ms); }
@keyframes revealIn {
  0% { transform: scale(0.55); opacity: 0.2; background: rgba(56, 189, 248, 0.35); }
  60% { background: rgba(56, 189, 248, 0.12); }
  100% { transform: scale(1); opacity: 1; }
}
.cell.is-empty.reveal-in { animation-name: revealInEmpty; }
@keyframes revealInEmpty {
  0% { transform: scale(0.55); opacity: 0.1; background: rgba(56, 189, 248, 0.3); }
  100% { transform: scale(1); opacity: 0.6; }
}
.cell.mine-in { animation: mineIn 0.3s ease-out both; animation-delay: var(--d, 0ms); }
@keyframes mineIn {
  0% { transform: scale(0.3); opacity: 0; background: #7f1d1d; }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}
.cell.win-flag { animation: winFlag 0.45s var(--ease-spring) both; animation-delay: var(--d, 0ms); }
@keyframes winFlag {
  0% { transform: scale(1); }
  50% { transform: scale(1.18); background: rgba(34, 197, 94, 0.45); }
  100% { transform: scale(1); background: rgba(34, 197, 94, 0.18); }
}
.board-wrap.is-won { border-color: var(--theme-success); box-shadow: 0 0 0 2px var(--theme-success-glow), 0 8px 24px rgba(0, 0, 0, 0.5); transition: border-color 0.4s, box-shadow 0.4s; }
.board-wrap.is-lost { border-color: var(--theme-danger); }
.board-wrap.is-shaking { animation: boardShake 0.45s ease-out; }
@keyframes boardShake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-6px, 3px); }
  30% { transform: translate(5px, -4px); }
  45% { transform: translate(-4px, 2px); }
  60% { transform: translate(3px, -2px); }
  80% { transform: translate(-1px, 1px); }
}

/* Long-press progress ring */
.cell.is-pressing::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  border: 2px solid #ef4444;
  animation: pressRing 0.32s linear forwards;
  pointer-events: none;
}
@keyframes pressRing {
  0% { opacity: 0; transform: scale(1.35); }
  100% { opacity: 1; transform: scale(1); }
}

/* Daily start beacon, chord hint, nudge */
.cell.is-start {
  border-color: var(--theme-gold);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.45), 0 0 14px rgba(245, 158, 11, 0.45);
  animation: beacon 1.4s ease-in-out infinite;
}
.cell.is-start::before {
  content: "";
  width: 30%; height: 30%;
  border-radius: 50%;
  background: var(--theme-gold);
  box-shadow: 0 0 8px var(--theme-gold);
}
@keyframes beacon {
  0%, 100% { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.45), 0 0 8px rgba(245, 158, 11, 0.3); }
  50% { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.8), 0 0 18px rgba(245, 158, 11, 0.6); }
}
.cell.is-hint { animation: hintFlash 0.6s ease-out; }
@keyframes hintFlash {
  0%, 100% { background: linear-gradient(145deg, #334155 0%, #1e293b 100%); }
  35% { background: rgba(245, 158, 11, 0.55); }
}
.cell.is-nudge { animation: nudge 0.45s ease-out; }
@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}

/* End sheet extras */
.delta-line {
  text-align: center;
  font-family: var(--font-label);
  font-size: 0.78rem;
  color: var(--theme-text-muted);
  margin: -0.25rem 0 0.6rem;
}
.delta-line.is-good { color: var(--theme-success); }
.loss-meter {
  height: 8px;
  border-radius: 999px;
  background: #0f172a;
  border: 1px solid var(--theme-border);
  overflow: hidden;
  margin: 0 0 0.6rem;
}
.loss-meter span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #f59e0b);
}

@media (max-width: 380px) {
  .diff-tab { font-size: 0.68rem; padding: 0.4rem 0.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cell, .cell.reveal-in, .cell.mine-in, .cell.win-flag, .cell.is-start,
  .cell.is-hint, .cell.is-nudge, .board-wrap.is-shaking, .icon-flag,
  .cell.is-detonated, .spark {
    animation: none !important;
    transition: none !important;
  }
  .cell.is-pressing::after { animation: none; opacity: 1; }
  .progress-bar span { transition: none; }
}
