* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;

  font-family: Arial, sans-serif;

  background:
    radial-gradient(circle at top left,
      rgba(255,255,255,.35),
      transparent 30%),

    radial-gradient(circle at bottom right,
      rgba(100,140,180,.18),
      transparent 35%),

    #dbe4ee;

  color: #2f3e46;

  padding: 2rem;

  transition: background .4s ease;
}

body.difficulty-easy {
  background:
    radial-gradient(
      circle at top left,
      rgba(255,255,255,.35),
      transparent 30%
    ),
    radial-gradient(
      circle at bottom right,
      rgba(100,140,180,.18),
      transparent 35%
    ),
      #dbe4ee;
}

body.difficulty-medium {
  background:
    radial-gradient(
      circle at top left,
      rgba(255,255,255,.30),
      transparent 30%
    ),
    radial-gradient(
      circle at bottom right,
      rgba(190,140,70,.18),
      transparent 35%
    ),
      #e8dfcf;
}

body.difficulty-hard {
  background:
    radial-gradient(
      circle at top left,
      rgba(255,255,255,.18),
      transparent 30%
    ),
    radial-gradient(
      circle at bottom right,
      rgba(150,60,60,.22),
      transparent 35%
    ),
      #c9b8b8;
}

.layout {
  display: grid;

  grid-template-columns:
    280px
    minmax(0, auto);

  align-items: center;
  justify-content: center;

  gap: 1.5rem;

  width: 100%;
}

.game-container {
  text-align: center;

  background: #f8f9fa;

  padding: 2rem;

  border-radius: 2px;

  box-shadow:
    0 12px 30px rgba(0,0,0,.15);

  min-width: 460px;
  max-width: calc(100vw - 4rem);

  overflow-x: auto;
}

h1 {
  margin-top: 0;
  margin-bottom: 1.5rem;

  font-size: 2.3rem;
}

.difficulty-selector {
  display: flex;
  justify-content: center;
  gap: .5rem;

  margin-bottom: 1rem;
}

.difficulty-btn {
  padding: .55rem .9rem;
  background: #cad2c5;
  color: #354f52;
  border-radius: 8px;
  font-size: .85rem;
}

.difficulty-btn:hover {
  background: #aebdad;
}

.difficulty-btn.active {
  background: #52796f;
  color: white;
}

.game-info {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;

  margin-bottom: 1.5rem;
  gap: 1rem;
}

.game-info p:first-child {
  justify-self: start;
}

.game-info #restart-btn {
  justify-self: center;
}

.game-info p:last-child {
  justify-self: end;
}

button {
  border: none;

  padding: .7rem 1rem;

  border-radius: 10px;

  background: #52796f;

  color: white;

  font-weight: bold;
  cursor: pointer;

  transition: .2s ease;
}

button:hover {
  background: #354f52;
  transform: translateY(-1px);
}

#restart-btn {
  display: flex;
  align-items: center;
  justify-content: center;

  gap: .45rem;
}

#restart-btn svg {
  width: 17px;
  height: 17px;

  stroke-width: 2.5;
  transition: transform .25s ease;
}

#restart-btn:hover svg {
  transform: rotate(-45deg);
}

#mine-count {
  display: inline-block;
  min-width: 2ch;
  text-align: right;
}

.board {
  display: grid;

  gap: clamp(2px, calc(var(--cell-size) * .12), 5px);

  justify-content: center;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);

  border: none;
  border-radius: 8px;

  background: #84a98c;

  color: #1d3557;

  font-size: clamp(.75rem, calc(var(--cell-size) * .42), 1.1rem);
  font-weight: bold;

  cursor: pointer;

  transition: .15s ease;

  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.cell:hover {
  background: #6b9080;
}

.cell.revealed {
  background: #cad2c5;
  cursor: default;
}

.cell.mine {
  background: #d62828;
  color: white;
}

.cell.flagged {
  background: #fcbf49;
}

.cell:not(.revealed):active {
  transform: scale(.92);
}

.message {
  min-height: 0;
  margin: 1.2rem auto 0;
  padding: 0;

  display: flex;
  align-items: center;
  gap: .75rem;

  width: fit-content;

  text-align: left;

  border-radius: 8px;
}

.message:empty {
  display: none;
}

.message:not(:empty) {
  padding: .8rem 1rem;
}

.message.win {
  background: rgba(46, 125, 50, .12);
  color: #2e7d32;
}

.message.loss {
  background: rgba(211, 47, 47, .12);
  color: #b71c1c;
}

.message svg {
  width: 22px;
  height: 22px;

  flex-shrink: 0;
}

.message span {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.message strong {
  font-size: .95rem;
}

.message small {
  font-size: .8rem;
  font-weight: normal;
  opacity: .8;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;

  width: 280px;
  min-width: 280px;
}

.panel-card {
  background: rgba(255,255,255,.6);

  backdrop-filter: blur(8px);

  padding: 1.2rem;

  border-radius: 16px;

  box-shadow:
    0 8px 20px rgba(0,0,0,.08);
}

.panel-card h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.panel-card p,
.panel-card li {
  line-height: 1.5;
  font-size: .95rem;
}

.panel-card ul {
  padding-left: 1.2rem;
  margin-bottom: 0;
}

.creator-card {
  min-height: 220px;

  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (max-width: 900px) {
  .layout,
  .layout.hard-mode {
    grid-template-columns: 1fr;

    max-width: 100%;
  }

  .game-container,
  .layout.hard-mode .game-container {
    grid-column: 1;
    grid-row: auto;

    width: 100%;
    max-width: 100%;
  }

  .side-panel,
  .layout.hard-mode .side-panel {
    width: 100%;
    min-width: 0;
  }
}

.cell svg {
  width: 55% !important;
  height: 55% !important;
  min-width: 0;
  min-height: 0;

  display: block;
  flex-shrink: 0;

  stroke-width: 2.3;
}

.cell.n1 { color: #1976d2; }
.cell.n2 { color: #2e7d32; }
.cell.n3 { color: #d32f2f; }
.cell.n4 { color: #512da8; }
.cell.n5 { color: #6d4c41; }
.cell.n6 { color: #00838f; }
.cell.n7 { color: #37474f; }
.cell.n8 { color: #424242; }

.cell.exploded {
  background: #d62828;
  color: white;
}

.cell.correct-flag {
  background: #70a37f;
  color: white;
}

.cell.wrong-flag {
  background: #e76f51;
  color: white;
  position: relative;
}

.cell.wrong-flag::after {
  content: "×";

  position: absolute;

  font-size: 1.5em;
  font-weight: bold;

  color: #8b0000;
}

.footer {
  margin-top: 1.5rem;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;

  font-size: .8rem;
  color: #65747a;
}

.footer a {
  display: inline-flex;
  align-items: center;
  gap: .3rem;

  color: inherit;
  text-decoration: none;

  transition: color .2s ease;
}

.footer a:hover {
  color: #354f52;
}

.footer svg {
  width: 14px;
  height: 14px;
}