:root {
  --ink: #2b2118;
  --ink-soft: #5a4a3a;
  --parch: #f4ead3;
  --parch-dark: #e6d6b3;
  --edge: #b89b6a;
  --wax: #8e2a1e;
  --gold: #b8892f;
  --night: #1d1814;
  --elf: #bfe3ff;
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { background: var(--night); }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  background:
    radial-gradient(ellipse at top, #3a2e22 0%, var(--night) 60%) fixed;
  min-height: 100vh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.page { max-width: 640px; margin: 0 auto; padding: 12px 12px 40px; }
.loading { color: var(--parch); text-align: center; margin-top: 30vh; font-style: italic; }

.hero { text-align: center; color: var(--parch); padding: 28px 8px 12px; }
.hero h1 { font-size: 2.1rem; margin: 6px 0 0; letter-spacing: .04em; font-variant: small-caps; color: #f1dca6; text-shadow: 0 0 18px rgba(241, 220, 166, .25); }
.hero .sub { margin: 2px 0 0; font-style: italic; color: #cbb991; }
.hero-runes { color: var(--gold); letter-spacing: .3em; font-size: .9rem; }

.banner { background: #c9a227; color: var(--night); text-align: center; padding: 6px 10px; border-radius: 6px; margin: 8px 0; font-size: .9rem; }

.card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .25), rgba(0, 0, 0, .03)),
    var(--parch);
  border: 1px solid var(--edge);
  border-radius: 4px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .45), inset 0 0 40px rgba(150, 110, 50, .18);
  padding: 18px 18px 16px;
  margin: 16px 0;
  position: relative;
}
.card h2 { margin: 4px 0 10px; font-variant: small-caps; letter-spacing: .03em; font-size: 1.4rem; }
details.card > summary, details.more > summary {
  cursor: pointer; font-variant: small-caps; font-size: 1.15rem; letter-spacing: .03em; list-style: none;
}
details > summary::-webkit-details-marker { display: none; }
details.card > summary::before, details.more > summary::before { content: "❧ "; color: var(--wax); }
details[open] > summary { margin-bottom: 8px; }
details.more { margin: 6px 0 10px; color: var(--ink-soft); }
details.more > summary { font-size: 1rem; }

.prose p { margin: 0 0 .8em; }
.letter-text { font-style: italic; }
.arrival { font-style: italic; color: var(--ink-soft); }
.help { font-size: .95rem; background: rgba(184, 137, 47, .12); border-left: 3px solid var(--gold); padding: 8px 10px 1px; margin: 12px 0; }
.muted { color: var(--ink-soft); font-size: .95rem; }
.error { color: var(--wax); font-weight: bold; }

.st-head { display: flex; justify-content: space-between; align-items: baseline; font-size: .85rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-soft); border-bottom: 1px solid var(--edge); padding-bottom: 4px; }
.st-label { color: var(--wax); }

.st-locked_date, .st-locked_prev { opacity: .82; }
.locked { display: flex; gap: 14px; align-items: center; margin-top: 10px; }
.locked p { margin: 0; }

.seal {
  flex: 0 0 auto;
  width: 52px; height: 52px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: bold; color: #f3d7c9;
  background: radial-gradient(circle at 35% 30%, #b5463a, var(--wax) 55%, #5e170f);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .4), inset 0 0 0 3px rgba(0, 0, 0, .15);
}
.seal.lock { font-size: 1.2rem; filter: grayscale(.4); }
.seal.empty { background: transparent; color: var(--edge); box-shadow: inset 0 0 0 2px var(--edge); }
.fragments { display: flex; gap: 10px; justify-content: center; margin: 14px 0; }

.solved { display: flex; gap: 14px; align-items: center; }
.solved p { margin: 0 0 4px; }

.btn {
  font-family: var(--serif); font-size: 1rem;
  background: var(--ink); color: var(--parch);
  border: 1px solid var(--ink); border-radius: 3px;
  padding: 10px 16px; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.danger { background: var(--wax); border-color: var(--wax); }
.hint-wrap { margin: 6px 0 4px; }
.hint { background: rgba(142, 42, 30, .08); border-left: 3px solid var(--wax); padding: 8px 10px; margin: 8px 0; }

/* Phiole */
.phial-box { text-align: center; margin-top: 16px; padding: 16px 10px 6px; background: var(--night); color: var(--parch); border-radius: 4px; }
.phial-box .muted { color: #cbb991; }
.phial-box .btn { background: var(--parch); color: var(--ink); }
.phial-box .btn.ghost { background: transparent; color: var(--parch); border-color: var(--parch); }
.phial {
  --glow: 0;
  width: 46px; height: 74px; margin: 6px auto 12px; position: relative;
  border-radius: 40% 40% 46% 46% / 30% 30% 70% 70%;
  background: radial-gradient(circle at 50% 62%, rgba(255, 255, 255, calc(.25 + var(--glow) * .75)), rgba(191, 227, 255, calc(.15 + var(--glow) * .8)) 45%, rgba(80, 120, 160, .35) 75%);
  box-shadow:
    0 0 calc(4px + var(--glow) * 60px) calc(var(--glow) * 22px) rgba(191, 227, 255, calc(var(--glow) * .85)),
    inset 0 0 8px rgba(255, 255, 255, .4);
  transition: box-shadow 1.2s ease, background 1.2s ease;
  animation: flicker 3s ease-in-out infinite;
}
.phial::before { content: ""; position: absolute; top: -12px; left: 50%; width: 14px; height: 14px; transform: translateX(-50%); background: #8a7a62; border-radius: 3px 3px 0 0; }
@keyframes flicker { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.12); } }
.glow-text { font-style: italic; font-size: 1.05rem; color: var(--elf); }

/* Chiffren */
.cipher { background: var(--parch-dark); border: 1px dashed var(--edge); border-radius: 3px; padding: 14px 12px; margin: 12px 0; text-align: center; }
.mono { font-family: "Courier New", ui-monospace, monospace; font-size: 1.25rem; letter-spacing: .12em; word-spacing: .3em; font-weight: bold; }
.mirror { display: inline-block; transform: scaleX(-1); font-size: 1.35rem; font-weight: bold; letter-spacing: .05em; }
.runes-line { display: flex; flex-wrap: wrap; gap: 10px 22px; justify-content: center; }
.rune-word { display: inline-flex; gap: 6px; align-items: flex-end; }
.rune { height: 34px; width: auto; stroke: var(--ink); stroke-width: .9; stroke-linecap: round; fill: none; }
.rune-char { font-size: 1.4rem; font-weight: bold; line-height: 34px; }
.rune-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; margin-top: 8px; }
.rune-cell { display: flex; flex-direction: column; align-items: center; background: var(--parch-dark); border-radius: 3px; padding: 6px 0 2px; }
.rune-cell .rune { height: 28px; }
.rune-cell span { font-weight: bold; font-size: .95rem; }

/* Antworten */
.answer { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.answer input { flex: 1 1 160px; font-family: var(--serif); font-size: 1.1rem; padding: 10px; border: 1px solid var(--edge); border-radius: 3px; background: #fffaf0; text-transform: uppercase; letter-spacing: .08em; }
.answer-msg { flex-basis: 100%; margin: 4px 0 0; font-style: italic; min-height: 1.3em; color: var(--wax); }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.reward { font-size: 1.05rem; }

.foot { text-align: center; color: #9d8b6c; font-size: .85rem; font-style: italic; margin-top: 24px; }

/* Admin */
.admin .card { font-size: 15px; }
.admin h2 { font-size: 1.2rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.admin label { display: block; font-size: .85rem; color: var(--ink-soft); }
.admin input[type=number], .admin input[type=text] { width: 100%; font-size: 1rem; padding: 8px; border: 1px solid var(--edge); border-radius: 3px; background: #fffaf0; font-family: inherit; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.kv { font-size: .9rem; margin: 2px 0; }
.attempts { font-size: .85rem; margin: 4px 0 0; padding-left: 18px; }
.ok { color: #2f6b2f; } .bad { color: var(--wax); }
.status-pill { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--ink); color: var(--parch); font-size: .8rem; }
.linkbox { word-break: break-all; font-family: ui-monospace, monospace; font-size: .85rem; background: var(--parch-dark); padding: 8px; border-radius: 3px; }

/* Kalender */
.cal .doors { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; margin-top: 12px; }
.door {
  position: relative; aspect-ratio: 1 / 1.05; border-radius: 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  font-family: var(--serif); color: var(--ink);
  background: linear-gradient(160deg, #fbf3df, var(--parch-dark));
  border: 1px solid var(--edge); box-shadow: 0 2px 4px rgba(0, 0, 0, .18);
  padding: 4px 2px;
}
.door-wd { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); }
.door-day { font-size: 1.45rem; font-weight: bold; line-height: 1.1; }
.door-kind { font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; color: var(--wax); min-height: .9em; }
.door.k-gps { border: 2px solid var(--wax); }
.door.s-locked { opacity: .5; background: var(--parch-dark); box-shadow: none; }
.door.s-open, .door.s-ready { box-shadow: 0 0 0 2px rgba(184, 137, 47, .55), 0 2px 6px rgba(0, 0, 0, .25); }
.door.s-solved { background: #e9dcc0; }
.door.s-solved .door-day { color: var(--ink-soft); }
.door.k-home.s-solved .door-kind { color: var(--ink); font-size: .85rem; font-weight: bold; }
.door-frag { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; font-size: .8rem; font-weight: bold;
  display: flex; align-items: center; justify-content: center; color: #f3d7c9;
  background: radial-gradient(circle at 35% 30%, #b5463a, var(--wax) 60%, #5e170f); }
.door.today::after { content: "heute"; position: absolute; bottom: -9px; left: 50%; transform: translateX(-50%);
  font-size: .58rem; background: var(--gold); color: var(--night); padding: 0 5px; border-radius: 6px; letter-spacing: .05em; }
.door.sel { outline: 3px solid var(--ink); outline-offset: 2px; }
.door:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Fortschritt */
.slots { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0 10px; }
.slot { width: 28px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px dashed var(--edge); border-radius: 3px; font-weight: bold; color: var(--edge); font-size: 1.05rem; }
.slot.got { border: 1px solid var(--ink); color: var(--ink); background: #fffaf0; }
.digits .slot.got { background: radial-gradient(circle at 35% 30%, #b5463a, var(--wax) 60%, #5e170f); color: #f3d7c9; border-color: var(--wax); border-radius: 50%; }
.small { font-size: .82rem; margin: 6px 0 0; }

/* weitere Chiffren und Hilfsmittel */
.cipher.plain { text-align: left; font-style: italic; }
.morse { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; font-size: 1.35rem; letter-spacing: .18em; }
.morse-word { white-space: nowrap; }
.morse-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; }
.morse-cell { background: var(--parch-dark); border-radius: 3px; padding: 4px 6px; display: flex; justify-content: space-between; font-family: "Courier New", monospace; }
.polybius { border-collapse: collapse; margin: 6px auto; font-size: 1.05rem; }
.polybius th, .polybius td { border: 1px solid var(--edge); width: 42px; height: 34px; text-align: center; }
.polybius th { background: var(--parch-dark); color: var(--wax); }
.tools details.more { color: var(--ink); }
.k-gps .st-label { font-weight: bold; }

/* Admin-Liste */
.admin-day { border-top: 1px solid var(--edge); padding: 8px 0; }
.admin-day > summary { cursor: pointer; list-style: none; font-size: 1rem; }
.admin-day > summary::-webkit-details-marker { display: none; }
.ad-date { display: inline-block; min-width: 72px; font-weight: bold; color: var(--ink-soft); }
.ad-tag { display: inline-block; margin-left: 8px; font-size: .72rem; padding: 0 7px; border-radius: 9px; border: 1px solid var(--wax); color: var(--wax); }
.ad-tag.missing { background: var(--wax); color: #fff; }
.ad-tag.done { border-color: #2f6b2f; color: #2f6b2f; }
.card.warn { border-color: var(--wax); }
.loc h3 { margin: 10px 0 4px; font-size: 1rem; }
