@font-face {
  font-family: Chivo;
  src: url('./assets/fonts/Chivo-Regular.otf') format('opentype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Chivo;
  src: url('./assets/fonts/Chivo-SemiBold.otf') format('opentype');
  font-weight: 600;
  font-display: swap;
}
:root {
  color-scheme: light;
  --ink: #16222a;
  --muted: #55636b;
  --sky: #eaf3f8;
  --accent: #ffd23f;
  --line: 1px solid var(--ink);
  --pad: clamp(14px, 2vw, 32px);
  font: 400 16px/1.45 Chivo, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body, h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; border-radius: 0; }
button, summary { cursor: pointer; }
button { border: var(--line); background: white; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid #176597; outline-offset: 2px; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--ink); }
.svg-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.page-shell { max-width: 1600px; margin: 0 auto; padding: var(--pad); }
.site-header, .title-group, .field-caption, .field-controls, .game-message { display: flex; align-items: center; }
.site-header { justify-content: space-between; gap: 12px; padding-bottom: var(--pad); }
.title-group { gap: clamp(10px, 1.3vw, 22px); }
.mine-mark { width: clamp(36px, 4.6vw, 70px); aspect-ratio: 1; display: grid; place-items: center; background: var(--accent); border: var(--line); }
.mine-mark .icon { width: 76%; height: 76%; }
h1, h2 { font-weight: 600; text-transform: uppercase; line-height: 1; }
h1 { font-size: clamp(30px, 5vw, 80px); letter-spacing: -.055em; }
h2 { font-size: 23px; letter-spacing: -.035em; }
#back-link, .text-button { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
#back-link { font-size: 14px; }
#back-link:hover, .text-button:hover { background: var(--accent); }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) clamp(265px, 23vw, 342px); align-items: stretch; border: var(--line); }
.game-card { min-width: 0; }
.scoreboard { display: flex; flex-wrap: wrap; align-items: stretch; border-bottom: var(--line); }
.score { display: grid; align-content: center; padding: 9px clamp(14px, 2.2vw, 36px); border-right: var(--line); }
.score span, .field-caption, #settings-form label { font-size: 12px; font-weight: 600; letter-spacing: .055em; text-transform: uppercase; }
.score strong { font: 600 clamp(23px, 2.2vw, 34px)/1.2 ui-monospace, monospace; letter-spacing: -.06em; }
.restart { display: inline-flex; align-items: center; align-self: center; gap: 7px; padding: 8px 12px; margin: 8px 14px 8px auto; font-size: 14px; font-weight: 600; }
.restart:hover, .secondary-button:hover, .dialog-close:hover { background: var(--sky); }
.field-panel { padding: clamp(12px, 1.65vw, 26px); background: var(--sky); }
.field-caption { justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.field-caption span { color: var(--muted); font-weight: 400; }
.board-stage { overflow: auto; max-height: min(62vh, 780px); scrollbar-width: thin; }
.board { --cell-gap: 1px; width: max-content; margin-inline: auto; border: var(--line); background: #728692; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.board:not([data-shape="rectangle"]) { background: transparent; border-color: transparent; }
.board-row { display: grid; grid-template-columns: repeat(var(--columns), var(--cell-size)); gap: var(--cell-gap); }
.board-row + .board-row { margin-top: var(--cell-gap); }
.cell, .cell-gap { width: var(--cell-size); height: var(--cell-size); }
.cell {
  position: relative; display: grid; place-items: center; padding: 0;
  background: #c6d8e3; border: 0; box-shadow: inset 1px 1px #edf5fa, inset -2px -2px #96adba;
  color: var(--ink); font: 600 calc(var(--cell-size) * .52)/1 ui-monospace, monospace;
}
@media (hover: hover) {
  .cell:not(.revealed):not(.flagged):not([aria-disabled="true"]):hover { background: #d9e7ee; }
}
.cell:focus-visible, .editor-cell:focus-visible { outline-offset: -3px; z-index: 1; }
.cell.revealed { background: #f7fafc; box-shadow: none; }
.cell[data-number="0"] { cursor: default; }
.cell.flagged { background: var(--accent); }
.cell.flagged .icon { fill: var(--ink); }
.cell .icon { width: 57%; height: 57%; }
.cell.mine { background: #f3e8d4; box-shadow: none; }
.cell.exploded, .cell.wrong-flag { background: #f58b70; }
.cell.wrong-flag::after { content: ''; position: absolute; width: 85%; height: 2px; background: var(--ink); transform: rotate(-45deg); }
.cell[data-number="1"] { color: #215788; }
.cell[data-number="2"] { color: #266447; }
.cell[data-number="3"] { color: #a1422a; }
.cell[data-number="4"] { color: #674080; }
.cell[data-number="5"] { color: #813819; }
.cell[data-number="6"] { color: #17666f; }
.cell[data-number="8"] { color: #545e65; }
.board[data-view="overview"] .cell { cursor: zoom-in; }
.board[data-compact="true"] .cell { box-shadow: none; font-size: 0; }
.board[data-compact="true"] .cell .icon { display: none; }
.field-controls { justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.switch { display: inline-flex; }
.switch button { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 12px; font-size: 13px; }
.switch button + button { border-left: 0; }
.switch button:hover, .presets button:hover { background: #f5f8fa; }
.switch button[aria-pressed="true"] { background: var(--ink); color: white; }
.hint, #editor-help, .editor-note { font-size: 13px; color: var(--muted); margin-top: 10px; }
.game-message { gap: 12px; padding: 12px clamp(12px, 1.65vw, 26px); border-top: var(--line); font-size: 14px; flex-wrap: wrap; }
#message-title { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
#message-title::before { content: ''; width: 8px; height: 8px; background: var(--ink); }
.game-card[data-status="playing"] #message-title::before, .game-card[data-status="won"] #message-title::before { background: #277047; }
.game-card[data-status="lost"] #message-title::before { background: #a1422a; }
#message-detail { color: var(--muted); }
aside { min-width: 0; border-left: var(--line); padding: var(--pad); }
aside h2 { margin-bottom: 17px; }
.presets { display: grid; grid-template-columns: 1fr 1fr; border-top: var(--line); border-left: var(--line); }
.presets button { border: 0; border-right: var(--line); border-bottom: var(--line); padding: 11px 8px; text-align: left; }
.presets button[aria-pressed="true"] { background: var(--accent); }
.presets strong, .presets small { display: block; }
.presets small { font-size: 12px; }
#settings-form, #board-help { margin-top: 24px; padding-top: 20px; border-top: var(--line); }
#settings-form label { display: block; }
input, select { width: 100%; min-width: 0; margin: 5px 0 0; padding: 8px; background: white; border: var(--line); }
.shape-overview { display: flex; align-items: center; gap: 12px; margin-block: 12px; }
.shape-overview > div { display: grid; justify-items: start; gap: 3px; }
#shape-preview { width: 54px; height: 48px; padding: 5px; background: var(--sky); fill: #445e6e; flex: none; }
#shape-count, .text-button { font-size: 13px; }
.text-button { padding: 0; background: none; border: 0; text-align: left; }
.dimension-inputs { display: grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 16px; }
.dimension-inputs input { font-size: 16px; font-weight: 400; }
.primary-button { margin-top: 16px; padding: 10px 14px; width: 100%; background: var(--ink); color: white; font-weight: 600; }
#settings-form .primary-button { display: flex; justify-content: space-between; align-items: center; }
.primary-button:not(:disabled):hover { background: var(--accent); color: var(--ink); }
.config-error { margin-top: 12px; color: #9b3425; font-size: 14px; }
#board-help summary { font-size: 15px; font-weight: 600; }
#board-help p { margin-top: 10px; font-size: 14px; }
#shape-editor { width: min(680px, calc(100% - 24px)); max-height: calc(100dvh - 24px); border: var(--line); padding: var(--pad); color: var(--ink); }
#shape-editor::backdrop { background: #16222a85; }
.editor-heading, .editor-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dialog-close, .secondary-button { padding: 6px 10px; }
.dialog-close { font-size: 20px; line-height: 1; }
.editor-tools { flex-wrap: wrap; justify-content: flex-start; margin: 14px 0; font-size: 14px; }
#editor-count { margin-left: auto; }
.editor-stage { overflow: auto; max-height: 48dvh; padding: 5px; border: var(--line); background: var(--sky); }
#editor-grid { width: max-content; margin: auto; user-select: none; touch-action: none; }
.editor-row { display: grid; grid-template-columns: repeat(var(--columns), var(--editor-cell-size)); gap: 3px; }
.editor-row + .editor-row { margin-top: 3px; }
.editor-cell { width: var(--editor-cell-size); height: var(--editor-cell-size); padding: 0; border: 1px solid #879ba7; }
.editor-cell[aria-selected="true"] { background: #445e6e; border-color: var(--ink); }
@media (max-width: 820px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  aside { border-left: 0; border-top: var(--line); }
  .presets { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 560px) {
  .page-shell { padding: 12px 8px; }
  .site-header { flex-wrap: wrap; padding-bottom: 12px; }
  #back-link { font-size: 12px; }
  .score { padding: 6px 9px; }
  .score span { font-size: 10px; }
  .score strong { font-size: 22px; }
  .restart { font-size: 12px; padding: 8px; gap: 4px; margin-right: 7px; }
  .restart .icon { width: 14px; height: 14px; }
  .field-panel { padding: 10px; }
  .field-controls { gap: 8px; margin-top: 10px; }
  .switch button { padding: 8px; font-size: 12px; }
  .switch .icon { width: 14px; height: 14px; }
  .presets { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 360px) {
  .title-group { gap: 6px; }
  h1 { font-size: 26px; }
  .mine-mark { width: 30px; }
  .score { padding-inline: 6px; }
  .restart { gap: 3px; padding-inline: 5px; }
}
/* Nur auf Touchgeräten: Hinweis auf langes Drücken. */
@media not (pointer: coarse) { #touch-hint { display: none; } }
@media (pointer: coarse) {
  .switch button, .restart, .primary-button, .secondary-button, .dialog-close,
  #shape, .dimension-inputs input, .text-button, #board-help summary { min-height: 44px; }
  .text-button { padding-inline: 4px; }
  #board-help summary { align-content: center; }
}
@media (max-width: 560px) and (pointer: coarse) {
  .field-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .switch { display: grid; grid-template-columns: auto auto; }
  .switch button { padding-inline: 3px; }
}
@media (max-width: 360px) and (pointer: coarse) {
  .field-controls { grid-template-columns: 1fr; }
  .switch { grid-template-columns: 1fr 1fr; }
}
