/* Minesweeper "Sonar" (AP3-43). Loaded only by the game document, after styles.css: the colours are the game's own
   tokens per theme (concept, table "Farben"); --minesweeper-rand is the line of covered cells (minesweeper/E-18) and of
   buttons and the mode switch (WCAG 1.4.11), at least 3:1 against open cells, the board and every ground it touches.
   Layouts follow the width of the game document (minesweeper/E-16): wide from 720px, narrow below. Text in DM Sans
   300 to 500 only, without a faked bold (minesweeper/E-36). Nothing moves and nothing has a transition in this
   package; motion comes with AP3-44. */

:root {
  --minesweeper-grund: #e7f2f6;
  --minesweeper-karte: #ffffff;
  --minesweeper-karte-2: #eef6f9;
  --minesweeper-text: #0b2a38;
  --minesweeper-leise: #456272;
  --minesweeper-akzent: #006c8a;
  --minesweeper-akzent-text: #ffffff;
  --minesweeper-verdeckt: #c6e0e9;
  --minesweeper-verdeckt-hell: #afd4e0;
  --minesweeper-offen: #f7fbfc;
  --minesweeper-rand: #5f8494;
  --minesweeper-n1: #00609a;
  --minesweeper-n2: #0a6e47;
  --minesweeper-n3: #8c5400;
  --minesweeper-n4: #ad361b;
  --minesweeper-n5: #85269a;
  --minesweeper-n6: #3949ad;
  --minesweeper-n7: #16242c;
  --minesweeper-n8: #52616c;
  --minesweeper-mine: #c0163a;
  --minesweeper-boje: #b34e08;
  --minesweeper-gut: #0a6e47;
  --minesweeper-linie: rgba(0, 88, 118, 0.22);
  --minesweeper-ring: rgba(0, 108, 138, 0.1);
  --minesweeper-leuchten: rgba(0, 108, 138, 0.3);
  --minesweeper-schleier: rgba(231, 242, 246, 0.74);
  --minesweeper-schatten: 0 18px 40px rgba(11, 42, 56, 0.22);
  --minesweeper-glanz: none;
}

[data-theme="dark"] {
  --minesweeper-grund: #03111a;
  --minesweeper-karte: #061b27;
  --minesweeper-karte-2: #0a2433;
  --minesweeper-text: #d8eef7;
  --minesweeper-leise: #8cadbd;
  --minesweeper-akzent: #5ee4ff;
  --minesweeper-akzent-text: #02121b;
  --minesweeper-verdeckt: #0b2634;
  --minesweeper-verdeckt-hell: #123a4c;
  --minesweeper-offen: #020b11;
  --minesweeper-rand: #4d8299;
  --minesweeper-n1: #5ee4ff;
  --minesweeper-n2: #6ff0b0;
  --minesweeper-n3: #ffd166;
  --minesweeper-n4: #ff9f7a;
  --minesweeper-n5: #f08cff;
  --minesweeper-n6: #aab6ff;
  --minesweeper-n7: #ffffff;
  --minesweeper-n8: #a3b6c4;
  --minesweeper-mine: #ff5a76;
  --minesweeper-boje: #ffa15c;
  --minesweeper-gut: #6ff0b0;
  --minesweeper-linie: rgba(94, 228, 255, 0.16);
  --minesweeper-ring: rgba(94, 228, 255, 0.08);
  --minesweeper-leuchten: rgba(94, 228, 255, 0.4);
  --minesweeper-schleier: rgba(2, 10, 16, 0.62);
  --minesweeper-schatten: 0 18px 40px rgba(0, 0, 0, 0.55);
  --minesweeper-glanz: 0 0 8px var(--minesweeper-leuchten);
}

/* The game document has its own calm ground instead of the layered page background of styles.css. */
.minesweeper-body {
  min-height: 100dvh;
  margin: 0;
  background: var(--minesweeper-grund);
  color: var(--minesweeper-text);
  font-family: "DM Sans", sans-serif;
  font-size: 16px;
  font-weight: 400;
  font-synthesis-weight: none;
  line-height: 1.5;
}

.minesweeper-body::before,
.minesweeper-body::after {
  content: none;
}

.minesweeper-body p,
.minesweeper-body h1,
.minesweeper-body h2,
.minesweeper-body dl,
.minesweeper-body dd,
.minesweeper-body ol {
  margin: 0;
}

.minesweeper-body p {
  line-height: 1.5;
}

.minesweeper-body h1,
.minesweeper-body h2 {
  font-weight: 500;
}

/* Without specificity of its own, so every button class below sets its size, weight and colour. */
:where(.minesweeper-body) button {
  font: inherit;
  color: inherit;
}

.minesweeper-body button:focus-visible {
  outline: 2px solid var(--minesweeper-akzent);
  outline-offset: 2px;
}

.minesweeper-symbole {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Pinned to the top left, so a hidden text after the last block never lengthens the document. */
.minesweeper-unsichtbar {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.minesweeper-symbol {
  display: block;
  width: 24px;
  height: 24px;
}

/* The page of the game: one column narrow, head over board and side column wide. Its height is the window, so the
   area of the board has a size of its own and scrolls in itself when "Schwer" does not fit (minesweeper/E-16). */
.minesweeper {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100dvh;
  padding: 12px 12px 14px;
}

.minesweeper-kopf {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  min-height: 48px;
}

.minesweeper-logo {
  flex: none;
  width: 30px;
  height: 30px;
  color: var(--minesweeper-akzent);
}

.minesweeper-titelblock {
  flex: 1 1 auto;
  min-width: 0;
}

.minesweeper-titel {
  font-size: 16px;
  letter-spacing: 0.24em;
  line-height: 1.2;
  text-transform: uppercase;
}

.minesweeper-unterzeile {
  color: var(--minesweeper-leise);
  font-size: 13px;
}

.minesweeper-anzeigen {
  display: flex;
  gap: 12px;
}

.minesweeper-anzeige {
  display: flex;
  flex-direction: column;
  padding-left: 12px;
  border-left: 1px solid var(--minesweeper-linie);
}

.minesweeper-anzeige--zeit {
  min-width: 72px;
}

.minesweeper-anzeige-name {
  color: var(--minesweeper-leise);
  font-size: 11px;
  letter-spacing: 0.16em;
  line-height: 1.3;
  text-transform: uppercase;
}

.minesweeper-anzeige-wert {
  color: var(--minesweeper-akzent);
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  line-height: 1.1;
  text-shadow: var(--minesweeper-glanz);
}

/* Buttons: a line of --minesweeper-rand around every control, because the fill of a button alone barely differs from
   the card or ground beside it. */
.minesweeper-knopf,
.minesweeper-stufe,
.minesweeper-modusknopf,
.minesweeper-ortenknopf,
.minesweeper-symbolknopf {
  border: 1px solid var(--minesweeper-rand);
  border-radius: 10px;
  background: var(--minesweeper-karte-2);
  cursor: pointer;
  touch-action: manipulation;
}

.minesweeper-knopf {
  min-height: 44px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 500;
}

.minesweeper-knopf--haupt,
.minesweeper-stufe[aria-pressed="true"],
.minesweeper-modusknopf[aria-pressed="true"] {
  border-color: var(--minesweeper-akzent);
  background: var(--minesweeper-akzent);
  color: var(--minesweeper-akzent-text);
}

.minesweeper-knopf--breit {
  width: 100%;
}

.minesweeper-knopf:disabled,
.minesweeper-ortenknopf:disabled {
  color: var(--minesweeper-leise);
  cursor: default;
}

.minesweeper-symbolknopf {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-left: auto;
  padding: 0;
}

.minesweeper-stufen {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.minesweeper-stufe {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 2px 8px;
  line-height: 1.2;
}

.minesweeper-stufe-name {
  font-size: 14px;
  font-weight: 500;
}

.minesweeper-stufe-groesse {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* The area of the board: the board stands in its middle and the area scrolls in itself, never the page. */
.minesweeper-flaeche {
  display: flex;
  flex: 1 1 0;
  min-height: 160px;
  overflow: auto;
}

.minesweeper-brettrahmen {
  display: grid;
  grid-template-areas:
    ". spalten"
    "zeilen brett";
  gap: 4px;
  margin: auto;
}

.minesweeper-spaltennamen,
.minesweeper-zeilennamen {
  display: flex;
  gap: var(--minesweeper-abstand, 3px);
  color: var(--minesweeper-leise);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.minesweeper-spaltennamen {
  grid-area: spalten;
  padding: 0 13px;
}

.minesweeper-zeilennamen {
  grid-area: zeilen;
  flex-direction: column;
  padding: 13px 0;
}

.minesweeper-spaltennamen > span,
.minesweeper-zeilennamen > span {
  display: grid;
  place-items: center;
  flex: none;
  width: var(--minesweeper-zelle, 24px);
  min-width: 18px;
  height: 18px;
}

.minesweeper-zeilennamen > span {
  width: 22px;
  height: var(--minesweeper-zelle, 24px);
}

/* The board: decorative sonar rings and, wide, a crosshair through the middle behind the cells. */
.minesweeper-brett {
  display: flex;
  flex-direction: column;
  grid-area: brett;
  gap: var(--minesweeper-abstand, 3px);
  padding: 8px;
  border: 1px solid var(--minesweeper-linie);
  border-radius: 14px;
  background-color: var(--minesweeper-karte);
  background-image: repeating-radial-gradient(circle at center, transparent 0 47px, var(--minesweeper-ring) 47px 48px);
}

.minesweeper-reihe {
  display: flex;
  gap: var(--minesweeper-abstand, 3px);
}

.minesweeper-zelle {
  flex: none;
  width: var(--minesweeper-zelle, 24px);
  height: var(--minesweeper-zelle, 24px);
}

.minesweeper-feld {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-size: var(--minesweeper-ziffer, 14px);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.minesweeper-body .minesweeper-feld:focus-visible {
  outline: 2px solid var(--minesweeper-akzent);
  outline-offset: 1px;
}

.minesweeper-feld.ist-verdeckt,
.minesweeper-feld.ist-boje {
  border-color: var(--minesweeper-rand);
  background: var(--minesweeper-verdeckt);
}

.minesweeper-feld.ist-boje {
  color: var(--minesweeper-boje);
}

.minesweeper-brett.ist-gewonnen .minesweeper-feld.ist-boje {
  color: var(--minesweeper-gut);
}

.minesweeper-feld.ist-offen:not([data-minesweeper-zahl=""]) {
  background: var(--minesweeper-offen);
  text-shadow: var(--minesweeper-glanz);
}

.minesweeper-feld[data-minesweeper-zahl="1"] { color: var(--minesweeper-n1); }
.minesweeper-feld[data-minesweeper-zahl="2"] { color: var(--minesweeper-n2); }
.minesweeper-feld[data-minesweeper-zahl="3"] { color: var(--minesweeper-n3); }
.minesweeper-feld[data-minesweeper-zahl="4"] { color: var(--minesweeper-n4); }
.minesweeper-feld[data-minesweeper-zahl="5"] { color: var(--minesweeper-n5); }
.minesweeper-feld[data-minesweeper-zahl="6"] { color: var(--minesweeper-n6); }
.minesweeper-feld[data-minesweeper-zahl="7"] { color: var(--minesweeper-n7); }
.minesweeper-feld[data-minesweeper-zahl="8"] { color: var(--minesweeper-n8); }

.minesweeper-feld.ist-offen {
  cursor: default;
}

.minesweeper-feld.ist-offen:not([data-minesweeper-zahl=""]) {
  cursor: pointer;
}

.minesweeper-feld.ist-mine {
  border-color: color-mix(in srgb, var(--minesweeper-mine) 50%, transparent);
  background: color-mix(in srgb, var(--minesweeper-mine) 12%, transparent);
  color: var(--minesweeper-mine);
}

.minesweeper-feld.ist-getroffen {
  border-color: var(--minesweeper-mine);
  background: var(--minesweeper-mine);
  color: var(--minesweeper-offen);
}

.minesweeper-feld.ist-falsch {
  border-color: var(--minesweeper-rand);
  background: var(--minesweeper-offen);
  color: var(--minesweeper-leise);
}

.minesweeper-feld.ist-falsch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 12%;
  width: 76%;
  height: 2px;
  background: var(--minesweeper-mine);
  transform: rotate(-45deg);
}

.minesweeper-feldsymbol {
  width: 68%;
  height: 68%;
}

/* The hint: a ring around its target, an inner ring in each source (concept, section "Hinweis"). */
.minesweeper-feld.ist-ziel {
  box-shadow: 0 0 0 2px var(--minesweeper-gut);
}

.minesweeper-feld.ist-quelle {
  box-shadow: inset 0 0 0 2px var(--minesweeper-n3);
}

.minesweeper-brett[aria-readonly="true"] .minesweeper-feld {
  cursor: default;
}

/* The line and the bottom bar of the narrow layout. */
.minesweeper-zeile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--minesweeper-linie);
  border-radius: 12px;
  background: var(--minesweeper-karte);
}

.minesweeper-zeilentext {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  text-wrap: pretty;
}

.minesweeper-leiste {
  display: flex;
  gap: 8px;
}

.minesweeper-moduswahl {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.minesweeper-modusknopf {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 8px;
  font-size: 14px;
  font-weight: 500;
}

.minesweeper-ortenknopf {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 76px;
  min-height: 66px;
  font-size: 13px;
  font-weight: 500;
}

/* The side column of the wide layout. */
.minesweeper-karte {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--minesweeper-linie);
  border-radius: 12px;
  background: var(--minesweeper-karte);
}

.minesweeper-augenbraue {
  color: var(--minesweeper-leise);
  font-size: 11px;
  letter-spacing: 0.16em;
  line-height: 1.3;
  text-transform: uppercase;
}

.minesweeper-body h2.minesweeper-augenbraue {
  font-size: 11px;
  font-weight: 400;
}

.minesweeper-statustitel {
  font-size: 22px;
  font-weight: 500;
  line-height: 1.25;
}

.minesweeper-statustext,
.minesweeper-hinweistext {
  font-size: 14px;
  text-wrap: pretty;
}

.minesweeper-balken {
  height: 6px;
  border-radius: 3px;
  background: var(--minesweeper-karte-2);
  overflow: hidden;
}

.minesweeper-balken-fuellung {
  display: block;
  width: 0;
  height: 100%;
  background: var(--minesweeper-akzent);
}

.minesweeper-logbuch {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.minesweeper-logbuch-zeit {
  color: var(--minesweeper-leise);
  font-variant-numeric: tabular-nums;
}

.minesweeper-logbuch-leer {
  color: var(--minesweeper-leise);
  font-size: 13px;
}

.minesweeper-kennzahlen {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.minesweeper-kennzahl {
  padding: 8px;
  border-radius: 10px;
  background: var(--minesweeper-karte-2);
  text-align: center;
}

.minesweeper-kennzahl dt {
  color: var(--minesweeper-leise);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.minesweeper-kennzahl dd {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.minesweeper-bedienhilfe {
  color: var(--minesweeper-leise);
  font-size: 12px;
}

.minesweeper-bedienhilfe kbd {
  padding: 0 4px;
  border: 1px solid var(--minesweeper-rand);
  border-radius: 4px;
  font-family: inherit;
  font-size: 11px;
}

/* The result (minesweeper/E-22): narrow a sheet from below, wide a card the script places over the board. */
.minesweeper-ergebnis {
  width: 100%;
  max-width: 100%;
  max-height: calc(100dvh - 24px);
  margin: auto 0 0;
  padding: 10px 20px 20px;
  border: 0;
  border-top: 2px solid var(--minesweeper-akzent);
  border-radius: 22px 22px 0 0;
  background: var(--minesweeper-karte);
  color: var(--minesweeper-text);
  box-shadow: var(--minesweeper-schatten);
  overflow-y: auto;
}

.minesweeper-ergebnis::backdrop {
  background: var(--minesweeper-schleier);
}

.minesweeper-ergebnis > * + * {
  margin-top: 10px;
}

.minesweeper-griff {
  display: block;
  width: 40px;
  height: 4px;
  margin: 0 auto 8px;
  border-radius: 2px;
  background: var(--minesweeper-rand);
}

.minesweeper-plakette {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--minesweeper-gut);
  color: var(--minesweeper-akzent-text);
  font-size: 13px;
  font-weight: 500;
}

.minesweeper-ergebnis-titel {
  font-size: 22px;
  line-height: 1.25;
}

.minesweeper-ergebniszahlen {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.minesweeper-ergebniszahlen > div {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--minesweeper-karte-2);
}

.minesweeper-ergebniszahlen dt {
  color: var(--minesweeper-leise);
  font-size: 12px;
}

.minesweeper-ergebniszahlen dd {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.minesweeper-vermerk {
  color: var(--minesweeper-leise);
  font-size: 13px;
}

.minesweeper-ergebnisknoepfe {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.minesweeper-ergebnisknoepfe .minesweeper-knopf {
  flex: 1 1 140px;
}

/* Wide layout from 720px (minesweeper/E-16). */
@media (min-width: 720px) {
  .minesweeper {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 272px;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "kopf kopf"
      "flaeche seite";
    gap: 0 24px;
    padding: 0 24px 0 0;
  }

  .minesweeper-kopf {
    grid-area: kopf;
    gap: 12px 20px;
    margin-right: -24px;
    padding: 18px 32px;
    border-bottom: 1px solid var(--minesweeper-linie);
  }

  .minesweeper-logo {
    width: 38px;
    height: 38px;
  }

  .minesweeper-titel {
    font-size: 22px;
    letter-spacing: 0.34em;
  }

  .minesweeper-anzeigen {
    gap: 16px;
  }

  .minesweeper-anzeige {
    min-width: 104px;
    padding-left: 16px;
  }

  .minesweeper-anzeige-wert {
    font-size: 30px;
  }

  .minesweeper-stufen {
    display: flex;
    gap: 6px;
  }

  .minesweeper-stufe {
    min-width: 84px;
  }

  .minesweeper-flaeche {
    grid-area: flaeche;
    min-height: 0;
    padding: 16px 0 16px 16px;
  }

  .minesweeper-brett {
    padding: 12px;
    background-image:
      linear-gradient(var(--minesweeper-ring), var(--minesweeper-ring)),
      linear-gradient(var(--minesweeper-ring), var(--minesweeper-ring)),
      repeating-radial-gradient(circle at center, transparent 0 63px, var(--minesweeper-ring) 63px 64px);
    background-position: center, center, center;
    background-repeat: no-repeat, no-repeat, repeat;
    background-size: 1px 100%, 100% 1px, auto;
  }

  .minesweeper-feldsymbol {
    width: 66%;
    height: 66%;
  }

  .minesweeper-seitenspalte {
    display: flex;
    flex-direction: column;
    grid-area: seite;
    gap: 12px;
    min-height: 0;
    padding: 16px 0;
    overflow-y: auto;
  }

  .minesweeper-ergebnis {
    width: min(380px, calc(100vw - 16px));
    margin: 0;
    padding: 20px;
    right: auto;
    bottom: auto;
    border: 1px solid var(--minesweeper-akzent);
    border-radius: 16px;
  }

  .minesweeper-ergebniszahlen dd {
    font-size: 24px;
  }

  .minesweeper-nur-schmal {
    display: none;
  }
}

@media (min-width: 720px) and (hover: hover) {
  .minesweeper-brett:not([aria-readonly="true"]) .minesweeper-feld.ist-verdeckt:hover {
    border-color: var(--minesweeper-akzent);
    background: var(--minesweeper-verdeckt-hell);
    box-shadow: 0 0 6px var(--minesweeper-leuchten);
  }
}

@media (max-width: 719.98px) {
  .minesweeper-nur-breit {
    display: none;
  }
}

/* The mode switch in the wide layout only where a finger or a pen can tap (minesweeper/E-4). */
@media not (any-pointer: coarse) {
  .minesweeper-nur-grob {
    display: none;
  }
}
