.magawa-main {
  max-width: 760px;
}

.magawa-main .header {
  margin-bottom: 0.25rem;
}

/* The rat in the title gives a friendly wave. */
.title-rat {
  width: 50px;
  height: 50px;
  display: inline-block;
  flex-shrink: 0;
  animation: wiggle 2.4s ease-in-out infinite;
}

.title-rat svg { width: 100%; height: 100%; display: block; }

.face-btn svg { width: 40px; height: 40px; display: block; }

/* ---------- Difficulty picker ---------- */

.levels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.level-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.05rem;
  padding: 0.45rem 0.95rem;
  border-radius: 14px;
  line-height: 1.15;
}

.level-btn small {
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--muted);
}

.level-btn.picked {
  background: var(--pick-bg);
  border-color: var(--pick-border);
  color: var(--primary-dark);
}

.level-btn.picked small { color: var(--primary-dark); }

/* ---------- Scoreboard ---------- */

.scoreboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 18px 18px 0 0;
  border-bottom: none;
  padding: 0.7rem 1rem;
  box-shadow: var(--shadow);
}

.readout {
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: 1px;
  color: #ff5c5c;
  background: #1a0e0e;
  padding: 0.2rem 0.55rem;
  border-radius: 8px;
  min-width: 3.4ch;
  text-align: center;
  text-shadow: 0 0 6px rgba(255, 92, 92, 0.7);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.85);
}

.readout-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.readout-wrap .readout-icon { font-size: 1.1rem; }

.face-btn {
  font-size: 1.7rem;
  line-height: 1;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: #fff;            /* cells stay light so the classic number colours read */
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.face-btn:hover { transform: translateY(-1px) scale(1.05); }
.face-btn:active { transform: scale(0.95); }

/* ---------- Board ---------- */

.board-scroll {
  overflow-x: auto;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 0 0 18px 18px;
  box-shadow: var(--shadow);
  padding: 0.6rem;
  -webkit-overflow-scrolling: touch;
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--cols), 34px);
  gap: 3px;
  margin: 0 auto;
  width: max-content;
  touch-action: manipulation;
}

.board.wide {
  grid-template-columns: repeat(var(--cols), 28px);
}

.cell {
  width: 34px;
  height: 34px;
  padding: 0;
  margin: 0;
  border-radius: 7px;
  border: none;
  font-family: "Fredoka", "Nunito", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s ease, transform 0.08s ease;
}

.board.wide .cell {
  width: 28px;
  height: 28px;
  font-size: 0.9rem;
  border-radius: 6px;
}

/* Unrevealed dirt — the ground Magawa hasn't sniffed yet. */
.cell.hidden-cell {
  background: linear-gradient(145deg, #f7c89a 0%, #e9a86d 100%);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.1), inset 0 2px 0 rgba(255, 255, 255, 0.35);
}

.cell.hidden-cell:hover {
  background: linear-gradient(145deg, #fad3aa 0%, #efb47e 100%);
  transform: translateY(-1px);
}

.cell.hidden-cell:active { transform: translateY(0) scale(0.96); }

/* Flash shown when you chord a number that isn't satisfied yet — points out
   which hidden tiles it's counting. */
.cell.hidden-cell.peek {
  background: #fff6ec;
  box-shadow: inset 0 0 0 2px var(--pick-border);
  transform: none;
}

.cell.flag {
  background: linear-gradient(145deg, #f7c89a 0%, #e9a86d 100%);
}

/* Cleared, safe ground. */
.cell.open {
  background: #fff6ec;
  box-shadow: inset 0 0 0 1px var(--border);
  cursor: default;
}

.cell.mine {
  background: #ffe0e0;
  box-shadow: inset 0 0 0 1px #f3b6b6;
}

.cell.mine.detonated {
  background: #ff6b6b;
  animation: boom 0.4s ease;
}

@keyframes boom {
  0% { transform: scale(0.4); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Classic Minesweeper number colours. */
.cell[data-n="1"] { color: #2e7bd6; }
.cell[data-n="2"] { color: #2e9e5b; }
.cell[data-n="3"] { color: #e74e4e; }
.cell[data-n="4"] { color: #6a3fb0; }
.cell[data-n="5"] { color: #a8521f; }
.cell[data-n="6"] { color: #1fa3a3; }
.cell[data-n="7"] { color: #444; }
.cell[data-n="8"] { color: #999; }

/* ---------- Status line ---------- */

.status {
  margin-top: 1rem;
  text-align: center;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--primary-dark);
  min-height: 1.4em;
  animation: cardPop 0.35s cubic-bezier(0.17, 0.89, 0.32, 1.275);
}

/* ---------- Controls row ---------- */

.controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1rem 0 0;
  flex-wrap: wrap;
}

#flag-toggle { cursor: pointer; }

.best-pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.best-pill b { font-variant-numeric: tabular-nums; }

/* ---------- How to play ---------- */

.how-to {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 1.25rem 1.4rem 1.1rem;
  margin-top: 1.5rem;
  box-shadow: var(--shadow);
}

.how-to h2 {
  margin: 0 0 0.6rem;
  font-family: "Fredoka", "Nunito", sans-serif;
  font-size: 1.15rem;
  font-weight: 500;
}

.how-to ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.how-to li { margin-bottom: 0.35rem; }
.how-to b { color: var(--ink); }

/* ---------- Banana reward shower ---------- */

.banana-pop {
  position: fixed;
  bottom: -2.5rem;
  z-index: 60;
  pointer-events: none;
  will-change: transform, opacity;
  animation-name: banana-rise;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.banana-pop svg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}

@keyframes banana-rise {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translateY(-112vh) rotate(380deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .banana-pop { display: none; }
}

/* ---------- About Magawa ---------- */

.about {
  background: var(--card);
  border: 2px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: 20px;
  padding: 1.25rem 1.4rem 1.3rem;
  margin-top: 1.25rem;
  box-shadow: var(--shadow);
}

.about h2 {
  margin: 0 0 0.6rem;
  font-family: "Fredoka", "Nunito", sans-serif;
  font-size: 1.15rem;
  font-weight: 500;
}

.about p {
  margin: 0 0 0.8rem;
  color: var(--muted);
}

.about p:last-child { margin-bottom: 0; }
.about b { color: var(--ink); }

.donate-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem 0.9rem;
  margin-top: 0.4rem !important;
}

.donate-btn {
  display: inline-block;
  padding: 0.55rem 1.3rem;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: background 0.15s ease, transform 0.15s ease;
}

.donate-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.donate-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.donate-link:hover { text-decoration: underline; }

@media (max-width: 500px) {
  .readout { font-size: 1.2rem; }
  .face-btn { width: 46px; height: 46px; }
  .face-btn svg { width: 34px; height: 34px; }
}
