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

:root {
  --ink: #0b0e1a;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  color: #eaf2ff;
  background: radial-gradient(circle at 10% 20%, #1d2b52 0%, #0a0f1f 45%, #07080f 100%);
  min-height: 100vh;
}

body.victory::after {
  content: "";
  position: fixed;
  inset: -20%;
  background: conic-gradient(
    from 90deg,
    rgba(255, 201, 139, 0.2),
    rgba(130, 177, 255, 0.25),
    rgba(122, 255, 196, 0.2),
    rgba(255, 139, 139, 0.22),
    rgba(255, 201, 139, 0.2)
  );
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  mix-blend-mode: screen;
  animation: victoryBurst 1.8s ease;
}

.page {
  padding: 0.9rem clamp(0.8rem, 2.5vw, 1.8rem) 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
}

.shell {
  width: min(1100px, 100%);
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 0 auto;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  color: #9bb2ff;
}

h1 {
  margin: 6px 0 0;
  font-size: clamp(28px, 5vw, 42px);
}

.stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.stat {
  background: rgba(14, 22, 45, 0.7);
  border: 1px solid rgba(130, 177, 255, 0.2);
  padding: 12px 16px;
  border-radius: 12px;
  min-width: 120px;
}

.label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #a0b6ff;
}

.value {
  font-size: 18px;
  font-weight: 600;
}

.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #9bb2ff;
}

.select select {
  background: rgba(16, 24, 46, 0.9);
  color: #eaf2ff;
  border: 1px solid rgba(130, 177, 255, 0.25);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0.04em;
}

.btn {
  border: 1px solid transparent;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:active {
  transform: translateY(1px);
}

.primary {
  background: linear-gradient(135deg, #82b1ff 0%, #3f6fff 100%);
  color: #0a0f1f;
  box-shadow: 0 10px 25px rgba(63, 111, 255, 0.35);
}

.ghost {
  background: rgba(14, 22, 45, 0.6);
  color: #eaf2ff;
  border-color: rgba(130, 177, 255, 0.3);
}

.board-shell {
  background: rgba(8, 12, 25, 0.8);
  border-radius: 24px;
  padding: 20px;
  border: 1px solid rgba(130, 177, 255, 0.15);
  box-shadow: 0 20px 40px rgba(4, 6, 14, 0.6);
  overflow: auto;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.board-shell.win {
  box-shadow: 0 20px 40px rgba(50, 200, 160, 0.45);
  transform: translateY(-4px);
  animation: victoryPulse 0.9s ease 2;
}

.board-shell.loss {
  box-shadow: 0 20px 40px rgba(200, 70, 70, 0.45);
}

.board {
  display: grid;
  gap: 6px;
  justify-content: start;
}

.cell {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(145deg, #192447, #0f182f);
  border: 1px solid rgba(130, 177, 255, 0.15);
  color: #eaf2ff;
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.1s ease, background 0.2s ease;
  position: relative;
  touch-action: none;
}

.cell:hover {
  transform: translateY(-1px);
}

.cell.revealed {
  background: rgba(16, 24, 46, 0.75);
  border-color: rgba(130, 177, 255, 0.3);
  cursor: default;
}

.cell.flagged {
  color: #ffc98b;
  font-size: 20px;
  text-shadow: 0 0 12px rgba(255, 201, 139, 0.6);
}

.cell.mine {
  background: rgba(128, 30, 30, 0.9);
  color: #ffd6d6;
  font-size: 20px;
  text-shadow: 0 0 12px rgba(255, 115, 115, 0.6);
}

.cell.pressing {
  box-shadow: inset 0 0 0 2px rgba(130, 177, 255, 0.45);
}

.cell.press-flag {
  border-color: rgba(255, 201, 139, 0.6);
  box-shadow:
    inset 0 0 0 2px rgba(255, 201, 139, 0.45),
    0 0 0 3px rgba(255, 201, 139, 0.3),
    0 0 18px rgba(255, 201, 139, 0.45);
  transform: scale(1.04);
  z-index: 2;
}

.cell.press-flag::before {
  content: "FLAG";
  position: absolute;
  left: 50%;
  top: -10px;
  transform: translate(-50%, -100%);
  background: rgba(24, 12, 6, 0.85);
  border: 1px solid rgba(255, 201, 139, 0.6);
  color: #ffd9b3;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 9px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

.cell.press-flag::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -10px;
  width: 6px;
  height: 6px;
  background: rgba(24, 12, 6, 0.85);
  border-left: 1px solid rgba(255, 201, 139, 0.6);
  border-bottom: 1px solid rgba(255, 201, 139, 0.6);
  transform: translate(-50%, -30%) rotate(45deg);
}

.cell:focus-visible {
  outline: 2px solid #82b1ff;
  outline-offset: 2px;
}

.cell.pulse {
  animation: pulse 0.2s ease;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

.board-shell.shake {
  animation: shake 0.35s ease;
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes victoryPulse {
  0% {
    transform: translateY(-4px) scale(1);
    box-shadow: 0 20px 40px rgba(50, 200, 160, 0.45);
  }
  50% {
    transform: translateY(-6px) scale(1.03);
    box-shadow: 0 26px 60px rgba(86, 255, 196, 0.7);
  }
  100% {
    transform: translateY(-4px) scale(1);
    box-shadow: 0 20px 40px rgba(50, 200, 160, 0.45);
  }
}

@keyframes victoryBurst {
  0% {
    opacity: 0;
    transform: scale(0.96);
  }
  20% {
    opacity: 0.55;
  }
  60% {
    opacity: 0.35;
  }
  100% {
    opacity: 0;
    transform: scale(1.05);
  }
}

.tips {
  font-size: 14px;
  color: #9bb2ff;
}

@media (max-width: 700px) {
  .board {
    gap: 4px;
  }

  .cell {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  .cell.flagged,
  .cell.mine,
  .cell.press-flag::before {
    font-size: 18px;
  }
}
