* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #0a0a0a;
  color: #33ff66;
  font-family: "Courier New", Courier, monospace;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

.cabinet {
  background: #111;
  border: 4px solid #2a2a2a;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 0 40px rgba(51, 255, 102, 0.15);
  width: min(94vw, 440px);
  position: relative;
}

.hud { text-align: center; }

.back {
  display: inline-block;
  color: #33ff66;
  text-decoration: none;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 2px;
  margin-bottom: 8px;
  border: 2px solid #33ff66;
  padding: 4px 12px;
  border-radius: 6px;
  background: #000;
}
.back:hover { background: #062b12; }

.title {
  font-size: 24px;
  font-weight: bold;
  letter-spacing: 3px;
  text-shadow: 0 0 8px #33ff66;
  margin-bottom: 8px;
}

.stats {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  background: #000;
  border: 2px solid #33ff66;
  padding: 6px 10px;
  margin-bottom: 12px;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.mode {
  flex: 1;
  background: #000;
  color: #33ff66;
  border: 2px solid #33ff66;
  border-radius: 6px;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  touch-action: manipulation;
}
.mode.active { background: #062b12; }
.mode svg, .stats svg.ic, .controls svg.ic { width: 20px; height: 20px; vertical-align: -4px; }
#status { display: inline-flex; align-items: center; }
#status svg { width: 24px; height: 24px; }
.cell svg { width: 72%; height: 72%; pointer-events: none; }

.diffbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.diff {
  flex: 1;
  background: #000;
  color: #9dffb8;
  border: 2px solid #2f5f2f;
  border-radius: 6px;
  padding: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  touch-action: manipulation;
}
.diff.active {
  color: #33ff66;
  border-color: #33ff66;
  background: #062b12;
  box-shadow: 0 0 8px rgba(51, 255, 102, 0.4);
}
.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 3px;
  background: #000;
  border: 3px solid #33ff66;
  padding: 6px;
  touch-action: none;
}
.cell {
  aspect-ratio: 1;
  background: #1a2b1a;
  border: 1px solid #2f5f2f;
  border-radius: 3px;
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  color: #ccffcc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.cell.open { background: #000; cursor: default; }
.board.mid .cell { font-size: 13px; }
.board.big { gap: 2px; padding: 4px; }
.board.big .cell { font-size: 11px; border-radius: 2px; }
.cell.flag { color: #ffee33; }
.cell.boom { background: #550000; }
.cell.n1 { color: #33ccff; } .cell.n2 { color: #33ff66; }
.cell.n3 { color: #ffee33; } .cell.n4 { color: #ff9933; }
.cell.n5 { color: #ff3355; } .cell.n6 { color: #ff66ff; }
.cell.n7 { color: #ffffff; } .cell.n8 { color: #999999; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.8);
  line-height: 1.4;
  text-align: center;
  padding: 16px;
  cursor: pointer;
  border-radius: 12px;
  z-index: 5;
}
.overlay.hidden { display: none; }
#overlay-title { font-size: 22px; font-weight: bold; text-shadow: 0 0 8px #33ff66; }
.overlay .hint { font-size: 12px; color: #9dffb8; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: center;
  margin-top: 12px;
  font-size: 12px;
  color: #9dffb8;
  text-align: center;
}

@media (max-width: 600px), (pointer: coarse) {
  .controls { display: none; }
  .cabinet { padding: 12px; }
  .title { font-size: 20px; }
  .cell { font-size: 18px; }
}
