:root {
  --face: #c0c0c0;
  --light: #ffffff;
  --shadow: #7b7b7b;
  --shadow-dark: #4d4d4d;
  --bg: #1e1e1e;
  --cell-size: 28px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.03), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,0.03), transparent 40%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  padding: 24px 12px;
}

.wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.title {
  color: #e8e8e8;
  font-size: 22px;
  letter-spacing: 6px;
  font-weight: 700;
  margin: 0;
}

/* --- Beveled 3D UI, the classic Windows look --- */
.raised {
  background: var(--face);
  border-top: 2px solid var(--light);
  border-left: 2px solid var(--light);
  border-right: 2px solid var(--shadow);
  border-bottom: 2px solid var(--shadow);
}

.sunken {
  background: var(--face);
  border-top: 2px solid var(--shadow);
  border-left: 2px solid var(--shadow);
  border-right: 2px solid var(--light);
  border-bottom: 2px solid var(--light);
}

.toolbar {
  padding: 8px;
}

.difficulty-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.diff-btn, .face, #custom-apply {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 10px;
  cursor: pointer;
}

.diff-btn:active, .face:active, #custom-apply:active {
  border-top: 2px solid var(--shadow);
  border-left: 2px solid var(--shadow);
  border-right: 2px solid var(--light);
  border-bottom: 2px solid var(--light);
}

.diff-btn.active {
  border-top: 2px solid var(--shadow);
  border-left: 2px solid var(--shadow);
  border-right: 2px solid var(--light);
  border-bottom: 2px solid var(--light);
  background: #b3b3b3;
}

.custom-panel {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  font-size: 13px;
  flex-wrap: wrap;
  justify-content: center;
}

.custom-panel label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #222;
}

.custom-panel input {
  width: 60px;
  font-family: inherit;
  padding: 2px 4px;
}

.hidden { display: none; }

.panel {
  padding: 10px;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px;
  margin-bottom: 8px;
}

.counter {
  background: #000;
  color: #ff2b2b;
  font-family: "Consolas", "DejaVu Sans Mono", monospace;
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 2px;
  padding: 2px 6px;
  min-width: 60px;
  text-align: center;
  border: 2px solid var(--shadow-dark);
}

.face {
  width: 36px;
  height: 36px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.board-frame {
  padding: 6px;
  display: inline-block;
}

.board {
  display: grid;
  gap: 0;
}

.cell {
  position: relative;
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell-size) * 0.55);
  font-weight: 700;
  user-select: none;
  cursor: pointer;
  border-top: 2px solid var(--light);
  border-left: 2px solid var(--light);
  border-right: 2px solid var(--shadow);
  border-bottom: 2px solid var(--shadow);
  background: var(--face);
}

.cell.revealed {
  border: 1px solid var(--shadow);
  background: #bdbdbd;
  cursor: default;
}

.cell.revealed.mine-hit { background: #ff4d4d; }
.cell.revealed.mine-hit .mine { background: radial-gradient(circle at 35% 35%, #444, #000 65%); }

.cell[data-n="1"] { color: #0000ff; }
.cell[data-n="2"] { color: #008000; }
.cell[data-n="3"] { color: #ff0000; }
.cell[data-n="4"] { color: #000080; }
.cell[data-n="5"] { color: #800000; }
.cell[data-n="6"] { color: #008080; }
.cell[data-n="7"] { color: #000000; }
.cell[data-n="8"] { color: #808080; }

/* Mine icon, drawn with CSS rather than relying on emoji fonts */
.mine {
  width: 62%;
  height: 62%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #6e6e6e, #000 65%);
  position: relative;
}
.mine::after {
  content: "";
  position: absolute;
  top: 14%;
  left: 20%;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
}

/* Flag icon, also drawn with CSS */
.flag {
  position: relative;
  width: 100%;
  height: 100%;
}
.flag::before {
  content: "";
  position: absolute;
  left: 48%;
  top: 18%;
  width: 8%;
  height: 68%;
  background: #1a1a1a;
}
.flag::after {
  content: "";
  position: absolute;
  left: 52%;
  top: 18%;
  width: 0;
  height: 0;
  border-top: 12% solid transparent;
  border-bottom: 12% solid transparent;
  border-left: 34% solid #d62828;
}

.cell.wrong-flag {
  background: #bdbdbd;
}
.cell.wrong-flag::before,
.cell.wrong-flag::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 85%;
  height: 3px;
  background: #d62828;
}
.cell.wrong-flag::before { transform: translate(-50%, -50%) rotate(45deg); }
.cell.wrong-flag::after { transform: translate(-50%, -50%) rotate(-45deg); }

.hint {
  color: #9a9a9a;
  font-size: 12px;
  text-align: center;
  max-width: 420px;
  margin: 0;
}

@media (max-width: 480px) {
  :root { --cell-size: 22px; }
  .title { font-size: 18px; letter-spacing: 3px; }
}
