/* Minesweeper — bright Baithak theme (classic cells, numbers, flags) */
:root {
  --bg0: #fff8e7;
  --bg1: #ffefd9;
  --amber: #ffb020;
  --amber-light: #ffd166;
  --amber-deep: #c77e00;
  --tile: #2e4d68;
  --tile-hi: #3d6484;
  --open: #142736;
  --open-alt: #10202e;
  --ink: #3a2c1c;
  --ink-dim: #8a755c;
  --cell: 34px;
}
body[data-bgfx="minesweeper"] { --accent: #ffb020; --flag: #ff5a48; }

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

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  /* page background comes from shared baithak.css (bright gradient) */
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetto {
  position: absolute; top: -4vh; border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(115vh) rotate(720deg); }
}

.topbar {
  width: 100%; max-width: 860px;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
}
.brand { font-size: 26px; font-weight: 800; font-family: 'Baloo 2', system-ui, sans-serif; color: #3a2c1c; letter-spacing: .5px; }
.brand-mine { display: inline-block; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-5px) rotate(8deg); } }
.hub-link {
  color: var(--ink-dim); text-decoration: none; font-weight: 700; font-size: 15px;
  padding: 8px 14px; border-radius: 999px; border: 2px solid rgba(255,176,32,.35);
  transition: transform .15s, background .15s;
}
.hub-link:hover { background: rgba(255,176,32,.12); transform: scale(1.05); }

.wrap { width: 100%; max-width: 860px; padding: 0 14px 30px; display: flex; flex-direction: column; gap: 14px; }

.panel {
  background: #fffdf8;
  border: 2px solid #eadfc8;
  border-radius: 20px;
  padding: 14px;
  box-shadow: 0 4px 14px rgba(120, 80, 20, .10);
}

.diff-row { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.diff-btn {
  flex: 1 1 0; min-width: 120px;
  border: 2px solid #eadfc8; border-radius: 14px;
  background: #fffdf8; color: var(--ink);
  font-weight: 800; font-size: 15px; padding: 9px 6px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; align-items: center;
  transition: transform .12s, background .12s, box-shadow .12s;
  box-shadow: 0 2px 8px rgba(120, 80, 20, .08);
}
.diff-btn .diff-sub { font-size: 11px; font-weight: 600; color: var(--ink-dim); }
.diff-btn:hover { transform: translateY(-2px); }
.diff-btn:active { transform: scale(.96); }
.diff-btn.active {
  background: linear-gradient(180deg, var(--amber-light), var(--amber));
  color: #2a1f08; border-color: var(--amber-deep);
  box-shadow: 0 4px 0 var(--amber-deep), 0 8px 18px rgba(255,176,32,.35);
}
.diff-btn.active .diff-sub { color: #5b430a; }

.hud {
  display: flex; justify-content: space-between; align-items: center;
  background: #f7efdc; border-radius: 14px; padding: 8px 16px;
  border: 1px solid #eadfc8; margin-bottom: 10px;
}
.counter {
  font-size: 22px; font-weight: 900; color: #c77e00;
  font-variant-numeric: tabular-nums; letter-spacing: 2px;
  min-width: 110px;
}
.counter:last-child { text-align: right; }
.smiley {
  font-size: 34px; line-height: 1; cursor: pointer;
  background: linear-gradient(180deg, var(--amber-light), var(--amber));
  border: 0; border-radius: 50%; width: 58px; height: 58px;
  box-shadow: 0 4px 0 var(--amber-deep), 0 8px 18px rgba(255,176,32,.35);
  transition: transform .12s;
}
.smiley:hover { transform: scale(1.08) rotate(-6deg); }
.smiley:active { transform: translateY(3px) scale(.95); box-shadow: 0 1px 0 var(--amber-deep); }

.controls-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.toggle-btn {
  border: 2px solid #eadfc8; border-radius: 999px;
  background: #fffdf8; color: var(--ink);
  font-size: 14px; font-weight: 700; padding: 8px 16px; cursor: pointer;
  transition: transform .12s, background .12s;
}
.toggle-btn:active { transform: scale(.95); }
.toggle-btn.on {
  background: linear-gradient(180deg, var(--amber-light), var(--amber));
  color: #2a1f08; border-color: var(--amber-deep);
  animation: wiggle .4s;
}
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
.best { font-size: 14px; font-weight: 700; color: var(--ink-dim); }
.best b { color: #c77e00; }

.hint { margin: 10px 2px 0; font-size: 12.5px; color: var(--ink-dim); text-align: center; }

.board-panel { display: flex; flex-direction: column; align-items: center; gap: 12px; }
#board-wrap { width: 100%; display: flex; justify-content: center; overflow-x: auto; padding: 4px; }
#board {
  display: grid; gap: 3px; padding: 10px;
  background: rgba(0,0,0,.35); border-radius: 14px;
  border: 1px solid rgba(255,176,32,.25);
  touch-action: none;
}
#board.shake { animation: shake .45s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-9px); } 40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); } 80% { transform: translateX(5px); }
}
#board.won { animation: happy-bounce .7s ease; }
@keyframes happy-bounce {
  0% { transform: scale(1); } 30% { transform: scale(1.03) rotate(-.6deg); }
  60% { transform: scale(1.03) rotate(.6deg); } 100% { transform: scale(1); }
}

.cell {
  width: var(--cell); height: var(--cell);
  border: 0; border-radius: 7px; padding: 0;
  background: linear-gradient(180deg, var(--tile-hi), var(--tile));
  box-shadow: inset 0 2px 0 rgba(255,255,255,.14), inset 0 -2px 0 rgba(0,0,0,.25);
  font-size: calc(var(--cell) * .55); font-weight: 900; line-height: 1;
  cursor: pointer; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  transition: transform .08s, filter .08s;
  font-family: "Menlo", "Consolas", monospace;
}
.cell:hover:not(.open) { filter: brightness(1.25); transform: scale(1.06); }
.cell:active:not(.open) { transform: scale(.92); }
.cell.open {
  background: var(--open);
  box-shadow: inset 0 2px 5px rgba(0,0,0,.5);
  cursor: default;
  animation: pop .18s ease-out;
}
.cell.open.alt { background: var(--open-alt); }
@keyframes pop { 0% { transform: scale(.55); } 60% { transform: scale(1.14); } 100% { transform: scale(1); } }
.cell .flag-emoji { display: inline-block; animation: flagpop .28s cubic-bezier(.2,2.2,.4,1); filter: drop-shadow(0 0 6px rgba(255,90,72,.85)); }
@keyframes flagpop { 0% { transform: scale(0) rotate(-30deg); } 100% { transform: scale(1) rotate(0); } }
.cell.boom {
  background: radial-gradient(circle, #ff6b6b, #c81e1e);
  animation: boomflash .5s;
}
@keyframes boomflash { 0%,100% { filter: none; } 50% { filter: brightness(1.8); } }

.n1 { color: #5aa2ff; } .n2 { color: #3fe07a; } .n3 { color: #ff5a5a; }
.n4 { color: #c07bff; } .n5 { color: #ffb020; } .n6 { color: #3fd4c1; }
.n7 { color: #dfe7ee; } .n8 { color: #8a97a8; }

.banner {
  font-size: 20px; font-weight: 900; padding: 10px 22px; border-radius: 999px;
  animation: banner-in .45s cubic-bezier(.2,1.6,.4,1);
}
@keyframes banner-in { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.banner.win { background: linear-gradient(180deg, var(--amber-light), var(--amber)); color: #2a1f08; box-shadow: 0 6px 20px rgba(255,176,32,.5); }
.banner.lose { background: linear-gradient(180deg, #ff7b7b, #d33); color: #fff; box-shadow: 0 6px 20px rgba(255,60,60,.4); }
.hidden { display: none !important; }

@media (max-width: 520px) {
  .brand { font-size: 21px; }
  .counter { font-size: 18px; min-width: 84px; }
  .smiley { width: 50px; height: 50px; font-size: 28px; }
  .hint { font-size: 11.5px; }
}

/* ---------- Baithak bright theme accents: minesweeper ---------- */
/* subtle grid pulse around the board (decorative; #board.shake/.won still override) */
#board { animation: grid-pulse 5s ease-in-out infinite; }
@keyframes grid-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 176, 32, 0); }
  50% { box-shadow: 0 0 28px rgba(255, 176, 32, .30); }
}
/* red flag accent: flags wave subtly once placed */
.cell .flag-emoji { animation: flagpop .28s cubic-bezier(.2,2.2,.4,1), flag-wave 2.6s ease-in-out .3s infinite; transform-origin: bottom center; }
@keyframes flag-wave {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}
@media (prefers-reduced-motion: reduce) {
  .brand-mine, #board, .cell .flag-emoji { animation: none !important; }
}
