/* ============ Theme Tokens ============ */
:root,
[data-theme="neumorphic"] {
  --bg: #e6ecf3;
  --bg-2: #dde4ec;
  --surface: #e6ecf3;
  --shadow-light: #ffffff;
  --shadow-dark: #c1c9d2;
  --text: #4a5568;
  --text-soft: #8a94a3;
  --accent: #5b8def;
  --danger: #ff6b6b;
  --success: #4cd7a0;
  --warning: #ffb84d;
  --n1: #2b6cff;
  --n2: #1ea874;
  --n3: #e64545;
  --n4: #7a3fde;
  --n5: #d68a1a;
  --n6: #1d8a9a;
  --n7: #b8326a;
  --n8: #2c2c2c;
  --flag: #e64545;
  --flag-pole: #2c2c2c;
  --mine-core-1: #ff8a8a;
  --mine-core-2: #ff6b6b;
  --mine-core-3: #c44545;
  --mine-glow: rgba(255, 107, 107, 0.6);
  --cell-revealed-bg: #dde4ec;
  --hint-bg: #c7d8f5;
  --wrong-flag: #ffb84d;
  --body-grad-1: #f0f4fa;
  --body-grad-2: #d8dfe8;
  --body-bg: #e6ecf3;
  --btn-glow: rgba(91, 141, 239, 0.0);
  --title-shadow-light: #ffffff;
  --title-shadow-dark: #c1c9d2;
  --cell-size: 34px;
  --cell-font: 15px;
  --board-radius: 24px;
  --style: "neumorphic";
}

[data-theme="neon"] {
  --bg: #0a0e1a;
  --bg-2: #111729;
  --surface: #131a2e;
  --shadow-light: #1d2747;
  --shadow-dark: #050810;
  --text: #e6f1ff;
  --text-soft: #6b7a9e;
  --accent: #00f0ff;
  --danger: #ff2d6f;
  --success: #00ffa3;
  --warning: #ffb84d;
  --n1: #00f0ff;
  --n2: #00ffa3;
  --n3: #ff2d6f;
  --n4: #b14dff;
  --n5: #ffd700;
  --n6: #00d4ff;
  --n7: #ff6bd1;
  --n8: #ffffff;
  --flag: #ff2d6f;
  --flag-pole: #e6f1ff;
  --mine-core-1: #ff8aa8;
  --mine-core-2: #ff2d6f;
  --mine-core-3: #8b0a32;
  --mine-glow: rgba(255, 45, 111, 0.8);
  --cell-revealed-bg: #0e1426;
  --hint-bg: rgba(0, 240, 255, 0.35);
  --wrong-flag: #ffd700;
  --body-grad-1: #0d1430;
  --body-grad-2: #050810;
  --body-bg: #0a0e1a;
  --btn-glow: rgba(0, 240, 255, 0.45);
  --title-shadow-light: #1d2747;
  --title-shadow-dark: #050810;
  --style: "neon";
}

[data-theme="minimal"] {
  --bg: #fafafa;
  --bg-2: #f0f0f0;
  --surface: #ffffff;
  --shadow-light: #ffffff;
  --shadow-dark: #e0e0e0;
  --text: #1a1a1a;
  --text-soft: #888888;
  --accent: #1a1a1a;
  --danger: #d32f2f;
  --success: #2e7d32;
  --warning: #ed6c02;
  --n1: #1976d2;
  --n2: #388e3c;
  --n3: #d32f2f;
  --n4: #7b1fa2;
  --n5: #f57c00;
  --n6: #0097a7;
  --n7: #c2185b;
  --n8: #212121;
  --flag: #d32f2f;
  --flag-pole: #212121;
  --mine-core-1: #ef5350;
  --mine-core-2: #d32f2f;
  --mine-core-3: #b71c1c;
  --mine-glow: rgba(211, 47, 47, 0.4);
  --cell-revealed-bg: #f5f5f5;
  --hint-bg: #e3f2fd;
  --wrong-flag: #ed6c02;
  --body-grad-1: #ffffff;
  --body-grad-2: #eeeeee;
  --body-bg: #fafafa;
  --btn-glow: rgba(0, 0, 0, 0.0);
  --title-shadow-light: #ffffff;
  --title-shadow-dark: #e0e0e0;
  --style: "minimal";
}

/* Smooth cross-theme transitions */
*,
*::before,
*::after {
  transition:
    background-color 0.45s ease,
    color 0.45s ease,
    box-shadow 0.45s ease,
    border-color 0.45s ease,
    text-shadow 0.45s ease,
    fill 0.45s ease,
    stroke 0.45s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(circle at 15% 15%, var(--body-grad-1) 0%, transparent 50%),
    radial-gradient(circle at 85% 85%, var(--body-grad-2) 0%, transparent 50%),
    var(--body-bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.app {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* ============ Theme Switcher ============ */
.theme-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 16px;
  background: var(--bg);
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light);
}

.theme-btn {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.3s ease, transform 0.2s ease;
}

.theme-btn:hover {
  color: var(--text);
  transform: translateY(-1px);
}

.theme-btn.active {
  color: var(--text);
}

.theme-btn .theme-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 1px 1px 2px rgba(0,0,0,0.2), inset -1px -1px 2px rgba(255,255,255,0.4);
  transition: box-shadow 0.3s ease;
}

.theme-btn:hover .theme-dot {
  box-shadow: inset 1px 1px 2px rgba(0,0,0,0.2), inset -1px -1px 2px rgba(255,255,255,0.4), 0 0 6px var(--btn-glow);
}

.theme-indicator {
  position: absolute;
  top: 6px;
  left: 6px;
  height: calc(100% - 12px);
  border-radius: 10px;
  background: var(--bg);
  box-shadow:
    3px 3px 6px var(--shadow-dark),
    -3px -3px 6px var(--shadow-light);
  z-index: 0;
  pointer-events: none;
  transition: transform 0.45s cubic-bezier(0.4, 0.0, 0.2, 1), width 0.45s cubic-bezier(0.4, 0.0, 0.2, 1);
}

[data-theme="neon"] .theme-btn.active,
[data-theme="neon"] .theme-btn:hover {
  color: var(--accent);
  text-shadow: 0 0 6px var(--accent);
}

[data-theme="neon"] .theme-indicator {
  box-shadow:
    inset 0 0 8px var(--accent),
    0 0 12px color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--bg) 60%, var(--accent));
}

[data-theme="minimal"] .theme-btn.active {
  color: var(--text);
}

[data-theme="minimal"] .theme-indicator {
  box-shadow:
    2px 2px 4px var(--shadow-dark),
    -2px -2px 4px var(--shadow-light);
}

/* Neon: glow on every interactive surface */
[data-theme="neon"] .face-btn {
  box-shadow:
    0 0 6px var(--shadow-light),
    0 0 12px color-mix(in srgb, var(--accent) 30%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}

[data-theme="neon"] .face-btn:hover {
  box-shadow:
    0 0 10px var(--accent),
    0 0 18px color-mix(in srgb, var(--accent) 50%, transparent);
  color: var(--accent);
}

[data-theme="neon"] .control-panel,
[data-theme="neon"] .board-wrapper,
[data-theme="neon"] .difficulty-panel {
  box-shadow:
    0 0 12px color-mix(in srgb, var(--accent) 18%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 15%, transparent);
}

[data-theme="neon"] .stat-box,
[data-theme="neon"] .diff-btn.active,
[data-theme="neon"] .cell {
  box-shadow:
    inset 0 0 6px color-mix(in srgb, var(--accent) 18%, transparent),
    0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

[data-theme="neon"] .overlay-content,
[data-theme="neon"] .overlay-btn {
  box-shadow:
    0 0 12px color-mix(in srgb, var(--accent) 30%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}

[data-theme="neon"] .overlay-title.win {
  text-shadow: 0 0 8px var(--success), 0 0 18px var(--success);
}
[data-theme="neon"] .overlay-title.lose {
  text-shadow: 0 0 8px var(--danger), 0 0 18px var(--danger);
}

/* Minimal: clean flat with subtle borders */
[data-theme="minimal"] {
  --shadow-light: #ffffff;
  --shadow-dark: #e0e0e0;
}

[data-theme="minimal"] .control-panel,
[data-theme="minimal"] .board-wrapper,
[data-theme="minimal"] .theme-switcher,
[data-theme="minimal"] .difficulty-panel,
[data-theme="minimal"] .face-btn,
[data-theme="minimal"] .overlay-content,
[data-theme="minimal"] .overlay-btn,
[data-theme="minimal"] .theme-indicator,
[data-theme="minimal"] .diff-btn.active {
  box-shadow:
    0 0 0 1px #d0d0d0,
    2px 2px 4px var(--shadow-dark),
    -2px -2px 4px var(--shadow-light);
}

[data-theme="minimal"] .stat-box,
[data-theme="minimal"] .cell.revealed,
[data-theme="minimal"] .cell.mine,
[data-theme="minimal"] .cell.wrong-flag {
  box-shadow: inset 0 0 0 1px #e0e0e0;
}

[data-theme="minimal"] .cell {
  box-shadow:
    0 0 0 1px #d0d0d0,
    1px 1px 2px var(--shadow-dark),
    -1px -1px 2px var(--shadow-light);
}

[data-theme="minimal"] .cell:active:not(.revealed):not(.flagged) {
  box-shadow: inset 0 0 0 1px #c0c0c0;
}

/* ============ Header ============ */
.header {
  text-align: center;
  margin-bottom: 4px;
}

.title {
  font-size: 32px;
  font-weight: 300;
  letter-spacing: 12px;
  padding-left: 12px;
  color: var(--text);
  text-shadow: 1px 1px 0 var(--title-shadow-light), -1px -1px 0 var(--title-shadow-dark);
}

.subtitle {
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--text-soft);
  margin-top: 4px;
  text-transform: uppercase;
}

/* ============ Neumorphic Mixins ============ */
.neu-raised {
  background: var(--bg);
  box-shadow:
    8px 8px 16px var(--shadow-dark),
    -8px -8px 16px var(--shadow-light);
}

.neu-raised-sm {
  background: var(--bg);
  box-shadow:
    4px 4px 8px var(--shadow-dark),
    -4px -4px 8px var(--shadow-light);
}

.neu-pressed {
  background: var(--bg);
  box-shadow:
    inset 4px 4px 8px var(--shadow-dark),
    inset -4px -4px 8px var(--shadow-light);
}

.neu-pressed-sm {
  background: var(--bg);
  box-shadow:
    inset 2px 2px 4px var(--shadow-dark),
    inset -2px -2px 4px var(--shadow-light);
}

/* ============ Control Panel ============ */
.control-panel {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  padding: 20px 24px;
  border-radius: 20px;
  background: var(--bg);
  box-shadow:
    8px 8px 16px var(--shadow-dark),
    -8px -8px 16px var(--shadow-light);
}

.stat-box {
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--bg);
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light);
  text-align: center;
  min-width: 0;
}

.stat-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-soft);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-value {
  font-family: "SF Mono", "Monaco", "Courier New", monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}

.face-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    6px 6px 12px var(--shadow-dark),
    -6px -6px 12px var(--shadow-light);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.face-btn:hover {
  color: var(--accent);
}

.face-btn:active,
.face-btn.surprised {
  box-shadow:
    inset 4px 4px 8px var(--shadow-dark),
    inset -4px -4px 8px var(--shadow-light);
  transform: scale(0.96);
}

.face-btn.lost {
  color: var(--danger);
}

.face-btn.won {
  color: var(--success);
}

.face-icon {
  width: 28px;
  height: 28px;
}

/* ============ Difficulty Panel ============ */
.difficulty-panel {
  display: flex;
  gap: 12px;
  padding: 8px;
  border-radius: 16px;
  background: var(--bg);
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light);
}

.diff-btn {
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.25s ease;
}

.diff-btn:hover {
  color: var(--text);
}

.diff-btn.active {
  color: var(--accent);
  background: var(--bg);
  box-shadow:
    3px 3px 6px var(--shadow-dark),
    -3px -3px 6px var(--shadow-light);
  font-weight: 600;
}

/* ============ Board ============ */
.board-wrapper {
  position: relative;
  padding: 20px;
  border-radius: var(--board-radius);
  background: var(--bg);
  box-shadow:
    10px 10px 20px var(--shadow-dark),
    -10px -10px 20px var(--shadow-light);
  max-width: 100%;
  width: max-content;
  max-width: min(100%, calc(100vw - 32px));
}

.board {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 16px;
  background: var(--bg);
  box-shadow:
    inset 5px 5px 10px var(--shadow-dark),
    inset -5px -5px 10px var(--shadow-light);
  margin: 0 auto;
  width: max-content;
  touch-action: manipulation;
}

/* ============ Cell ============ */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "SF Mono", "Monaco", "Courier New", monospace;
  font-size: var(--cell-font);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: box-shadow 0.15s ease, color 0.15s ease, background 0.15s ease;
  box-shadow:
    3px 3px 6px var(--shadow-dark),
    -3px -3px 6px var(--shadow-light);
  color: transparent;
  pointer-events: auto;
}

.cell:hover:not(.revealed):not(.flagged) {
  color: var(--text-soft);
}

.cell:active:not(.revealed):not(.flagged) {
  box-shadow:
    inset 2px 2px 4px var(--shadow-dark),
    inset -2px -2px 4px var(--shadow-light);
}

.cell.revealed {
  background: var(--cell-revealed-bg);
  box-shadow:
    inset 1px 1px 2px var(--shadow-dark),
    inset -1px -1px 2px var(--shadow-light);
  cursor: default;
  animation: cellReveal 0.3s ease;
}

@keyframes cellReveal {
  0% {
    transform: scale(0.7);
    opacity: 0;
  }
  60% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.cell.flagged {
  color: var(--flag);
}

.cell.flagged::before {
  content: "";
  width: 4px;
  height: 14px;
  background: var(--flag-pole);
  border-radius: 2px;
  position: absolute;
  bottom: 6px;
  box-shadow: 0 0 2px rgba(0,0,0,0.2);
}

.cell.flagged::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-left: 7px solid var(--flag);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  top: 8px;
  left: 50%;
  transform: translateX(-7px);
  filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.15));
  animation: flagPlant 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="neon"] .cell.flagged::after {
  filter: drop-shadow(0 0 4px var(--flag));
}

@keyframes flagPlant {
  0% {
    transform: translateX(-7px) translateY(-10px) scale(0);
    opacity: 0;
  }
  100% {
    transform: translateX(-7px) translateY(0) scale(1);
    opacity: 1;
  }
}

.cell.n1 {
  color: var(--n1);
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255,255,255,0.08);
}
.cell.n2 {
  color: var(--n2);
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255,255,255,0.08);
}
.cell.n3 {
  color: var(--n3);
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255,255,255,0.08);
}
.cell.n4 {
  color: var(--n4);
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255,255,255,0.08);
}
.cell.n5 {
  color: var(--n5);
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255,255,255,0.08);
}
.cell.n6 {
  color: var(--n6);
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255,255,255,0.08);
}
.cell.n7 {
  color: var(--n7);
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255,255,255,0.08);
}
.cell.n8 {
  color: var(--n8);
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255,255,255,0.08);
}

[data-theme="neumorphic"] .cell.n1,
[data-theme="neumorphic"] .cell.n2,
[data-theme="neumorphic"] .cell.n3,
[data-theme="neumorphic"] .cell.n4,
[data-theme="neumorphic"] .cell.n5,
[data-theme="neumorphic"] .cell.n6,
[data-theme="neumorphic"] .cell.n7,
[data-theme="neumorphic"] .cell.n8 {
  text-shadow:
    0 1px 0 rgba(255,255,255,0.9),
    0 -1px 0 rgba(0,0,0,0.08);
}

[data-theme="neon"] .cell.n1 {
  text-shadow: 0 0 6px var(--n1), 0 0 12px var(--n1);
}
[data-theme="neon"] .cell.n2 {
  text-shadow: 0 0 6px var(--n2), 0 0 12px var(--n2);
}
[data-theme="neon"] .cell.n3 {
  text-shadow: 0 0 6px var(--n3), 0 0 12px var(--n3);
}
[data-theme="neon"] .cell.n4 {
  text-shadow: 0 0 6px var(--n4), 0 0 12px var(--n4);
}
[data-theme="neon"] .cell.n5 {
  text-shadow: 0 0 6px var(--n5), 0 0 12px var(--n5);
}
[data-theme="neon"] .cell.n6 {
  text-shadow: 0 0 6px var(--n6), 0 0 12px var(--n6);
}
[data-theme="neon"] .cell.n7 {
  text-shadow: 0 0 6px var(--n7), 0 0 12px var(--n7);
}
[data-theme="neon"] .cell.n8 {
  text-shadow: 0 0 6px var(--n8), 0 0 12px var(--n8);
}

/* Mine */
.cell.mine {
  color: var(--danger);
  background: var(--cell-revealed-bg);
  box-shadow:
    inset 1px 1px 2px var(--shadow-dark),
    inset -1px -1px 2px var(--shadow-light);
}

.cell.mine::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  background: radial-gradient(circle at 35% 30%, var(--mine-core-1), var(--mine-core-2) 60%, var(--mine-core-3));
  border-radius: 50%;
  box-shadow:
    inset -2px -2px 3px rgba(0,0,0,0.3),
    inset 2px 2px 3px rgba(255,255,255,0.4),
    0 0 8px var(--mine-glow);
  animation: mineExplode 0.4s ease;
}

[data-theme="neon"] .cell.mine {
  background: var(--cell-revealed-bg);
  box-shadow:
    inset 0 0 6px rgba(255, 45, 111, 0.4),
    0 0 8px var(--mine-glow);
}

[data-theme="neon"] .cell.mine::after {
  box-shadow:
    inset -1px -1px 2px rgba(0,0,0,0.5),
    inset 1px 1px 2px rgba(255,255,255,0.5),
    0 0 10px var(--mine-glow),
    0 0 18px var(--mine-glow);
}

@keyframes mineExplode {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.4);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

.cell.mine-triggered {
  background: color-mix(in srgb, var(--danger) 30%, var(--cell-revealed-bg));
  animation: mineBlast 0.5s ease;
}

@keyframes mineBlast {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.15); box-shadow: 0 0 20px var(--mine-glow); }
  60% { transform: scale(0.95); }
}

.cell.wrong-flag {
  color: var(--wrong-flag);
  background: var(--cell-revealed-bg);
}

.cell.wrong-flag::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 18px;
  background: var(--wrong-flag);
  border-radius: 2px;
  transform: rotate(45deg);
  box-shadow: 6px 6px 0 var(--wrong-flag);
}

.cell.hint {
  animation: cellHint 0.4s ease;
}

@keyframes cellHint {
  0%, 100% { background: var(--cell-revealed-bg); }
  50% { background: var(--hint-bg); }
}

[data-theme="neon"] .cell.hint {
  animation: cellHintNeon 0.4s ease;
}

@keyframes cellHintNeon {
  0%, 100% { background: var(--cell-revealed-bg); }
  50% { background: var(--hint-bg); box-shadow: inset 0 0 10px var(--accent), 0 0 10px var(--accent); }
}

/* ============ Overlay ============ */
.board-overlay {
  position: absolute;
  inset: 0;
  border-radius: var(--board-radius);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0s linear 0.4s;
  z-index: 10;
}

.board-overlay.show {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition: opacity 0.4s ease, visibility 0s linear 0s;
}

.overlay-content {
  text-align: center;
  padding: 40px 50px;
  border-radius: 24px;
  background: var(--bg);
  box-shadow:
    10px 10px 20px var(--shadow-dark),
    -10px -10px 20px var(--shadow-light);
  animation: overlayIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes overlayIn {
  0% {
    transform: scale(0.7) translateY(20px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.overlay-title {
  font-size: 36px;
  font-weight: 200;
  letter-spacing: 8px;
  margin-bottom: 8px;
}

.overlay-title.win {
  color: var(--success);
  text-shadow: 0 0 20px color-mix(in srgb, var(--success) 40%, transparent);
}

.overlay-title.lose {
  color: var(--danger);
  text-shadow: 0 0 20px color-mix(in srgb, var(--danger) 40%, transparent);
}

.overlay-sub {
  font-size: 13px;
  color: var(--text-soft);
  letter-spacing: 2px;
  margin-bottom: 24px;
}

.overlay-btn {
  padding: 12px 32px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  border: none;
  border-radius: 12px;
  background: var(--bg);
  color: var(--accent);
  cursor: pointer;
  box-shadow:
    5px 5px 10px var(--shadow-dark),
    -5px -5px 10px var(--shadow-light);
  transition: all 0.2s ease;
}

.overlay-btn:hover {
  color: var(--text);
}

.overlay-btn:active {
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light);
}

/* ============ Footer ============ */
.footer {
  display: flex;
  gap: 24px;
  font-size: 12px;
  color: var(--text-soft);
  letter-spacing: 1px;
  margin-top: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--bg);
  box-shadow:
    2px 2px 4px var(--shadow-dark),
    -2px -2px 4px var(--shadow-light);
  position: relative;
}

.key.left::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 4px var(--accent);
}

.key.right::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 4px var(--danger);
}

/* ============ Responsive ============ */
@media (max-width: 600px) {
  .title { font-size: 22px; letter-spacing: 5px; }
  .control-panel { padding: 14px 16px; gap: 12px; }
  .face-btn { width: 50px; height: 50px; }
  .face-icon { width: 22px; height: 22px; }
  .stat-value { font-size: 18px; }
  .stat-box { padding: 10px 12px; }
  .diff-btn { padding: 6px 12px; font-size: 10px; }
  .footer { flex-direction: column; gap: 6px; align-items: center; }
}

@media (max-width: 420px) {
  .board-wrapper { padding: 14px; }
  .board { gap: 4px; padding: 8px; }
  .difficulty-panel { gap: 6px; padding: 6px; }
  .diff-btn { padding: 6px 10px; }
}

/* Shake animation on mine click */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.board.shake {
  animation: shake 0.4s ease;
}

/* Confetti for win */
.confetti {
  position: fixed;
  width: 8px;
  height: 8px;
  pointer-events: none;
  z-index: 100;
  border-radius: 2px;
}
