:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --ink: #23201c;
  --muted: #6f675c;
  --line: #e2d9c8;
  --accent: #9b2c1f;
  --accent-ink: #fff;
  --header: #1f2a35;
  --header-ink: #f3ead8;
  --select: #1f2a35;
  --select-ink: #f3ead8;
  --dm-bg: #fbf3e3;
  --dm-line: #e6d3ad;
  --holz: #1f9d4d;
  --feuer: #d6362b;
  --erde: #c4740a;
  --metall: #6b7280;
  --wasser: #1593d2;
  /* dunklere Töne derselben Farben für kleine Schrift (Kontrast mindestens 4,5 : 1) */
  --holz-text: #15753a;
  --feuer-text: #c22d23;
  --erde-text: #9c5a00;
  --metall-text: #5a6170;
  --wasser-text: #0b6ea3;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c;
    --surface: #1e2329;
    --ink: #ece6da;
    --muted: #a39b8d;
    --line: #343b44;
    --accent: #d9624f;
    --accent-ink: #1a1210;
    --header: #101317;
    --select: #d5dbe2;
    --select-ink: #15181c;
    --dm-bg: #3a3222;
    --dm-line: #7a6638;
    --holz: #3fc46f;
    --feuer: #f0624f;
    --erde: #f0a035;
    --metall: #a3acb9;
    --wasser: #45b8f2;
    --holz-text: #3fc46f;
    --feuer-text: #f0624f;
    --erde-text: #f0a035;
    --metall-text: #a3acb9;
    --wasser-text: #45b8f2;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/* Hintergrundbild: feststehend hinter der ganzen Seite, oben und unten abgedunkelt.
   Als eigenes fixiertes Element, weil background-attachment: fixed auf iOS nicht zuverlässig ist. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background-color: #3d4a44;
  background-image: linear-gradient(rgba(16, 24, 30, .72), rgba(16, 24, 30, .18) 38%, rgba(16, 24, 30, .5)), url(../img/bg-1920.jpg);
  background-image: linear-gradient(rgba(16, 24, 30, .72), rgba(16, 24, 30, .18) 38%, rgba(16, 24, 30, .5)),
    image-set(url(../img/bg-1920.webp) type("image/webp"), url(../img/bg-1920.jpg) type("image/jpeg"));
  background-size: cover; background-position: center;
}
@media (max-width: 700px) {
  body::before {
    background-image: linear-gradient(rgba(16, 24, 30, .72), rgba(16, 24, 30, .18) 38%, rgba(16, 24, 30, .5)), url(../img/bg-960.jpg);
    background-image: linear-gradient(rgba(16, 24, 30, .72), rgba(16, 24, 30, .18) 38%, rgba(16, 24, 30, .5)),
      image-set(url(../img/bg-960.webp) type("image/webp"), url(../img/bg-960.jpg) type("image/jpeg"));
  }
}
@media (prefers-color-scheme: dark) {
  body::before { filter: brightness(.6); }
}
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 16px; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; margin: 0; }

.site-header { color: #fff; padding: 36px 0 12px; text-shadow: 0 1px 12px rgba(0, 0, 0, .55); }
.site-header h1 { font-size: clamp(2rem, 5vw, 3rem); }
.eyebrow { margin: 0 0 6px; letter-spacing: .12em; text-transform: uppercase; font-size: .78rem; opacity: .9; }
.lead { margin: 10px 0 0; max-width: 60ch; opacity: .95; }

.layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 24px; align-items: start; padding-top: 24px; padding-bottom: 24px; }
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: 0 10px 30px rgba(0, 0, 0, .22); }
.card h2 { font-size: 1.25rem; margin-bottom: 14px; }
.result { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; min-width: 0; }
.placeholder { text-align: center; color: var(--muted); padding: 56px 22px; }
.placeholder .big { font-size: 4rem; margin: 0 0 8px; color: var(--line); font-family: serif; }

/* Formular */
.field { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.field > label, .field > legend { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; padding: 0; }
.hint { font-weight: 400; color: var(--muted); }
.field-hint { margin: 6px 0 0; font-size: .78rem; line-height: 1.4; color: var(--muted); }
input[type="text"], input[type="number"], select {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
input:focus-visible, select:focus-visible, .btn:focus-visible, .segmented input:focus-visible + span {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input:disabled { opacity: .45; }
.row { display: flex; gap: 8px; align-items: center; }
.date-row input, .time-row input[type="text"] { text-align: center; }
.date-row input:nth-child(-n+2), .time-row input[type="text"] { flex: 0 0 62px; }
.sep { font-weight: 700; }
.check { display: flex; align-items: center; gap: 6px; font-size: .88rem; white-space: nowrap; }
.time-unknown { margin-top: 8px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; text-align: center; padding: 9px; cursor: pointer; background: var(--bg); }
.segmented input:checked + span { background: var(--select); color: var(--select-ink); }

.place-box { position: relative; }
.place-list {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px; list-style: none; max-height: 300px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.place-list li { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; }
.place-list li:hover { background: var(--bg); }
.place-list li.online { color: var(--select); font-weight: 600; }
.place-list li.msg { cursor: default; color: var(--muted); font-size: .9rem; }
.place-list li.msg:hover { background: none; }
.pl-sub { font-size: .8rem; color: var(--muted); }
.place-info { margin: 6px 0 0; font-size: .82rem; color: var(--muted); min-height: 1.2em; }
.manual { margin-top: 4px; font-size: .85rem; }
.manual summary { cursor: pointer; color: var(--muted); }
.manual-row { align-items: flex-end; margin-top: 8px; }
.manual-row label { flex: 1; min-width: 0; font-size: .8rem; color: var(--muted); }
.manual-row input, .manual-row select { margin-top: 4px; }

.btn {
  width: 100%; padding: 13px; font: inherit; font-weight: 700; cursor: pointer;
  color: var(--accent-ink); background: var(--accent); border: 0; border-radius: 8px;
}
.btn:hover { filter: brightness(1.08); }
.error { color: var(--feuer); font-size: .9rem; margin: 0 0 12px; }

/* Elementfarben */
.el-holz { color: var(--holz); --el-text: var(--holz-text); }
.el-feuer { color: var(--feuer); --el-text: var(--feuer-text); }
.el-erde { color: var(--erde); --el-text: var(--erde-text); }
.el-metall { color: var(--metall); --el-text: var(--metall-text); }
.el-wasser { color: var(--wasser); --el-text: var(--wasser-text); }
/* Kleine farbige Schrift nimmt den dunkleren Textton, große Zeichen behalten die kräftige Farbe */
.glyph .py, .hs-main, .nayin-hz, .dm-line strong { color: var(--el-text); }
.bg-holz { background: var(--holz); } .bg-feuer { background: var(--feuer); } .bg-erde { background: var(--erde); }
.bg-metall { background: var(--metall); } .bg-wasser { background: var(--wasser); }

/* Vier Säulen */
.table-scroll { overflow-x: auto; }
.pillars { width: 100%; min-width: 560px; border-collapse: separate; border-spacing: 6px 0; table-layout: fixed; }
.pillars th, .pillars td { text-align: center; padding: 10px 6px; vertical-align: top; }
.pillars thead th { font-family: Georgia, serif; font-size: 1rem; }
.pillars .rowhead { width: 122px; padding-right: 14px; text-align: left; font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); vertical-align: middle; }
.pillars td, .pillars thead th:not(.rowhead) { background: var(--bg); border-bottom: 1px solid var(--line); }
.pillars thead th:not(.rowhead) { border-radius: 10px 10px 0 0; }
.pillars tbody tr:last-child td { border-radius: 0 0 10px 10px; border-bottom: 0; }
/* Tagessäule: warme Fläche statt farbigem Rahmen, damit sie nicht wie eine Elementfarbe wirkt */
.pillars td.dm, .pillars thead th.dm { background: var(--dm-bg); border-bottom-color: var(--dm-line); box-shadow: inset 1px 0 var(--dm-line), inset -1px 0 var(--dm-line); }
.pillars thead th.dm { box-shadow: inset 1px 0 var(--dm-line), inset -1px 0 var(--dm-line), inset 0 1px var(--dm-line); }
.pillars tbody tr:last-child td.dm { box-shadow: inset 1px 0 var(--dm-line), inset -1px 0 var(--dm-line), inset 0 -1px var(--dm-line); }

.pillar-legend { display: none; }
/* Weiche Trennstellen in den Na-Yin-Namen nur in den schmalen Handy-Spalten nutzen */
.pillars td { hyphens: none; }
/* Handy: Beschriftungsspalte ausblenden, damit alle vier Säulen nebeneinander passen */
@media (max-width: 640px) {
  .card { padding: 16px 14px; }
  .pillars { min-width: 0; border-spacing: 4px 0; }
  .pillars .rowhead { display: none; }
  .pillars th, .pillars td { padding: 8px 2px; hyphens: manual; overflow-wrap: anywhere; }
  .pillars thead th { font-size: .86rem; }
  .pillars .god { font-size: .72rem; }
  .pillars .glyph.big .hz { font-size: 2.4rem; }
  .pillars .sub, .hs-text { font-size: .68rem; }
  .pillar-legend { display: block; margin: 10px 0 0; font-size: .74rem; color: var(--muted); }
}

.glyph { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.glyph .hz { font-size: 1.7rem; font-family: "Noto Serif SC", "Songti SC", SimSun, serif; }
.glyph.big .hz { font-size: 2.8rem; }
.glyph .py { font-size: .78rem; font-weight: 600; }
.sub { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.god { font-size: .82rem; font-weight: 600; }
.god-hz { font-size: .78rem; color: var(--muted); }
.none { color: var(--muted); }
.hidden-stem { margin: 0 0 7px; line-height: 1.25; }
.hidden-stem:last-child { margin-bottom: 0; }
.hs-main { display: flex; gap: 5px; align-items: baseline; justify-content: center; }
.hs-main .hz { font-size: 1.05rem; }
.hs-main .py { font-size: .76rem; font-weight: 600; }
.hs-text { font-size: .74rem; color: var(--muted); }
.nayin-hz { font-size: 1rem; }
.dm-line { margin: 16px 0 0; }

/* Lebensphasen */
.note { color: var(--muted); font-size: .88rem; margin: 0 0 14px; }
/* 11 Phasen: 6 oben, 5 darunter; auf schmalen Bildschirmen 3 pro Zeile */
.luck { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px 8px; padding-top: 4px; }
@media (max-width: 640px) { .luck { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.luck-item { position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 6px 10px; text-align: center; }
.luck-item.current { background: var(--dm-bg); border-color: var(--dm-line); }
.luck-age { font-weight: 700; font-size: .9rem; }
.luck-years { font-size: .74rem; color: var(--muted); }
.luck-item .god { font-size: .7rem; line-height: 1.25; height: 2.5em; display: flex; align-items: center; justify-content: center; }
/* Trennlinien wie zwischen den Zeilen der Vier-Säulen-Tabelle, über die ganze Kartenbreite */
.luck-sep { border-top: 1px solid var(--line); margin: 8px -6px; }
.luck-item.current .luck-sep { border-top-color: var(--dm-line); }
/* Luft zwischen Stamm, Zweig und Tiername */
.luck-item .glyph { gap: 2px; }
.luck-item .sub { margin-top: 2px; font-size: .72rem; }
/* Schild sitzt auf der Oberkante, damit alle Karten einer Reihe gleich hoch bleiben */
.badge { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); padding: 0 8px; border-radius: 99px; background: var(--select); color: var(--select-ink); font-size: .66rem; font-weight: 700; line-height: 1.5; white-space: nowrap; }

/* Elementverteilung */
.bars { display: grid; gap: 8px; margin-bottom: 12px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 24px; gap: 10px; align-items: center; font-size: .9rem; }
.bar-track { height: 12px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; }
.bar-num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Hinweis */
.warning { border-left: 3px solid var(--erde); background: var(--bg); padding: 10px 12px; border-radius: 0 8px 8px 0; margin: 0 0 12px; font-size: .9rem; }
.facts { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; margin: 0 0 12px; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
@media (max-width: 520px) { .facts { grid-template-columns: 1fr; } .facts dd { margin-bottom: 6px; } }

.site-footer { font-size: .82rem; padding-bottom: 32px; }
/* Fußbereich als helle Karte wie der Rest der Seite */
.footer-panel { background: var(--surface); color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; box-shadow: 0 10px 30px rgba(0, 0, 0, .22); }
.site-footer p { margin: 0 0 6px; }
.site-footer a { color: inherit; }
.privacy { margin: 10px 0; }
.privacy summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.privacy h3 { font-size: .85rem; margin: 12px 0 2px; color: var(--ink); }
.privacy-body { columns: 2 320px; column-gap: 32px; margin-top: 6px; }
.privacy-body section { break-inside: avoid; padding-bottom: 10px; }
.privacy-body h3 { margin-top: 0; }
.legal-links { margin-top: 12px; }

/* Aktionen über dem Chart */
.actions { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 14px 22px; }
.actions .check { margin-left: 0; }
.btn-secondary {
  padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.btn-secondary:hover { border-color: var(--select); }
.btn-secondary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.action-status { font-size: .85rem; color: var(--muted); flex-basis: 100%; min-height: 0; }
.action-status:empty { display: none; }
.manual-copy { flex-basis: 100%; width: 100%; height: 180px; padding: 10px; font: .8rem/1.4 ui-monospace, Consolas, monospace; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.print-only { display: none; }

/* Druckansicht: nur das Chart, hell, ohne Hintergrundbild */
@media print {
  @page { margin: 14mm; }
  :root {
    --bg: #f4f1ea; --surface: #fff; --ink: #1c1a17; --muted: #5a544b; --line: #cfc7b8;
    --accent: #9b2c1f; --accent-ink: #fff; --select: #1f2a35; --select-ink: #f3ead8; --dm-bg: #fbf3e3; --dm-line: #e6d3ad;
    --holz: #1f9d4d; --feuer: #d6362b; --erde: #c4740a; --metall: #6b7280; --wasser: #1593d2;
    --holz-text: #15753a; --feuer-text: #c22d23; --erde-text: #9c5a00; --metall-text: #5a6170; --wasser-text: #0b6ea3;
  }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; font-size: 11pt; }
  body::before, .form, .site-footer, .actions, .lead, .placeholder { display: none; }
  .wrap { max-width: none; padding: 0; }
  .site-header { color: var(--ink); text-shadow: none; padding: 0 0 4px; }
  .site-header h1 { font-size: 20pt; }
  .layout { display: block; padding: 0; }
  .result { gap: 10px; }
  .print-only { display: block; }
  .screen-only { display: none; }
  .print-footer { order: 5; margin: 2px 0 0; font-size: 9pt; color: var(--muted); text-align: right; }
  .print-summary { margin: 0 0 4px; font-weight: 600; }
  .card { box-shadow: none; border: 1px solid var(--line); padding: 12px 14px; break-inside: avoid; }
  .card h2 { font-size: 13pt; margin-bottom: 8px; }
  .table-scroll { overflow: visible; }
  .pillars { min-width: 0; }
  .pillars th, .pillars td { padding: 6px 4px; }
  .glyph.big .hz { font-size: 2.1rem; }
  .luck { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .luck-item { padding: 6px 4px; break-inside: avoid; }
  .luck-sep { margin: 4px -4px; }
  .luck-item .sub { margin-top: 0; }
  /* Reihenfolge im Ausdruck: Säulen und Elemente auf Seite 1, Lebensphasen und Hinweis auf Seite 2 */
  .card-pillars { order: 1; } .card-elements { order: 2; } .card-luck { order: 3; } .card-notes { order: 4; }
  .card-notes .note, .card-elements .note { display: none; }
  .bars { margin-bottom: 0; }
  .facts { margin-bottom: 0; }
}
