/* @section: design-system */
:root {
  color-scheme: dark;
  --bg: #10151d;
  --bg-2: #17202b;
  --surface: rgba(246, 249, 242, 0.94);
  --surface-dark: rgba(22, 29, 39, 0.92);
  --tile: #d8e2cf;
  --tile-raised: #eef5e9;
  --tile-open: #c4d1bb;
  --text: #f4f7ef;
  --ink: #17202b;
  --muted: #9ead9b;
  --border: rgba(255, 255, 255, 0.14);
  --primary: #99d65d;
  --primary-strong: #6dbb36;
  --accent: #ffbf4d;
  --danger: #ef626c;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-sm: 10px;
  font-family: Arial, Helvetica, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 10%, rgba(153, 214, 93, 0.22), transparent 28rem),
    radial-gradient(circle at 88% 18%, rgba(255, 191, 77, 0.16), transparent 22rem),
    linear-gradient(145deg, var(--bg), var(--bg-2) 62%, #0d1117);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

button,
select { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

/* @section: app-shell */
.game-shell {
  width: min(1180px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(18px, 4vw, 42px) 0;
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr);
  gap: clamp(18px, 4vw, 42px);
  align-items: center;
}

.hero-panel {
  min-height: 560px;
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(160deg, rgba(255,255,255,0.10), rgba(255,255,255,0.03)),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.035) 0 12px, transparent 12px 26px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.hero-panel::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -60px;
  width: 210px;
  height: 210px;
  border-radius: 46px;
  background:
    linear-gradient(135deg, transparent 43%, rgba(23, 32, 43, 0.7) 43% 57%, transparent 57%),
    linear-gradient(45deg, transparent 43%, rgba(23, 32, 43, 0.7) 43% 57%, transparent 57%),
    var(--primary);
  transform: rotate(13deg);
  opacity: 0.85;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 14ch;
  font-size: clamp(1.5rem, 4.5vw, 3.3rem);
  line-height: 0.96;
  letter-spacing: -0.06em;
}

.lead {
  max-width: 520px;
  margin: 22px 0 0;
  color: #d7e3d1;
  font-size: clamp(1rem, 2vw, 1.18rem);
}

.quick-rules {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  max-width: 430px;
}

.quick-rules div {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  background: rgba(0,0,0,0.18);
  backdrop-filter: blur(10px);
}

.quick-rules strong { color: var(--accent); }
.quick-rules span { color: #dce8d6; }

/* @section: game-card */
.game-card {
  padding: clamp(16px, 3.4vw, 28px);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.game-topbar,
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.game-topbar { margin-bottom: 16px; }

.stat-chip {
  min-width: 96px;
  padding: 10px 14px;
  border-radius: 18px;
  background: #0b1118;
  border: 1px solid rgba(255,255,255,0.14);
  text-align: center;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat-chip strong {
  display: block;
  margin-top: 2px;
  color: var(--primary);
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.face-button {
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff4b8, #f7c448);
  box-shadow: inset 0 -6px 0 rgba(90, 60, 0, 0.16), 0 12px 26px rgba(0,0,0,0.26);
  cursor: pointer;
  font-size: 2rem;
  transition: transform 160ms ease, filter 160ms ease;
}

.face-button:hover { transform: translateY(-2px) rotate(-3deg); }
.face-button:active { transform: translateY(2px) scale(0.98); }

.controls {
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #dce8d6;
  font-weight: 700;
}

select,
.toggle-button {
  min-height: 44px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  color: var(--text);
  background: #0c121a;
  padding: 0 12px;
  cursor: pointer;
}

.toggle-button {
  font-weight: 800;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.toggle-button[aria-pressed="true"] {
  color: #17202b;
  background: var(--accent);
}

.status {
  min-height: 28px;
  margin: 0 0 14px;
  color: #d9e7d2;
  font-weight: 700;
}

.board-wrap {
  width: 100%;
  overflow: hidden;
  padding: 10px;
  border-radius: var(--radius-lg);
  background: rgba(0,0,0,0.28);
  border: 1px solid rgba(255,255,255,0.12);
}

.board {
  --cols: 9;
  --cell-size: 44px;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell-size));
  gap: 4px;
  width: max-content;
  margin: 0 auto;
  user-select: none;
  touch-action: manipulation;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border: 0;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--tile-raised), var(--tile));
  color: var(--ink);
  box-shadow: inset 0 -4px 0 rgba(78, 99, 67, 0.22), 0 2px 0 rgba(255,255,255,0.22);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: calc(var(--cell-size) * 0.46);
  transition: transform 100ms ease, filter 120ms ease, background 120ms ease;
}

.cell:hover:not(.open) { filter: brightness(1.05); transform: translateY(-1px); }
.cell:active:not(.open) { transform: translateY(1px); }

.cell.open {
  background: var(--tile-open);
  box-shadow: inset 0 0 0 1px rgba(38, 55, 44, 0.18);
  cursor: default;
}

.cell.flagged { color: #b76700; }
.cell.mine.open { background: var(--danger); color: #fff; }
.cell.n1 { color: #2563eb; }
.cell.n2 { color: #128044; }
.cell.n3 { color: #c2410c; }
.cell.n4 { color: #6d28d9; }
.cell.n5 { color: #be123c; }
.cell.n6 { color: #0f766e; }
.cell.n7 { color: #111827; }
.cell.n8 { color: #64748b; }

@media (prefers-reduced-motion: no-preference) {
  .hero-panel,
  .game-card { animation: rise-in 520ms ease both; }
  .game-card { animation-delay: 90ms; }
  @keyframes rise-in {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 860px) {
  .game-shell {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .hero-panel { min-height: auto; gap: 28px; }
  h1 { max-width: 9ch; }
}

@media (max-width: 560px) {
  .game-shell { width: min(100% - 18px, 560px); padding: 10px 0 18px; }
  .hero-panel,
  .game-card { border-radius: 22px; }
  .quick-rules div { grid-template-columns: 1fr; gap: 2px; }
  .game-topbar { gap: 8px; }
  .stat-chip { min-width: 78px; padding: 8px 10px; }
  .stat-chip strong { font-size: 1.25rem; }
  .face-button { width: 54px; height: 54px; font-size: 1.75rem; }
  .control-group,
  .toggle-button { width: 100%; }
  .control-group { justify-content: space-between; }
  select { flex: 1; }
  .board { gap: 3px; }
}
