:root {
  --bg: #dbe8d6;
  --panel: rgba(248, 244, 233, 0.94);
  --line: rgba(36, 69, 50, 0.12);
  --line-strong: rgba(36, 69, 50, 0.24);
  --text: #102117;
  --muted: #4f6958;
  --accent: #79bc63;
  --accent-soft: #eef5ea;
  --danger: #d24f4f;
  --gold: #d7aa48;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 24%),
    radial-gradient(circle at bottom right, rgba(121, 188, 99, 0.22), rgba(121, 188, 99, 0) 28%),
    linear-gradient(180deg, #edf4e9, var(--bg) 58%, #cddfc6);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 18, 12, 0.34);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.overlay.hidden {
  display: none;
}

.menu-card {
  width: min(540px, 100%);
  padding: 28px;
  border-radius: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.18);
}

.menu-card h1 {
  margin: 0;
  font-size: clamp(2.4rem, 5vw, 3.4rem);
}

.subtitle {
  margin: 12px 0 18px;
  color: var(--muted);
  line-height: 1.55;
}

.menu-card label,
.menu-card summary,
.instructions-body p {
  color: var(--text);
}

.menu-card label {
  display: block;
  margin-top: 14px;
  margin-bottom: 8px;
  font-weight: 700;
}

.menu-card input,
.menu-card select,
.menu-card button {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 14px 16px;
}

.menu-card input,
.menu-card select {
  background: #eaf3e5;
  color: var(--text);
}

.menu-card button {
  margin-top: 16px;
  background: #0e0f11;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.secondary-link {
  display: inline-flex;
  justify-content: center;
  width: 100%;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #eef6ea;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line);
}

.instructions {
  margin-top: 16px;
  border-radius: 18px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  padding: 14px 16px;
}

.instructions summary {
  cursor: pointer;
  font-weight: 800;
}

.instructions-body {
  margin-top: 12px;
}

.instructions-body p {
  margin: 8px 0;
  line-height: 1.45;
}

.topbar {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  background: rgba(245, 242, 232, 0.92);
  border-bottom: 1px solid rgba(36, 69, 50, 0.08);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.brand {
  display: flex;
  flex-direction: column;
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 800;
  color: #5b8a55;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand strong {
  font-size: 1.8rem;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.hud-chip {
  min-width: 112px;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(234, 243, 229, 0.96);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-chip span {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.hud-chip strong {
  font-size: 1rem;
}

.actions {
  display: flex;
  gap: 10px;
}

.icon-button {
  height: 50px;
  border: 0;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(234, 243, 229, 0.96);
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
  text-decoration: none;
  border: 1px solid var(--line);
  cursor: pointer;
}

.wide-button {
  min-width: 72px;
  padding: 0 14px;
}

.game-shell {
  min-height: calc(100vh - 92px);
  display: grid;
  place-items: center;
  padding: 28px;
}

.board-panel {
  width: min(960px, 100%);
  padding: 24px;
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0.12)),
    rgba(245, 242, 232, 0.72);
  border: 1px solid rgba(36, 69, 50, 0.12);
  box-shadow: 0 28px 80px rgba(34, 58, 40, 0.12);
}

.board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.board-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.board-meta span {
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(234, 243, 229, 0.96);
  border: 1px solid var(--line);
  font-weight: 700;
  color: var(--text);
}

.board-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-button,
.face-button {
  border: 0;
  border-radius: 18px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.tool-button {
  min-height: 52px;
  padding: 0 16px;
  background: linear-gradient(180deg, #fff5dd, #f0dfb1);
  color: #59411a;
  font-weight: 800;
}

.face-button {
  width: 58px;
  height: 58px;
  background: linear-gradient(180deg, #fffdf3, #edf5e6);
  font-size: 1.2rem;
  font-weight: 900;
}

.board {
  --cell-size: 34px;
  --board-gap: 2px;
  display: grid;
  gap: var(--board-gap);
  justify-content: center;
  padding: 8px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(97, 123, 95, 0.18), rgba(97, 123, 95, 0.12));
  border: 1px solid rgba(36, 69, 50, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.tile {
  width: var(--cell-size);
  height: var(--cell-size);
  border: 0;
  border-radius: 7px;
  background: linear-gradient(180deg, #eff7ea, #d7e5cf);
  color: var(--text);
  font-weight: 900;
  font-size: clamp(0.82rem, 1.5vw, 1rem);
  cursor: pointer;
  box-shadow:
    inset 0 -2px 0 rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.58);
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.tile:hover:not(.revealed):not(.exploded) {
  transform: translateY(-1px);
}

.tile.revealed {
  background: rgba(248, 244, 233, 0.98);
  box-shadow: inset 0 0 0 1px rgba(36, 69, 50, 0.08);
}

.tile.flagged {
  background: linear-gradient(180deg, #fff3e0, #f1dec3);
}

.tile.mark-red,
.tile.mark-blue,
.tile.mark-green {
  font-size: 1.38rem;
  line-height: 1;
}

.tile.mark-red {
  color: #d94343;
}

.tile.mark-blue {
  color: #2b67d8;
}

.tile.mark-green {
  color: #2f8b3b;
}

.tile.mine,
.tile.exploded {
  background: linear-gradient(180deg, #f7b1b1, #de7272);
}

.tile.exploded {
  color: #fff;
}

.tile.saved {
  background: linear-gradient(180deg, #d6f2d7, #9ddba0);
  color: #255f2d;
}

.tile.hint {
  box-shadow:
    0 0 0 2px rgba(215, 170, 72, 0.35),
    inset 0 -2px 0 rgba(0, 0, 0, 0.08);
}

.tile.reveal-pop {
  animation: tile-reveal 220ms ease-out;
}

.tile.mine-burst {
  animation: tile-burst 380ms ease-out;
}

.tile.shield-pop {
  animation: tile-shield 320ms ease-out;
}

.tile.n1 { color: #2b67d8; }
.tile.n2 { color: #2f8b3b; }
.tile.n3 { color: #d24f4f; }
.tile.n4 { color: #5f52c4; }
.tile.n5 { color: #98511b; }
.tile.n6 { color: #147d8f; }
.tile.n7 { color: #2d3642; }
.tile.n8 { color: #6b7580; }

@keyframes tile-reveal {
  0% {
    transform: scale(0.84);
    opacity: 0.35;
    filter: brightness(1.15);
  }
  100% {
    transform: scale(1);
    opacity: 1;
    filter: brightness(1);
  }
}

@keyframes tile-burst {
  0% {
    transform: scale(0.8);
    filter: saturate(1.5);
  }
  50% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes tile-shield {
  0% {
    transform: scale(0.82);
    filter: brightness(1.2);
  }
  45% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .brand,
  .actions {
    justify-self: center;
  }

  .board-head {
    flex-direction: column;
    align-items: stretch;
  }

  .board-tools {
    justify-content: space-between;
  }
}

@media (max-width: 620px) {
  .game-shell {
    padding: 16px;
  }

  .board-panel {
    padding: 16px;
  }

  .wide-button {
    min-width: 62px;
  }
}
