:root {
  --bg: #FDF0D5;
  --bg-deep: #F5E4C4;
  --panel: #ffffff;
  --panel-2: #F7EBD0;
  --text: #2C2416;
  --muted: #7A6A52;
  --accent: #249D8F;
  --accent-2: #1A7A6F;
  --gold: #E9C46A;
  --coral: #E76F51;
  --border: rgba(36, 157, 143, 0.35);
  --border-strong: rgba(26, 122, 111, 0.42);
  --ok: #249D8F;
  --danger: #E76F51;
  /* Classic Win95 / MiniMine palette */
  --ms-face: #c0c0c0;
  --ms-hi: #ffffff;
  --ms-sh: #808080;
  --ms-dk: #404040;
  --ms-n1: #0061ff;
  --ms-n2: #008900;
  --ms-n3: #ff1a1a;
  --ms-n4: #1a1acc;
  --ms-n5: #e127bd;
  --ms-n6: #00b3b3;
  --ms-n7: #000000;
  --ms-n8: #f29f05;
  --ms-flag: #ff0000;
  --ms-mine: #000000;
  --ms-boom: #ff0000;
  --ms-lcd: #ff2020;
  --ms-lcd-bg: #000000;
  --radius: 16px;
  --shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 10px 30px rgba(36, 157, 143, 0.12),
    0 2px 8px rgba(44, 36, 22, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    system-ui, sans-serif;
}

* { box-sizing: border-box; }

html {
  margin: 0;
  padding: 0;
  min-height: 100%;
  min-height: 100dvh;
  background-color: var(--bg-deep);
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  min-height: 100dvh;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  line-height: 1.4;
  background-color: var(--bg-deep);
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 12px 28px;
}

header.hero {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.nav-home {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}

.nav-home:hover { color: var(--accent-2); }

header.hero h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  letter-spacing: -0.02em;
  font-weight: 750;
}

header.hero .sub {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 4px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 300px);
  gap: 16px;
  align-items: start;
}

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.stat-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  min-width: 72px;
}

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

.stat-chip .value {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hint-bar {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 10px;
  min-height: 1.3em;
}

.progress {
  height: 4px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  border-radius: 999px;
  transition: width 0.15s ease;
}

.ms-window.panel {
  background: #c0c0c0 !important;
  border-radius: 0 !important;
  border: 2px solid !important;
  border-color: #ffffff #808080 #808080 #ffffff !important;
  box-shadow: 1px 1px 0 #000000 !important;
  padding: 8px !important;
}

.ms-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #808080 #ffffff #ffffff #808080;
}

.lcd {
  position: relative;
  justify-self: start;
  background: #000;
  border: 2px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  padding: 2px 6px;
  min-width: 3.4em;
  text-align: center;
  font-family: "Courier New", "Lucida Console", ui-monospace, monospace;
  font-weight: 800;
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  letter-spacing: 0.06em;
  line-height: 1.15;
}

.ms-hud .lcd:last-child {
  justify-self: end;
}

.lcd-bg,
.lcd-fg {
  font: inherit;
  letter-spacing: inherit;
}

.lcd-bg {
  color: #400000;
}

.lcd-fg {
  position: absolute;
  inset: 2px 6px;
  color: #ff2020;
}

.ms-face {
  width: 36px;
  height: 36px;
  padding: 0 !important;
  margin: 0 auto;
  border-radius: 0 !important;
  border: 2px solid !important;
  border-color: #ffffff #404040 #404040 #ffffff !important;
  background: #c0c0c0 !important;
  box-shadow: none !important;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.ms-face:active {
  border-color: #404040 #ffffff #ffffff #404040 !important;
}

.ms-window .board-frame {
  position: relative;
  width: 100%;
  max-width: min(100%, 640px);
  margin: 0 auto;
  background: #c0c0c0 !important;
  border-radius: 0 !important;
  border: 3px solid !important;
  border-color: #808080 #ffffff #ffffff #808080 !important;
  box-shadow: none !important;
  overflow: hidden;
  touch-action: manipulation;
  padding: 0 !important;
}

.ms-board {
  display: grid;
  width: 100%;
  gap: 0;
  background: #c0c0c0;
}

.ms-cell {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  margin: 0;
  border-radius: 0 !important;
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
  font-weight: 700;
  font-size: clamp(0.78rem, 2.6vw, 1.12rem);
  line-height: 1;
  cursor: pointer;
  color: transparent;
  background: #c0c0c0 !important;
  box-shadow:
    inset 2px 2px 0 #ffffff,
    inset -2px -2px 0 #808080,
    inset -3px -3px 0 #404040 !important;
}

.ms-cell:hover:not(.open):not(:disabled) {
  filter: none;
}

.ms-cell:active:not(.open):not(.flagged),
.ms-cell.chord-press:not(.open):not(.flagged) {
  box-shadow: inset 1px 1px 0 #808080 !important;
}

.ms-cell.open.chord-press {
  box-shadow: inset 2px 2px 0 #808080 !important;
}

.ms-cell.open {
  background: #c0c0c0 !important;
  box-shadow: inset 1px 1px 0 #808080 !important;
  cursor: default;
  color: transparent;
  filter: none;
}

.ms-cell.open.alt {
  background: #c0c0c0 !important;
}

.ms-cell.n1 { color: var(--ms-n1) !important; }
.ms-cell.n2 { color: var(--ms-n2) !important; }
.ms-cell.n3 { color: var(--ms-n3) !important; }
.ms-cell.n4 { color: var(--ms-n4) !important; }
.ms-cell.n5 { color: var(--ms-n5) !important; }
.ms-cell.n6 { color: var(--ms-n6) !important; }
.ms-cell.n7 { color: var(--ms-n7) !important; }
.ms-cell.n8 { color: var(--ms-n8) !important; }

.ms-cell.flagged::after {
  content: "▶";
  color: #ff0000;
  font-size: 0.72em;
  display: block;
  transform: translate(1px, 0) rotate(-90deg);
  text-shadow: 1px 0 0 #000;
}

.ms-cell.mine.open,
.ms-cell.exploded {
  background: #c0c0c0 !important;
  color: #000;
}

.ms-cell.exploded {
  background: #ff0000 !important;
}

.ms-cell.mine.open::after,
.ms-cell.exploded::after {
  content: "";
  position: absolute;
  inset: 14%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 78% 78%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><line x1='8' y1='1' x2='8' y2='15' stroke='%23000' stroke-width='2'/><line x1='1' y1='8' x2='15' y2='8' stroke='%23000' stroke-width='2'/><line x1='2.8' y1='2.8' x2='13.2' y2='13.2' stroke='%23000' stroke-width='2'/><line x1='13.2' y1='2.8' x2='2.8' y2='13.2' stroke='%23000' stroke-width='2'/><circle cx='8' cy='8' r='4.1' fill='%23000'/><circle cx='6.6' cy='6.5' r='1.15' fill='%23fff'/></svg>");
}

.ms-cell.wrong {
  background: #c0c0c0 !important;
}

.ms-cell.wrong::after {
  content: "×";
  color: #ff0000;
  font-weight: 900;
  font-size: 1.15em;
}

.ms-cell:disabled {
  cursor: default;
  opacity: 1 !important;
}

.board-wrap.flag-mode .ms-cell:not(.open) {
  outline: 1px dotted #000;
  outline-offset: -3px;
}

.ms-window .hint-bar {
  margin: 8px 0 0;
  color: #404040;
  font-size: 0.8rem;
}

.ms-window .toolbar,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

button {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease,
    box-shadow 0.12s ease;
}

button:hover {
  background: #fff;
  border-color: var(--border-strong);
  box-shadow: 0 4px 12px rgba(36, 157, 143, 0.12);
}

button:active { transform: scale(0.97); }

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover { filter: brightness(1.05); }

button.primary[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--coral), #c9543a);
  border-color: var(--coral);
}

button:disabled:not(.ms-cell) {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

a.btn-link,
a.btn-link:link,
a.btn-link:visited {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  box-sizing: border-box;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
}

a.btn-link:hover {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--text);
  text-decoration: none;
}

.status {
  margin-top: 10px;
  min-height: 1.4em;
  font-size: 0.9rem;
  color: var(--muted);
}

.status.ok { color: var(--ok); }
.status.bad { color: var(--coral, var(--danger)); }

.side-panel h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.howto {
  margin: 0 0 14px;
  padding-left: 1.2em;
  color: var(--muted);
  font-size: 0.9rem;
}

.howto li { margin-bottom: 8px; }
.howto strong { color: var(--text); }

.side-meta {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 12px;
}

.side-meta dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  margin: 0;
}

.side-meta dt { font-weight: 700; color: var(--text); }
.side-meta dd { margin: 0; }

.footnote {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  opacity: 0.9;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden { display: none; }

html.night-mode .ms-window.panel,
html.night-mode .ms-hud,
html.night-mode .board-frame,
html.night-mode .ms-board,
html.night-mode .ms-cell,
html.night-mode .ms-cell.open,
html.night-mode .ms-cell.open.alt {
  background: #c0c0c0 !important;
}


/* Daily-clear unlock gate (extreme Minesweeper) */
.board-frame {
  position: relative;
}
.board-frame.locked {
  cursor: default;
  touch-action: none;
}
.board-frame.locked .ms-board {
  filter: blur(2px) saturate(0.75);
  opacity: 0.55;
  pointer-events: none;
}
.unlock-gate {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-radius: 8px;
  background:
    linear-gradient(
      160deg,
      rgba(253, 240, 213, 0.94) 0%,
      rgba(245, 228, 196, 0.96) 100%
    );
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.unlock-gate[hidden] {
  display: none !important;
}
.unlock-gate-card {
  width: min(100%, 300px);
  text-align: center;
}
.unlock-gate-emoji {
  font-size: 2.4rem;
  line-height: 1;
  margin-bottom: 8px;
}
.unlock-gate-title {
  margin: 0 0 8px;
  font-size: 1.2rem;
  font-family: "Waukegan LDO", "Eurostile", "Arial Narrow", system-ui, sans-serif;
  font-weight: 700;
  color: var(--text);
}
.unlock-gate-text {
  margin: 0 0 8px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
}
.unlock-gate-progress {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent-2);
}
.unlock-missing {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.unlock-missing li {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
}
.unlock-gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.unlock-gate-actions .primary-link {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 800;
  text-decoration: none;
}
