/* Minensuche im ISSON-Stil „Lieferschein“. Farben und Schriften setzt spiele.css. */

* { box-sizing: border-box; }

body {
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 660px;
  margin: 0 auto;
  padding: 28px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---------- Kopfzeile ---------- */

.app__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  border-bottom: 2px solid var(--tinte);
  padding-bottom: 14px;
}

.app__title {
  margin: 0;
  font-family: var(--schrift-titel);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--tinte);
}

.app__meta { display: flex; flex-wrap: wrap; gap: 8px 22px; }

.meta__item { display: flex; flex-direction: column; gap: 2px; }

.meta__label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-leise);
}

.meta__value {
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--tinte);
}

/* Experte (30 Spalten) bekommt mehr Breite */
body[data-level="expert"] .app { max-width: 1000px; }

/* ---------- Spielfeld ---------- */

.board__frame { display: flex; flex-direction: column; gap: 12px; }

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.controls__right { display: flex; align-items: center; gap: 8px; }

.segmented { display: inline-flex; border: 1px solid var(--tinte); }

.segmented button {
  min-height: 44px;
  padding: 6px 14px;
  font: 500 0.92rem/1.2 var(--schrift-text);
  color: var(--tinte);
  background: var(--papier);
  border: 0;
  border-radius: 0;
  cursor: pointer;
  transition: background-color 180ms var(--ease), color 180ms var(--ease);
}

.segmented button + button { border-left: 1px solid var(--tinte); }
.segmented button:hover { background: var(--surface-2); }
.segmented button[aria-pressed="true"] { background: var(--tinte); color: var(--papier); font-weight: 600; }

.icon { width: 18px; height: 18px; flex: none; }

/* Das Feld scrollt bei Bedarf in seinem eigenen Rahmen, nie die ganze Seite. */
.board__field {
  position: relative;
  overflow-x: auto;
  border: 2px solid var(--tinte);
  background: #AEB5BA;
}

/* ---------- Zellen-Raster ---------- */

.grid {
  --cols: 9;
  --rows: 9;
  --min-cell: 0px;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(var(--min-cell), 1fr));
  gap: 1px;
  background: #AEB5BA;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

body[data-level="expert"] .grid { --min-cell: 28px; }

.cell {
  aspect-ratio: 1 / 1;
  min-width: 0;
  display: grid;
  place-items: center;
  padding: 0;
  font-family: var(--schrift-text);
  font-weight: 700;
  font-size: 1em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--tinte);
  background: #E3E6E8;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  transition: background-color 0.08s ease;
}

.cell svg { width: 66%; height: 66%; display: block; }

.cell:hover { background: #D2D6D9; }
.cell:focus-visible { outline: 2px solid var(--tinte); outline-offset: -2px; box-shadow: none; }

/* Tastatur-Cursor: Leuchtstift-Rahmen */
/* Tastatur-Cursor: nur sichtbar, solange das Feld den Fokus hat */
.grid:focus-visible { outline: none; box-shadow: none; }
.grid:focus-visible .cell.is-cursor,
.grid:focus-within .cell.is-cursor:focus-visible { outline: 3px solid var(--cyan); outline-offset: -3px; box-shadow: inset 0 0 0 4px var(--tinte); }
.board__field:has(.grid:focus-visible) { outline: 2px solid var(--tinte); outline-offset: 2px; box-shadow: 0 0 0 5px var(--cyan); }

.cell--revealed { background: var(--papier); cursor: default; }
.cell--revealed:hover { background: var(--papier); }

/* Zahlenfarben: dunkle, gut unterscheidbare Töne (alle >= 4.5:1 auf Weiss) */
.cell--n1 { color: #1D4ED8; }
.cell--n2 { color: #166534; }
.cell--n3 { color: #9A3412; }
.cell--n4 { color: #312E81; }
.cell--n5 { color: #6B21A8; }
.cell--n6 { color: #0F766E; }
.cell--n7 { color: #000000; }
.cell--n8 { color: #4A4A4A; }

.cell--flagged { color: var(--tinte); }
.cell--mine { background: var(--papier); color: var(--fehler); }
.cell--exploded { background: var(--fehler); color: var(--papier); }
.cell--wrong { background: var(--papier); color: var(--fehler); }

/* ---------- Overlay ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.35);
  text-align: center;
}

/* Meldung als kleiner Beleg über dem Feld, das Feld bleibt lesbar */
.overlay__karte {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  padding: 18px 22px;
  background: var(--papier);
  border: 2px solid var(--tinte);
}

.overlay[hidden] { display: none; }

.overlay__title {
  margin: 0;
  font-family: var(--schrift-titel);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.overlay__hint { margin: 0; max-width: 34ch; color: var(--text-leise); font-size: 0.95rem; }

.button {
  min-height: 44px;
  margin-top: 6px;
  padding: 0.6rem 1.1rem;
  font: 600 0.95rem/1.2 var(--schrift-text);
  color: var(--papier);
  background: var(--tinte);
  border: 2px solid var(--tinte);
  border-radius: 0;
  cursor: pointer;
  transition: background-color 180ms var(--ease), color 180ms var(--ease);
}

.button:hover { background: var(--papier); color: var(--tinte); }

.button--ghost { display: inline-flex; align-items: center; gap: 0.45rem; margin-top: 0; color: var(--tinte); background: var(--papier); }
.button--ghost:hover { background: var(--surface-2); color: var(--tinte); }
.button--ghost[aria-pressed="true"] { color: var(--papier); background: var(--tinte); }

/* ---------- Tastenlegende ---------- */

.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 24px; padding-top: 4px; }

.legend__copyright { flex-basis: 100%; text-align: center; font-size: 0.78rem; color: var(--text-leise); }

.legend__group { display: inline-flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 5px; font-size: 0.85rem; color: var(--text-leise); }

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  font: 600 0.75rem/1.3 var(--schrift-text);
  text-align: center;
  color: var(--tinte);
  background: var(--papier);
  border: 1px solid var(--tinte);
  border-radius: 0;
}

@media (max-width: 420px) {
  .app { padding: 20px 16px 32px; }
  .app__meta { gap: 8px 16px; }
  .meta__value { font-size: 1.1rem; }
  .legend { gap: 8px 14px; }
  .controls { justify-content: flex-start; }
  .segmented { width: 100%; }
  .segmented button { flex: 1 1 0; }
}
