/* Minesweeper page styles — pairs with ../../shared.css */
:root {
  --cell-cover: #ecdcb4;
  --cell-cover-2: #e2d09f;
  --cell-cover-hover: #f1e3bf;
  --cell-revealed: #fbf6ea;
  --cell-revealed-2: #f5ecd5;
  --cell-edge: #cdbd95;
  --cell-edge-soft: #ddd0ad;
  --mine: #2a1c12;
  --mine-bg: #f0c8c0;
  --flag: #c0392b;

  --n1: #1f3a5f; /* navy-blue, classic 1 */
  --n2: #2e7d4f; /* green */
  --n3: #c0392b; /* red */
  --n4: #1c2a5a; /* navy */
  --n5: #8a4a2b; /* brown */
  --n6: #2a8a8a; /* teal */
  --n7: #1c2a3a; /* black */
  --n8: #7a7565; /* grey */
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: clamp(28px, 4.4vw, 40px);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.05;
}
.page-head .sub {
  color: var(--ink-soft);
  margin: 6px 0 0;
  font-size: 14px;
  min-height: 1.4em;
}
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.play {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* Difficulty tabs */
.difficulty {
  display: inline-flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow);
}
.diff-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: 600 13px 'Inter', sans-serif;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
}
.diff-btn:hover { color: var(--ink); }
.diff-btn.is-active {
  background: var(--accent);
  color: var(--paper);
  box-shadow: 0 6px 16px -8px rgba(31, 58, 95, 0.5);
}

/* Game chrome (mine count / face / timer) */
.game-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.stat {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 16px;
  min-width: 96px;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
}
.stat-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  display: block;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  line-height: 1;
}

.face-wrap { display: flex; justify-content: center; flex: 1; }
.face {
  appearance: none;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 120ms ease, background 160ms ease;
  box-shadow: var(--shadow);
}
.face:hover { background: #f9e7b8; }
.face:active { transform: translateY(1px); }
.face svg { width: 30px; height: 30px; }
.face .face-bg { fill: #f4d96b; stroke: #1f3a5f; stroke-width: 1.4; }
.face .face-features { fill: #1f3a5f; stroke: #1f3a5f; }
.face[data-mood="lost"] .face-bg { fill: #ecb4a8; }
.face[data-mood="lost"] .face-mouth { d: path("M11 22 Q16 18.5 21 22"); }
.face[data-mood="won"] .face-bg { fill: #b6e0c2; }

/* Board */
.board-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  margin: 0 -4px;
}
.board {
  display: grid;
  gap: 2px;
  padding: 6px;
  background: var(--cell-edge);
  border: 1px solid var(--cell-edge);
  border-radius: 8px;
  width: max-content;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.cell {
  appearance: none;
  width: var(--cell-size, 30px);
  height: var(--cell-size, 30px);
  border: 0;
  margin: 0;
  padding: 0;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 900;
  font-size: calc(var(--cell-size, 30px) * 0.55);
  line-height: 1;
  cursor: pointer;
  background: linear-gradient(180deg, var(--cell-cover) 0%, var(--cell-cover-2) 100%);
  color: transparent;
  border-radius: 4px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.5),
    inset 0 -2px 0 rgba(31,58,95,0.08);
  transition: background 120ms ease, transform 80ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-variant-numeric: tabular-nums;
}
.cell:hover:not(.is-revealed):not(:disabled) {
  background: var(--cell-cover-hover);
}
.cell:focus { outline: none; }
.cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  z-index: 2;
}

.cell.is-revealed {
  background: linear-gradient(180deg, var(--cell-revealed) 0%, var(--cell-revealed-2) 100%);
  box-shadow:
    inset 0 0 0 1px var(--cell-edge-soft);
  cursor: default;
}
.cell.is-revealed[data-n="0"] { color: transparent; }
.cell.is-revealed[data-n="1"] { color: var(--n1); }
.cell.is-revealed[data-n="2"] { color: var(--n2); }
.cell.is-revealed[data-n="3"] { color: var(--n3); }
.cell.is-revealed[data-n="4"] { color: var(--n4); }
.cell.is-revealed[data-n="5"] { color: var(--n5); }
.cell.is-revealed[data-n="6"] { color: var(--n6); }
.cell.is-revealed[data-n="7"] { color: var(--n7); }
.cell.is-revealed[data-n="8"] { color: var(--n8); }

.cell.is-flag::before {
  content: "";
  position: absolute;
  width: 50%;
  height: 50%;
  background:
    radial-gradient(circle at 35% 35%, #d96a5c 0%, var(--flag) 70%);
  clip-path: polygon(20% 6%, 96% 30%, 20% 54%);
  left: 14%;
  top: 14%;
}
.cell.is-flag::after {
  content: "";
  position: absolute;
  width: 8%;
  height: 70%;
  background: var(--ink);
  left: 18%;
  top: 14%;
  border-radius: 2px;
}

.cell.is-mine {
  background: var(--mine-bg);
}
.cell.is-mine::before {
  content: "";
  position: absolute;
  width: 46%;
  height: 46%;
  background: var(--mine);
  border-radius: 50%;
  left: 27%;
  top: 27%;
  box-shadow:
    0 0 0 2px var(--mine-bg),
    8px -3px 0 -6px var(--mine),
    -8px 3px 0 -6px var(--mine),
    -8px -3px 0 -6px var(--mine),
    8px 3px 0 -6px var(--mine);
}
.cell.is-mine::after {
  content: "";
  position: absolute;
  width: 14%;
  height: 14%;
  background: #fff;
  border-radius: 50%;
  left: 32%;
  top: 32%;
}
.cell.is-mine-hit {
  background: #e89c92;
  animation: ms-explode 500ms ease-out;
}
@keyframes ms-explode {
  0%   { transform: scale(1); background: #ff4b3f; }
  40%  { transform: scale(1.25); background: #ff6b5f; }
  100% { transform: scale(1); background: #e89c92; }
}

/* Cell-reveal — numbers pop in with a small bounce */
@keyframes ms-reveal {
  0%   { transform: scale(0.6); opacity: 0.4; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.cell.is-revealed:not(.is-mine) {
  animation: ms-reveal 160ms ease-out;
}

/* Flag plant — quick pop */
@keyframes ms-flag-in {
  0%   { transform: scale(0.4); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.cell.is-flag::before, .cell.is-flag::after {
  animation: ms-flag-in 240ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Board shake on lose */
@keyframes ms-board-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
.board.is-lost { animation: ms-board-shake 380ms ease-in-out; }

@media (prefers-reduced-motion: reduce) {
  .cell.is-mine-hit, .cell.is-revealed, .cell.is-flag::before, .cell.is-flag::after, .board.is-lost { animation: none; }
}
.cell.is-wrong-flag::before,
.cell.is-wrong-flag::after {
  /* mark wrong flags with an X */
  content: "";
  position: absolute;
  left: 50%;
  top: 10%;
  width: 8%;
  height: 80%;
  background: var(--danger);
  border-radius: 2px;
  clip-path: none;
}
.cell.is-wrong-flag::before {
  transform: translateX(-50%) rotate(45deg);
}
.cell.is-wrong-flag::after {
  transform: translateX(-50%) rotate(-45deg);
}

.cell.is-chord-press:not(.is-revealed):not(.is-flag) {
  background: var(--cell-cover-hover);
  transform: translateY(1px);
}

/* Win/lose overlay */
.win-overlay {
  position: fixed; inset: 0; background: rgba(28, 42, 58, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.win-overlay[hidden] { display: none; }
.win-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 30px; text-align: center; box-shadow: var(--shadow-lift); max-width: 360px;
}
.win-eyebrow {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.win-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  color: var(--ink);
}
.win-body {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 18px;
  line-height: 1.5;
}
.win-actions { display: flex; gap: 10px; justify-content: center; }

/* aside info */
.aside-info { margin-top: 22px; }
.aside-info details {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.aside-info summary {
  cursor: pointer;
  font: 700 14px 'Inter', sans-serif;
  color: var(--ink);
}
.aside-info .help-body {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}
.aside-info .help-body p { margin: 0 0 8px; }
.aside-info .help-body ul { margin: 0; padding-left: 18px; }
.aside-info .help-body li { margin: 4px 0; }
.aside-info kbd {
  font-family: 'Inter', monospace;
  font-size: 11px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

/* Difficulty-specific cell sizing */
.board[data-diff="beginner"] { --cell-size: 36px; }
.board[data-diff="intermediate"] { --cell-size: 30px; }
.board[data-diff="expert"] { --cell-size: 26px; }

@media (max-width: 640px) {
  .board[data-diff="beginner"] { --cell-size: 32px; }
  .board[data-diff="intermediate"] { --cell-size: 26px; }
  .board[data-diff="expert"] { --cell-size: 24px; }
  .game-chrome .stat { min-width: 80px; padding: 6px 12px; }
  .stat-value { font-size: 19px; }
}
