:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #d9dde3;
  --text: #1b1f24;
  --muted: #626b76;
  --accent: #2f6f4f;
  --accent-text: #ffffff;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --border: #2e343d;
    --text: #e7e9ec;
    --muted: #97a0ad;
    --accent: #4c9c73;
    --accent-text: #0d130f;
  }
}

* { box-sizing: border-box; }

/* Eigene display-Regeln (etwa .field oder .account) haben mehr Gewicht als die
   eingebaute Regel des Browsers fuer das hidden-Attribut. Ohne diese Zeile
   bleiben Elemente sichtbar, obwohl das Attribut gesetzt ist. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

main {
  max-width: 68rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
.lede { color: var(--muted); margin: 0 0 1.5rem; max-width: 44ch; }
.hint { color: var(--muted); font-size: .85rem; margin: .5rem 0 0; }

form, section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
legend { padding: 0; font-weight: 600; font-size: .9rem; margin-bottom: .5rem; }

.choices { display: flex; flex-wrap: wrap; gap: .5rem; }

.choice input { position: absolute; opacity: 0; pointer-events: none; }

.choice span {
  display: inline-block;
  padding: .4rem .8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: .9rem;
  user-select: none;
}

.choice input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.titlebar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: start;
            justify-content: space-between; margin-bottom: 1.5rem; }
.titlebar .lede { margin-bottom: 0; }

#install { border-color: var(--accent); color: var(--accent); font-weight: 600; flex: none; }

.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.actions { margin-top: 1rem; }

button {
  font: inherit;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .55; cursor: default; }

#generate {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.field { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); }

.field input {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .6rem;
  width: 9rem;
}

.check { display: flex; align-items: center; gap: .4rem; font-size: .9rem; padding-bottom: .5rem; }

.status { color: var(--muted); margin: 0 0 1rem; }

.map { width: 100%; }
.map svg { display: block; width: 100%; height: auto; }

details { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .75rem; }
summary { cursor: pointer; font-weight: 600; font-size: .9rem; }

pre {
  overflow-x: auto;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: .9rem;
  background: var(--bg);
  border-radius: var(--radius);
  padding: .75rem;
}

.stats p { margin: .25rem 0; font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }

/* --- Konten und Premium --------------------------------------------------- */

.headerbuttons { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; flex: none; }

.account { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .85rem; }

.badge {
  display: inline-block;
  padding: .1rem .45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: .75rem;
  color: var(--muted);
}

.badge.premium {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 1.25rem;
  max-width: 24rem;
  width: calc(100% - 2rem);
}

dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog h2 { font-size: 1.1rem; margin: 0 0 1rem; }
dialog .row { margin-top: 1rem; }

.field.wide { width: 100%; margin-bottom: .75rem; }
.field.wide input { width: 100%; }

.error { color: #d13438; font-size: .85rem; margin: .5rem 0 0; }
@media (prefers-color-scheme: dark) { .error { color: #ff8a8a; } }

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

#account-panel h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
#account-panel p { margin: 0; font-size: .9rem; color: var(--muted); }

button.danger { border-color: #d13438; color: #d13438; }
button.danger:hover:not(:disabled) { background: #d13438; color: #fff; }
@media (prefers-color-scheme: dark) {
  button.danger { border-color: #ff8a8a; color: #ff8a8a; }
  button.danger:hover:not(:disabled) { background: #ff8a8a; color: #14171c; }
}

#delete-account { border-color: var(--border); color: var(--muted); }
#delete-account:hover:not(:disabled) { border-color: #d13438; color: #d13438; }

/* --- Zweispaltiger Aufbau: Inhalt links, Konto und Premium schmal rechts --- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  gap: 1rem;
  align-items: start;
}

/* Auf schmalen Bildschirmen untereinander statt nebeneinander */
@media (max-width: 54rem) {
  .layout { grid-template-columns: 1fr; }
}

/* Kein Backend erreichbar: rechte Spalte faellt weg */
.layout.no-sidebar { grid-template-columns: 1fr; }
.layout.no-sidebar .sidebar { display: none; }

.content { min-width: 0; }

.sidebar section { padding: .85rem; margin-bottom: 1rem; }
.sidebar h2 { font-size: .95rem; margin: 0 0 .5rem; }
.sidebar p { font-size: .85rem; margin: .25rem 0; overflow-wrap: anywhere; }
.sidebar button { width: 100%; margin-top: .5rem; padding: .4rem .6rem; font-size: .9rem; }
/* Ein Verweis-Knopf steht mitten im Satz und soll sich wie ein Wort verhalten.
   Die Regel darueber wuerde ihn ueber die ganze Breite ziehen und damit den
   Absatz auseinanderreissen. display:inline laesst ihn mit dem Text umbrechen. */
.sidebar button.link {
  display: inline;
  width: auto;
  margin: 0;
  padding: 0;
  font-size: inherit;
}
.sidebar .field { font-size: .8rem; margin-bottom: 0; }
.sidebar .field input { width: 100%; }
.sidebar .error, .sidebar .hint { font-size: .8rem; }

#account-email { font-weight: 600; color: var(--text); }
.until { color: var(--muted); font-size: .8rem; }

#redeem-form { margin-top: .75rem; border-top: 1px solid var(--border); padding-top: .75rem; }

#buy { margin-top: .75rem; border-top: 1px solid var(--border); padding-top: .75rem; }
#buy h3 { font-size: .85rem; margin: 0 0 .25rem; }
#buy .buy { text-align: left; line-height: 1.3; }
#cancel-subscription { border-color: var(--border); color: var(--muted); }
#redeem-code { font-family: ui-monospace, Consolas, monospace; letter-spacing: .05em; }

/* --- Karteneditor ---------------------------------------------------------- */

#editor h2 { font-size: 1.1rem; margin: 0 0 .25rem; }
#editor h2 .badge { vertical-align: middle; margin-left: .35rem; }
#editor .row { margin-top: .75rem; }
#editor select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .6rem;
}
#editor-width { width: 6rem; }
#editor-height { width: 6rem; }
#editor-board { margin-top: 1rem; }
/* Der Werbeclip fuellt den Platz, an dem gleich die Karte steht. */
#ad video { width: 100%; max-width: 640px; display: block; border-radius: 8px;
            background: #000; }
#ad .hint { margin: 0 0 0.4rem; }

/* touch-action: none - sonst deutet der Browser das Ziehen ueber die Karte als
   Wischen und scrollt die Seite, statt einen Fluss zu malen. */
#editor-canvas { width: 100%; touch-action: none; }
#editor-canvas .cell { cursor: pointer; }
#editor-canvas .cell:hover { stroke: var(--accent); stroke-width: 3; }

.buildstamp { color: var(--muted); font-size: .75rem; margin-top: 2rem; text-align: right; }

/* --- Pflichtseiten (Impressum, Datenschutz, AGB, Widerruf) --------------- */
.legal { max-width: 46rem; }
.legal .back { margin: 0 0 1rem; }
.legal h2 { font-size: 1.1rem; margin: 1.75rem 0 .5rem; }
.legal h3 { font-size: 1rem; margin: 1.25rem 0 .35rem; }
.legal p, .legal li { max-width: 70ch; }
.legal blockquote {
  margin: 1rem 0;
  padding: .75rem 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

/* Muss auf jeder Seite zu finden sein - deshalb dieselbe Zeile ueberall. */
.sitefooter {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: .85rem;
}

#pricing .prices { padding-left: 1.1rem; margin: .5rem 0; }
/* Hinweis ueber den Preisen: auffaellig, aber keine Behauptung ueber einen
   frueheren Preis - ein durchgestrichener Wunschpreis waere irrefuehrend. */
#pricing .launch { color: var(--accent); font-weight: 700; margin: .75rem 0 0; }
#pricing .prices li { margin-bottom: .4rem; }
#pricing-signup { margin-top: .75rem; }

/* Die Zahl der Paesse ist die Information, auf die es im Kontobereich ankommt. */
#pass-count { font-weight: 700; }

/* Die genauen Wahrscheinlichkeiten des gewaehlten Feldes. */
#probs-values { font-size: .85rem; margin: .5rem 0 0; }

/* Rueckfrage vor einem Kauf: kein Fehler, aber auch kein beilaeufiger Hinweis. */
.warn { color: #9a6700; font-size: .85rem; }
@media (prefers-color-scheme: dark) { .warn { color: #e2b341; } }
#pricing-signup p { margin: 0 0 .4rem; }

/* Die Erklaerung zur sofortigen Ausfuehrung steht ueber den Kaufknoepfen und
   braucht dort mehr Luft als ein gewoehnliches Kaestchen. */
.check.consent { align-items: flex-start; margin: .5rem 0 .4rem; font-size: .85rem; }
.check.consent input { margin-top: .2rem; }

/* Erklaerung und Knopf gehoeren zusammen - eine Trennlinie macht sichtbar, dass
   das Kaestchen darueber zu genau diesem Kauf gehoert und nicht zum anderen. */
.offer { padding-top: .6rem; border-top: 1px solid var(--border); }
.offer:first-of-type { border-top: 0; padding-top: 0; }
