/* Ported from prototypes/minesweeper — scoped under .ms-root */

.ms-root {
  height: 100%;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--ink);
  background: var(--stage);
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.35;
  box-sizing: border-box;
}

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

.ms-root .activity-stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
}

:root,
:root[data-theme='light-slate'],
:root[data-theme='light'] {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.35;
  --ink: #1c2430;
  --muted: #5a6573;
  --panel: #e8eef5;
  --panel-edge: #9aa8b8;
  --stage: #d7dde5;
  --chip: #f4f7fb;
  --chip-hover: #ffffff;
  --accent: #3d6a96;
  --accent-fill: #5b8ec0;
  --accent-text: #2f5f8f;
  --board-well: #c5d0dc;
  --board-edge: #aeb9c6;
  --covered: #9aa7b5;
  --covered-hi: #b7c2ce;
  --covered-lo: #7d8a99;
  --open: #eceff3;
  --danger: #c62828;
  --n1: #1976d2;
  --n2: #2e7d32;
  --n3: #c62828;
  --n4: #6a1b9a;
  --n5: #ef6c00;
  --n6: #00838f;
  --n7: #37474f;
  --n8: #263238;
  --gap: 2px;
  --board-pad: 0.35rem;
}

:root[data-theme='light-paper'] {
  color-scheme: light;
  --ink: #2a2a2a;
  --muted: #6e6a64;
  --panel: #f3f1ec;
  --panel-edge: #cfc8bc;
  --stage: #e4e0d8;
  --chip: #faf8f4;
  --chip-hover: #ffffff;
  --accent: #5a6b4f;
  --accent-fill: #6f8262;
  --accent-text: #4a5a40;
  --board-well: #ddd6cb;
  --board-edge: #c4bbae;
  --covered: #b7b0a4;
  --covered-hi: #cdc6ba;
  --covered-lo: #9a9388;
  --open: #f7f5f0;
  --danger: #b33a2b;
  --n1: #3b6ea5;
  --n2: #3f6b3a;
  --n3: #b33a2b;
  --n4: #6b4a8a;
  --n5: #b86a1e;
  --n6: #2f6f74;
  --n7: #4a4640;
  --n8: #2a2a2a;
}

:root[data-theme='light-mint'] {
  color-scheme: light;
  --ink: #1e2f2c;
  --muted: #5a736d;
  --panel: #e7f2ef;
  --panel-edge: #9bb8b0;
  --stage: #d3e5e0;
  --chip: #f2faf7;
  --chip-hover: #ffffff;
  --accent: #2f7a6b;
  --accent-fill: #3d9583;
  --accent-text: #246457;
  --board-well: #c5ddd6;
  --board-edge: #9bb8b0;
  --covered: #8fafa5;
  --covered-hi: #a9c5bc;
  --covered-lo: #6f9187;
  --open: #eef7f4;
  --danger: #c62828;
  --n1: #1e6f9f;
  --n2: #2e7d32;
  --n3: #c62828;
  --n4: #6a1b9a;
  --n5: #ef6c00;
  --n6: #00796b;
  --n7: #37474f;
  --n8: #1e2f2c;
}

:root[data-theme='dark-slate'],
:root[data-theme='dark'] {
  color-scheme: dark;
  --ink: #e8eef5;
  --muted: #9aa8b8;
  --panel: #2a3340;
  --panel-edge: #4a5563;
  --stage: #1a2028;
  --chip: #343e4c;
  --chip-hover: #3e4a5a;
  --accent: #7eb0d8;
  --accent-fill: #4a7ab0;
  --accent-text: #9ec8ea;
  --board-well: #1e2630;
  --board-edge: #4a5563;
  --covered: #4a5563;
  --covered-hi: #5c6878;
  --covered-lo: #3a4452;
  --open: #323c48;
  --danger: #ef5350;
  --n1: #64b5f6;
  --n2: #81c784;
  --n3: #ef5350;
  --n4: #ce93d8;
  --n5: #ffb74d;
  --n6: #4dd0e1;
  --n7: #cfd8dc;
  --n8: #eceff1;
}

:root[data-theme='dark-midnight'] {
  color-scheme: dark;
  --ink: #e6eefc;
  --muted: #8fa0c0;
  --panel: #1b2438;
  --panel-edge: #3a4a6a;
  --stage: #0f1524;
  --chip: #243049;
  --chip-hover: #2d3b58;
  --accent: #8fb4ff;
  --accent-fill: #4d6fbf;
  --accent-text: #a8c4ff;
  --board-well: #121a2c;
  --board-edge: #3a4a6a;
  --covered: #2f3d5c;
  --covered-hi: #3d4f73;
  --covered-lo: #24304a;
  --open: #1e2a42;
  --danger: #ff6b7a;
  --n1: #7eb6ff;
  --n2: #7ddea0;
  --n3: #ff6b7a;
  --n4: #c9a0ff;
  --n5: #ffc078;
  --n6: #6de0d8;
  --n7: #d7e0f2;
  --n8: #e6eefc;
}

:root[data-theme='dark-ember'] {
  color-scheme: dark;
  --ink: #f3ebe4;
  --muted: #b5a79c;
  --panel: #2c2622;
  --panel-edge: #56483e;
  --stage: #1a1613;
  --chip: #3a322c;
  --chip-hover: #463c35;
  --accent: #e0a878;
  --accent-fill: #b07545;
  --accent-text: #e8b98a;
  --board-well: #1f1a17;
  --board-edge: #56483e;
  --covered: #4a4038;
  --covered-hi: #5c5147;
  --covered-lo: #3a322c;
  --open: #342c27;
  --danger: #ff7a6a;
  --n1: #7eb6ff;
  --n2: #8fd18a;
  --n3: #ff7a6a;
  --n4: #d4a0ff;
  --n5: #ffb86b;
  --n6: #6fd0c7;
  --n7: #ddd2c8;
  --n8: #f3ebe4;
}

.activity-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: stretch;
  padding: 0;
  overflow: hidden;
}

.activity-frame {
  width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.65rem;
  background: var(--panel);
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

.top-bar {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
}

.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.theme-picker select {
  max-width: 11rem;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  background: var(--chip);
  color: var(--ink);
}

.chrome {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.stat:last-child {
  text-align: right;
  align-items: end;
}

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

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

.reset {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.25rem 0.65rem;
  border: 2px solid var(--panel-edge);
  border-radius: 8px;
  background: var(--chip);
  color: var(--ink);
  cursor: pointer;
}

.reset:hover {
  background: var(--chip-hover);
}

.reset-face {
  font-size: 1.35rem;
  line-height: 1;
}

.reset-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--muted);
}

.title {
  flex: 0 0 auto;
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

.setup-lead {
  flex: 0 0 auto;
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.activity-frame--setup {
  justify-content: center;
  gap: 0.45rem;
}

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  width: min(100%, 22rem);
  margin: 0 auto;
  min-height: 0;
  overflow: hidden;
}

.preset {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.65rem;
  border: 2px solid var(--panel-edge);
  border-radius: 8px;
  background: var(--chip);
  cursor: pointer;
}

.preset-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.preset-name {
  font-weight: 600;
}

.preset-max {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.score-bar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.score-value {
  color: var(--ink);
  font-weight: 700;
}

.score-value--floor {
  color: var(--accent-text);
  animation: score-floor-pulse 1.1s ease-in-out infinite;
}

.score-floor-note {
  flex: 0 0 auto;
  margin: 0;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-text);
  animation: score-floor-pulse 1.1s ease-in-out infinite;
}

@keyframes score-floor-pulse {
  0%,
  100% {
    opacity: 1;
    filter: brightness(1);
  }
  50% {
    opacity: 0.72;
    filter: brightness(1.15);
  }
}

.preset--active {
  border-color: var(--accent);
  background: var(--chip-hover);
}

.preset input {
  margin: 0;
}

.primary {
  display: block;
  margin: 0.25rem auto 0;
  padding: 0.55rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-fill);
  color: #fff;
  cursor: pointer;
}

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

.play-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.linkish {
  border: none;
  background: none;
  color: var(--accent-text);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.play-size {
  font-variant-numeric: tabular-nums;
}

.board-wrap {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: grid;
  place-items: center;
  container-type: size;
  overflow: hidden;
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  gap: var(--gap);
  padding: var(--board-pad);
  background: var(--board-well);
  border: 2px solid var(--board-edge);
  aspect-ratio: var(--cols) / var(--rows);
  width: min(100cqw, calc(100cqh * var(--cols) / var(--rows)));
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

.cell {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 3px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: clamp(0.65rem, 2.8cqmin, 1.15rem);
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
}

.cell--covered {
  background: var(--covered);
  box-shadow: inset 1px 1px 0 var(--covered-hi), inset -1px -1px 0 var(--covered-lo);
}

.cell--flag {
  background: var(--covered);
  box-shadow: inset 1px 1px 0 var(--covered-hi), inset -1px -1px 0 var(--covered-lo);
  font-size: clamp(0.7rem, 3cqmin, 1.25rem);
}

.cell--open {
  background: var(--open);
  box-shadow: none;
  cursor: default;
}

.cell--mine {
  background: var(--open);
  font-size: clamp(0.7rem, 3cqmin, 1.25rem);
}

.cell--exploded {
  background: color-mix(in srgb, var(--danger) 35%, var(--open));
  outline: 2px solid var(--danger);
  outline-offset: -2px;
}

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

.cell:disabled {
  cursor: default;
}

.params {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 0.65rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.params--setup {
  width: min(100%, 20rem);
  margin: 0 auto;
}

.params--disabled {
  opacity: 0.45;
}

.params label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.params input {
  width: 3rem;
  padding: 0.1rem 0.25rem;
  background: var(--chip);
  color: var(--ink);
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
}

.hint {
  flex: 0 0 auto;
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
}
