:root {
  --line-thin: #cbd5e1;
  --line-thick: #33475b;
  --cage-line: #344861;
  --cell-bg: #ffffff;
  --peer-bg: #e8f0fb;
  --selected-bg: #bfdcff;
  --same-value-bg: #d3e9ff;
  --error-color: #e0483e;
  --hint-color: #2e6fd1;
  --user-color: #1c2733;
  --note-color: #7c8a9a;
  --accent: #3a6fd8;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #f4f6fa;
  color: #1c2733;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 12px;
}

.app { width: 100%; max-width: 980px; }

/* --- Seitenuebergreifende Kopfzeile (nav.js) --- */

.app-nav {
  width: 100%;
  max-width: 980px;
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.app-nav-link {
  background: #fff;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #46566b;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
@media (hover: hover) { .app-nav-link:hover { background: #eef2f9; } }
.app-nav-link.active { background: var(--accent); color: #fff; }

/* Eigene Zeile im flex-wrap-Nav (siehe .app-nav) statt neben den Links zu
   quetschen - nur sichtbar unter file:// (siehe nav.js::renderFileProtocolWarning). */
.file-protocol-warning {
  width: 100%;
  background: #fff3d6;
  color: #6b5100;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12.5px;
  line-height: 1.4;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.app-header h1 { font-size: 24px; margin: 0; }
.header-title { display: flex; align-items: center; gap: 8px; }
.rules-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: #eef2f9;
  color: #46566b;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
@media (hover: hover) { .rules-btn:hover { background: #dfe9f8; } }

.difficulty-selector {
  display: flex;
  gap: 6px;
}
.diff-btn {
  background: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #46566b;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.diff-btn.active { background: var(--accent); color: #fff; }

.difficulty-fallback-note {
  flex-basis: 100%;
  font-size: 12px;
  font-weight: 600;
  color: #8a5a00;
  background: #fff3d6;
  border: 1px solid #f0d090;
  border-radius: 6px;
  padding: 4px 10px;
  margin-top: 4px;
}
.difficulty-fallback-note.hidden { display: none; }

.game-area {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
}

/* --- Dashboard (index.html) --- */

.dashboard-area {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: stretch;
}

.game-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.game-tile {
  background: #fff;
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  text-decoration: none;
  color: var(--user-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
@media (hover: hover) { .game-tile:hover { background: #f4f7fb; } }
.game-tile-title { font-size: 17px; font-weight: 700; color: var(--accent); }
.game-tile-stat { font-size: 13px; color: #46566b; }
.game-tile-stat b { color: var(--user-color); }
.game-tile-avg { font-style: italic; color: #7c8a9a; }

.game-tile-best-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin: 2px 0;
}
.game-tile-best-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #f4f7fb;
  border-radius: 6px;
  padding: 4px 2px;
}
.game-tile-best-diff { font-size: 10px; color: #7c8a9a; }
.game-tile-best-value { font-size: 13px; font-weight: 700; color: var(--user-color); }

.week-trend { font-size: 14px; color: #46566b; }

/* --- Board --- */

.board-panel { flex: 0 0 auto; display: flex; flex-direction: column; gap: 14px; }

.global-stats {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.global-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.global-stats-table th {
  font-size: 11px;
  font-weight: 600;
  color: #7c8a9a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-bottom: 8px;
}
.global-stats-table td {
  text-align: center;
  padding: 4px 6px;
  font-weight: 700;
  color: var(--user-color);
}
.global-stats-table .global-stats-row-label {
  text-align: left;
  font-weight: 600;
  color: #46566b;
  text-transform: none;
}

.stats-section-title {
  font-size: 11px;
  font-weight: 600;
  color: #7c8a9a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 14px 0 8px;
  padding-top: 12px;
  border-top: 1px solid #eef2f9;
}
.best-times-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.best-time-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: #f4f7fb;
  border-radius: 8px;
  padding: 8px 4px;
}
.best-time-diff { font-size: 11px; color: #7c8a9a; }
.best-time-value { font-size: 15px; font-weight: 700; color: var(--user-color); }

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.leaderboard-list li {
  display: flex;
  justify-content: space-between;
  background: #f4f7fb;
  border-radius: 6px;
  padding: 5px 10px;
}

.streaks-row {
  margin-top: 12px;
  justify-content: space-around;
  background: none;
  box-shadow: none;
  padding: 0;
}

.board {
  --board-size: 9;
  --cell: min(60px, calc((100vw - 32px) / var(--board-size)));
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--board-size), var(--cell));
  grid-template-rows: repeat(var(--board-size), var(--cell));
  border: 2px solid var(--line-thick);
  background: var(--cell-bg);
  user-select: none;
}

#cage-borders {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.cage-border-path {
  fill: none;
  stroke: var(--cage-line);
  stroke-width: 0.02;
  stroke-dasharray: 0.06 0.03;
}

.cell {
  position: relative;
  border-right: 1px solid var(--line-thin);
  border-bottom: 1px solid var(--line-thin);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell) * 0.45);
  font-weight: 600;
  color: var(--user-color);
  cursor: pointer;
  background: var(--cell-bg);
}
.cell.thick-right { border-right: 2px solid var(--line-thick); }
.cell.thick-bottom { border-bottom: 2px solid var(--line-thick); }

.cell.peer { background: var(--peer-bg); }
.cell.same-value { background: var(--same-value-bg); }
.cell.selected { background: var(--selected-bg); }
.cell.error { color: var(--error-color); }
.cell.hint-target { box-shadow: inset 0 0 0 2px var(--hint-color); }
.cell.hint-context { background: #fff3d6; }
.cell.hint-context.hint-target { background: #fff3d6; box-shadow: inset 0 0 0 2px var(--hint-color); }

.cage-sum {
  position: absolute;
  top: calc(var(--cell) * 0.08);
  left: calc(var(--cell) * 0.08);
  font-size: calc(var(--cell) * 0.19);
  line-height: 1;
  font-weight: 600;
  color: var(--cage-line);
  pointer-events: none;
  z-index: 1;
}

.cell-value { line-height: 1; }

/* Fester, kompakter Block (60% x 59% der Zelle, nach unten versetzt) statt
   die ganze Zelle auszufüllen – Position ist damit für jede Zelle identisch,
   unabhängig davon, ob eine Käfigsumme angezeigt wird (per Pixel-Analyse des
   Originals ermittelt: Notizen liegen bei ca. 20%/27% bis 80%/86% der Zelle). */
.notes-grid {
  position: absolute;
  top: 29%;
  left: 22%;
  width: 58%;
  height: 56%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  pointer-events: none;
}
.notes-grid span {
  font-size: calc(var(--cell) * 0.15);
  line-height: 1;
  color: var(--note-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.notes-grid span.note-error {
  color: var(--error-color);
  font-weight: 700;
}

/* --- Side panel --- */

.side-panel {
  flex: 0 0 auto;
  width: 290px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-label { font-size: 11px; color: #7c8a9a; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 18px; font-weight: 600; }
#pause-btn {
  flex: 0 0 auto;
  background: #eef2f9;
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 15px;
  color: #46566b;
}
@media (hover: hover) { #pause-btn:hover { background: #dfe9f8; } }

/* Primary action: used far more often than the tools below, so it gets
   the most prominent, easiest-to-hit spot right under the stats row. */
.notes-primary-btn {
  background: #eef2f9;
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: #46566b;
  width: 100%;
}
@media (hover: hover) { .notes-primary-btn:hover { background: #e2e9f4; } }
.notes-primary-btn .tool-icon { font-size: 20px; }
.notes-primary-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.tool-label em { display: inline; font-style: normal; font-weight: 700; margin-left: 4px; }

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.num-btn {
  background: #eef2f9;
  border: none;
  border-radius: 10px;
  font-size: 24px;
  padding: 18px 0;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}
@media (hover: hover) { .num-btn:hover { background: #dfe9f8; } }
.num-btn:disabled { opacity: 0.35; cursor: not-allowed; background: #eef2f9; }
.num-btn.hidden { display: none; }

/* Secondary tools: used rarely, so they stay small and out of the way
   below the numpad instead of competing with it for attention. */
.toolbar-secondary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.tool-btn-sm {
  background: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #7c8a9a;
}
@media (hover: hover) { .tool-btn-sm:hover { background: #f4f7fb; } }
.tool-btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }
.tool-btn-sm .tool-icon-sm { font-size: 15px; }
.tool-btn-sm.active { background: var(--accent); color: #fff; }
.tool-badge { font-style: normal; font-weight: 700; font-size: 10px; }

.endgame-solver-btn {
  background: #eef2f9;
  border: 1px solid #dbe4f0;
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #46566b;
  width: 100%;
}
@media (hover: hover) { .endgame-solver-btn:hover { background: #e2e9f4; } }
.endgame-solver-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.endgame-solver-btn.active {
  background: #fff0ea;
  border-color: #f0b39c;
  color: #b1490f;
}

.new-game-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
@media (hover: hover) { .new-game-btn:hover { background: #2f5fc0; } }
.new-game-btn.hidden { display: none; }

/* --- Hinweis-Popup ---
   Schwebt als echtes Popup ueber der Seitenleiste (Toolbar/Numpad), ist
   aber auf die Seitenleiste begrenzt (.side-panel ist position: relative),
   damit das Raetsel-Gitter links davon immer sichtbar und erreichbar bleibt. */

.hint-panel {
  position: absolute;
  /* Mindestens so hoch wie die Seitenleiste, waechst aber mit dem Hinweistext
     nach unten - der Hinweis wird nie abgeschnitten oder in einem winzigen
     Scrollfeld versteckt (z.B. lange Mastermind-Erklaerungen). */
  inset: 0 0 auto 0;
  min-height: 100%;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-top: 4px;
  background: rgba(20, 28, 40, 0.25);
  border-radius: 12px;
}
.hint-panel.hidden { display: none; }
.hint-panel-card {
  /* So breit wie die Seitenleiste - das Popup darf nie ueber das Raetsel ragen. */
  flex: 0 0 auto;
  width: 100%;
  box-sizing: border-box;
  background: #fff;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 16px 32px rgba(20,28,40,0.25), 0 2px 6px rgba(20,28,40,0.12);
  border: 1px solid #dbe4f0;
}
.hint-panel h2 { margin: 4px 0 10px; font-size: 16px; }
.hint-panel .modal-steps { margin-bottom: 12px; }
.hint-panel-actions {
  display: flex;
  gap: 8px;
}
.hint-panel-close {
  background: #eef2f9;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #46566b;
  cursor: pointer;
}
@media (hover: hover) { .hint-panel-close:hover { background: #dfe9f8; } }
.hint-panel-apply {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  flex: 1;
}
@media (hover: hover) { .hint-panel-apply:hover { background: #2f5fc0; } }
.hint-panel-apply[hidden] { display: none; }

/* --- Overlay --- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 40, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.overlay.hidden { display: none; }
.overlay-card {
  background: #fff;
  border-radius: 14px;
  padding: 28px 32px;
  text-align: center;
  max-width: 320px;
}
.overlay-card h2 { margin-top: 0; }
.overlay-card .overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.overlay-card .overlay-actions button { width: 100%; }

.light-overlay { background: rgba(20, 28, 40, 0.32); }
.modal-card {
  max-width: 380px;
  text-align: left;
}

.overlay-card input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  margin: 12px 0;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
}
.modal-kicker {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.modal-card h2 { font-size: 18px; }
.modal-card p { line-height: 1.5; color: #46566b; }
.modal-steps {
  margin: 0 0 16px;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-steps li { line-height: 1.45; color: #33475b; }
.modal-steps li b { color: var(--user-color); }

@media (max-width: 560px) {
  .side-panel { width: 100%; max-width: 340px; }
}


/* Raetsel-Menue der Kopfzeile (nav.js) */
.app-nav-menu { position: relative; }
.app-nav-menu-btn { border: none; cursor: pointer; font-family: inherit; }
.app-nav-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(20, 30, 50, 0.18);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 4px;
  width: max-content;
  max-width: calc(100vw - 24px);
}
.app-nav-panel.hidden { display: none; }
.app-nav-panel-link {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #46566b;
  text-decoration: none;
}
@media (hover: hover) { .app-nav-panel-link:hover { background: #eef2f9; } }
.app-nav-panel-link.active { background: var(--accent); color: #fff; }
@media (max-width: 420px) {
  .app-nav-panel { grid-template-columns: 1fr 1fr; }
}

/* Startseite: Kachel und Schwierigkeits-Zellen sind Links */
.game-tile { cursor: pointer; }
.game-tile-title { text-decoration: none; }
@media (hover: hover) { .game-tile-title:hover { text-decoration: underline; } }
.game-tile-best-cell { text-decoration: none; color: inherit; }
@media (hover: hover) { .game-tile-best-cell:hover { background: var(--accent); } }
@media (hover: hover) { .game-tile-best-cell:hover .game-tile-best-diff, .game-tile-best-cell:hover .game-tile-best-value { color: #fff; } }

/* --- Startseite: Vorschlaege + Generierungs-Panel --- */
.home-top { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; width: 100%; }
.home-suggest { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.home-card {
  background: #fff; border: none; border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08); text-decoration: none; text-align: left;
  display: flex; flex-direction: column; gap: 3px; cursor: pointer; font: inherit; color: inherit;
}
@media (hover: hover) { .home-card:hover { background: #f4f7fb; } }
.home-card-main { background: var(--accent); color: #fff; }
@media (hover: hover) { .home-card-main:hover { background: #2f5fc4; } }
.home-card-kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.75; }
.home-card-title { font-size: 17px; font-weight: 700; }
.home-card-sub { font-size: 12.5px; opacity: 0.8; }
.gen-panel { background: #fff; border-radius: 12px; padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.gen-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.gen-title { font-weight: 700; font-size: 15px; }
.gen-sub { font-size: 12.5px; color: #6b7a8c; margin-top: 2px; }
.gen-start { width: auto; padding: 10px 18px; margin: 0; }
.gen-bar { height: 12px; background: #e6ecf5; border-radius: 6px; overflow: hidden; margin: 12px 0 8px; }
.gen-bar-fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width 0.4s ease; }
.gen-stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: #46566b; }
.gen-log { list-style: none; margin: 10px 0 0; padding: 8px 10px; background: #f4f7fb; border-radius: 8px; font: 12px/1.5 Consolas, monospace; color: #46566b; max-height: 150px; overflow-y: auto; }
.gen-result { margin-top: 10px; font-size: 13px; }
.gen-result.ok { color: #2e7d4f; }
.gen-result.bad { color: var(--error-color); }

/* --- Aktionsleiste (actions.js) ---
   Beschriftete Knoepfe statt Icon-Raetsel: Rueckgaengig/Hinweis nebeneinander,
   "Pruefen + Speichern" breit darunter, Ergebnis und gespeicherter Stand als
   Zeilen direkt darunter, Seltenes im "Mehr"-Menue. */
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  position: relative;
}
.act-btn {
  background: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #46566b;
}
@media (hover: hover) { .act-btn:hover { background: #f4f7fb; } }
.act-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.act-ico { font-size: 15px; line-height: 1; }
.act-span { grid-column: 1 / -1; }
.act-primary {
  grid-column: 1 / -1;
  background: var(--accent);
  color: #fff;
  padding: 12px 8px;
  font-size: 14px;
}
@media (hover: hover) { .act-primary:hover { background: #2f5fc0; } }
.act-primary:disabled { background: var(--accent); }
.act-status { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; }
.act-status:empty, .act-status:not(:has(:not([hidden]))) { display: none; }
.act-result {
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}
.act-result.ok { background: #e6f5ea; color: #1f6b37; }
.act-result.bad { background: #fdebe8; color: #a8321f; }
.act-result.note { background: #fff6dd; color: #7a5a00; }
.act-stand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #fff;
  border-radius: 8px;
  padding: 6px 6px 6px 12px;
  font-size: 12.5px;
  color: #46566b;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.act-result[hidden], .act-stand[hidden], .act-menu[hidden] { display: none; }
.act-link {
  background: #eef2f9;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
@media (hover: hover) { .act-link:hover { background: #dfe9f8; } }
.act-more { position: relative; }
.act-quiet { width: 100%; background: transparent; box-shadow: none; color: #7c8a9a; padding: 6px 8px; font-weight: 500; }
@media (hover: hover) { .act-quiet:hover { background: #eef2f9; } }
.act-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 35;
  min-width: 230px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(20,28,40,0.22), 0 2px 6px rgba(20,28,40,0.1);
  border: 1px solid #dbe4f0;
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.act-menu-item {
  background: none;
  border: none;
  border-radius: 7px;
  padding: 10px 12px;
  text-align: left;
  font-size: 13.5px;
  color: #1c2733;
  cursor: pointer;
}
@media (hover: hover) { .act-menu-item:hover { background: #eef2f9; } }
.act-counts { align-self: center; text-align: right; font-size: 12px; color: #7c8a9a; }
.act-counts b { color: #46566b; }

/* Handy: Aktionen als feste Leiste am unteren Rand (Daumen), Ergebnis/Stand
   als Blase darueber, Menue klappt nach oben. */
@media (max-width: 700px) {
  body { padding-bottom: 84px; }
  .actions {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    display: flex;
    gap: 0;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.14);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .actions > .act-btn, .act-more { flex: 1 1 0; min-width: 0; }
  .actions > .act-primary { flex: 2 1 0; }
  .actions .act-btn {
    flex-direction: column;
    gap: 2px;
    box-shadow: none;
    border-radius: 8px;
    background: transparent;
    padding: 6px 2px;
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
  }
  .actions .act-primary { background: var(--accent); margin: 0 4px; }
  .act-more .act-btn { width: 100%; height: 100%; }
  .act-counts { display: none; }
  .act-status { position: absolute; left: 8px; right: 8px; bottom: calc(100% + 8px); }
  .act-menu { top: auto; bottom: calc(100% + 8px); left: auto; right: 0; }
}

/* ======================================================================
   Handy-Bedienung. ALLES hier steht in Media-Queries (schmal bzw. Touch),
   damit die Desktop-Ansicht mit Maus unveraendert bleibt.
   ====================================================================== */

/* Touch: kein graues Aufblitzen beim Tippen, kein Doppeltipp-Zoom (Pinch bleibt). */
@media (pointer: coarse) {
  html { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  button { -webkit-touch-callout: none; }
}

/* Groessere Tippflaechen (Mindestmass ca. 40 px). */
@media (max-width: 700px), (pointer: coarse) {
  .app-nav-link { padding: 10px 16px; font-size: 14px; }
  .app-nav-panel-link { padding: 12px 14px; }
  .rules-btn { width: 36px; height: 36px; font-size: 16px; }
  .difficulty-selector { flex-wrap: wrap; }
  .diff-btn { padding: 10px 13px; font-size: 14px; min-height: 40px; }
  #pause-btn { width: 44px; height: 44px; font-size: 17px; }
  .tool-btn-sm { padding: 12px 2px; }
  .act-menu-item { padding: 14px 14px; font-size: 15px; }
  .act-link { padding: 10px 12px; }
  .hint-panel-apply, .hint-panel-close { padding: 12px 14px; font-size: 14px; }
  .overlay-card input[type="text"] { font-size: 16px; } /* verhindert Auto-Zoom auf iOS */
}

@media (max-width: 700px) {
  body { padding: 12px 12px 96px; }
  .app-nav { margin-bottom: 10px; }

  /* Spielseiten: Reihenfolge fuer den Daumen - Titel, Stufen, BRETT, Zifferblock/
     Werkzeuge, erst dann Hinweistexte und Statistik. (Hueellen zaehlen nicht als
     Boxen, ihre Kinder sortieren sich direkt in .app.) */
  .app:has(> .game-area) { display: flex; flex-direction: column; gap: 12px; }
  .app:has(> .game-area) > .app-header,
  .app:has(> .game-area) > .game-area,
  .app:has(> .game-area) .board-panel { display: contents; }
  .app:has(> .game-area) .header-title { order: 0; }
  .app:has(> .game-area) .difficulty-selector { order: 1; }
  .app:has(> .game-area) .board-panel > * { order: 2; }
  .app:has(> .game-area) .board-panel > .pz-zoom { order: 3; margin: -6px 0 0; }
  .app:has(> .game-area) .side-panel { order: 4; }
  .app:has(> .game-area) .level-note,
  .app:has(> .game-area) .difficulty-fallback-note,
  .app:has(> .game-area) .puzzle-info-note { order: 5; margin: 0; }
  .app:has(> .game-area) .board-panel > .global-stats { order: 6; }
  .app:has(> .game-area) .board-panel > .board { align-self: center; scroll-margin-top: 8px; }
  .app:has(> .game-area) .board-panel > .pz-board-host { scroll-margin-top: 8px; }

  .side-panel { gap: 10px; }
  .stats-row { padding: 6px 14px; }
  /* Fehler/Zeit unter die Eingabe (Zifferblock/Werkzeuge), damit diese direkt am
     Raetsel liegt. Nur mobil; alle Spiele teilen dieses .side-panel. */
  .side-panel > .stats-row { order: 99; }
  .notes-primary-btn { padding: 10px 14px; }
  .notes-primary-btn .tool-icon { font-size: 18px; }

  /* Zifferblock: eine Reihe (schmal und hoch) statt 3x3 - die Ziffern liegen so
     direkt unter dem Brett. Ausgeblendete Ziffern lassen keine Luecke. */
  .numpad { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 5px; }
  .num-btn { font-size: 22px; padding: 0; height: 54px; }
  .endgame-solver-btn { padding: 10px 12px; min-height: 40px; }

  /* Hinweis als Karte am unteren Rand (ueber der Aktionsleiste), das Brett bleibt
     oberhalb sichtbar (nav.js scrollt es beim Oeffnen nach oben). */
  .hint-panel {
    position: fixed;
    inset: auto 0 calc(68px + env(safe-area-inset-bottom)) 0;
    min-height: 0;
    padding: 0 8px;
    background: none;
    border-radius: 0;
    align-items: flex-end;
    z-index: 45;
  }
  .hint-panel-card { max-height: 42vh; overflow-y: auto; padding: 14px 16px; }
  .hint-panel-actions { flex-wrap: wrap; }

  .overlay-card { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 22px 20px; }

  /* Startseite: zwei Kacheln pro Zeile statt einer langen Liste. */
  .game-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .game-tile { padding: 12px; gap: 4px; }
  .game-tile-title { font-size: 15px; }
  .game-tile-stat { font-size: 12px; }
}

/* --- Konto-Dialog (nav.js) --- */
.app-nav-account { margin-left: auto; border: 0; cursor: pointer; font-family: inherit; }
.account-card { max-width: 360px; width: calc(100% - 32px); text-align: left; max-height: 90vh; overflow-y: auto; }
.account-card h3 { font-size: 15px; margin: 18px 0 4px; }
.account-field { display: block; font-size: 13px; font-weight: 600; color: #46566b; margin-top: 10px; }
.account-card input[type="text"],
.account-card input[type="email"],
.account-card input[type="password"] {
  display: block; width: 100%; box-sizing: border-box; padding: 10px 12px; margin: 4px 0 0;
  border: 1px solid #ccc; border-radius: 8px; font-size: 1rem; font-weight: 400;
}
.account-card .new-game-btn { width: 100%; margin-top: 12px; }
.account-card .new-game-btn.secondary { background: #e8edf5; color: #2c3a4e; }
.account-card .new-game-btn.danger { background: #c0392b; }
.account-link { background: none; border: 0; padding: 10px 0 0; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; display: block; }
.account-error { color: #b3261e; font-size: 13px; margin: 8px 0 0; }
.account-danger { margin-top: 16px; font-size: 13px; color: #46566b; }
.account-danger summary { cursor: pointer; }

/* --- Raetsel des Tages (dashboard.js) --- */
.daily-card-wrap { width: 100%; max-width: 980px; }
.daily-card {
  display: flex; flex-direction: column; gap: 4px; background: #fff; border-radius: 12px;
  border-left: 5px solid var(--accent); padding: 14px 16px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.daily-card .home-card-kicker { color: var(--accent); opacity: 1; }
.daily-card .home-card-sub { color: #46566b; }
.daily-top { margin: 4px 0 0 18px; padding: 0; font-size: 13px; color: #46566b; }
.daily-play { align-self: flex-start; margin-top: 8px; padding: 10px 22px; text-decoration: none; }
.daily-note { background: #fff7dc; color: #6b5100; }
.account-card [hidden] { display: none !important; }
.account-error.account-ok { color: #1e7a3c; }
