/* Mobile-first: gespielt wird am Handy. */
:root {
  --bg: #2b2622;
  --paper: #f3ead8;
  --ink: #2a2118;
  --accent: #8b2e1f;
  --ok: #2f6b3a;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}

/* Kopfleiste mit Menü */
:root { --bar-h: 52px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: .75rem;
  height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(.25rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
  background: #1c1916;
  color: var(--paper);
}
.topbar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-family: "Courier New", monospace;
  font-weight: bold;
  letter-spacing: .03em;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.topbar-progress { font-size: .8rem; opacity: .75; white-space: nowrap; }
.menu summary {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  font-size: 1.5rem;
  list-style: none;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: rgb(255 255 255 / .12); }
/* Abdunklung hinter dem offenen Menü; Tippen darauf schließt es (gehört zum summary) */
.menu[open] summary::before {
  content: "";
  position: fixed;
  inset: calc(var(--bar-h) + env(safe-area-inset-top)) 0 0 0;
  background: rgb(0 0 0 / .45);
  cursor: default;
}
.menu-panel {
  position: fixed;
  top: calc(var(--bar-h) + env(safe-area-inset-top));
  left: 0;
  right: 0;
  max-height: calc(100dvh - var(--bar-h) - env(safe-area-inset-top));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: .25rem 0 calc(.5rem + env(safe-area-inset-bottom));
  background: #1c1916;
  border-top: 1px solid #3a332c;
  box-shadow: 0 12px 24px rgb(0 0 0 / .5);
}
.menu-panel a, .menu-panel .locked {
  display: flex;
  align-items: center;
  gap: .85rem;
  min-height: 54px;
  padding: 0 max(1.25rem, env(safe-area-inset-right)) 0 max(1.25rem, env(safe-area-inset-left));
  color: var(--paper);
  text-decoration: none;
  border-bottom: 1px solid #2a2520;
}
.menu-panel a:active { background: rgb(255 255 255 / .1); }
.menu-panel a.active { background: rgb(255 255 255 / .07); box-shadow: inset 4px 0 0 var(--accent); }
.menu-panel .ico { width: 2rem; text-align: center; flex: 0 0 auto; }
.menu-panel .num {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  font-size: .9rem;
  border: 1px solid #6b5d48;
  border-radius: 50%;
}
.menu-panel .done .num { background: var(--ok); border-color: var(--ok); color: #fff; }
.menu-panel .label { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.menu-panel .tag {
  padding: .1rem .5rem;
  font-size: .75rem;
  background: var(--accent);
  border-radius: 999px;
}
.menu-panel .locked { opacity: .45; }
.menu-sep {
  padding: 1rem 1.25rem .35rem;
  font-size: .75rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .6;
}
.menu-panel .logout { margin-top: .5rem; color: #e0a898; border-bottom: 0; }
@media (min-width: 640px) {
  .menu-panel { left: auto; right: .5rem; width: 24rem; border-radius: 0 0 8px 8px; }
}

main {
  padding: .75rem .75rem calc(1.5rem + env(safe-area-inset-bottom));
}
.card {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.25rem 1rem;
  background: var(--paper);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgb(0 0 0 / .4);
  overflow-wrap: anywhere;
}
.card.narrow { max-width: 24rem; margin-top: 12vh; }
.file { border-left: 5px solid var(--accent); }
.body img, .body video { max-width: 100%; height: auto; }
h1 {
  margin-top: 0;
  font-family: "Courier New", monospace;
  font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: .03em;
}
.audio { margin: 1rem 0; }
.audio audio { width: 100%; }

label { display: block; font-weight: bold; margin-bottom: .35rem; }
input {
  width: 100%;
  min-height: 48px;
  padding: .7rem;
  font-size: 1rem; /* >=16px verhindert Auto-Zoom auf iOS */
  font-family: inherit;
  border: 1px solid #a89a80;
  border-radius: 4px;
  background: #fffaf0;
  color: var(--ink);
}
input:focus { outline: 3px solid rgb(139 46 31 / .35); border-color: var(--accent); }

button, .button {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 1rem;
  padding: .75rem 1rem;
  font-size: 1.05rem;
  font-family: inherit;
  text-align: center;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
button:active, .button:active { filter: brightness(.85); }

.msg { font-weight: bold; margin: .75rem 0 0; }
.msg.wrong { color: var(--accent); }
.msg.correct { color: var(--ok); }

/* Steckbrief */
.profile {
  margin: 1.5rem 0;
  padding: 1rem;
  background: #fffaf0;
  border: 2px solid var(--ink);
  border-radius: 2px;
  transform: rotate(-.6deg);
  box-shadow: 2px 3px 0 rgb(0 0 0 / .25);
}
.profile h2 {
  margin: 0 0 .75rem;
  font-family: "Courier New", monospace;
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: .15em;
  text-align: center;
  border-bottom: 2px solid var(--ink);
  padding-bottom: .5rem;
}
.profile img {
  display: block;
  width: 100%;
  max-width: 18rem;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  margin: 0 auto 1rem;
  border: 1px solid var(--ink);
  filter: grayscale(1) contrast(1.05);
}
.profile dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .4rem .9rem;
  margin: 0;
  font-family: "Courier New", monospace;
}
.profile dt { font-weight: bold; text-transform: uppercase; font-size: .9rem; padding-top: .1rem; }
.profile dd { margin: 0; border-bottom: 1px dotted #a89a80; }

/* Größere Bildschirme */
@media (min-width: 640px) {
  main { padding: 1.5rem 1rem; }
  .card { padding: 1.75rem; }
  h1 { font-size: 1.9rem; }
  button, .button { display: inline-block; width: auto; }
  .profile { display: grid; grid-template-columns: 14rem 1fr; gap: 0 1.25rem; align-items: start; }
  .profile h2 { grid-column: 1 / -1; }
  .profile img { margin: 0; }
}

/* --- Desktop-Rätsel ----------------------------------------------------- */
.os {
  position: relative;
  isolation: isolate;
  max-width: 60rem;
  height: calc(100dvh - var(--bar-h) - env(safe-area-inset-top) - 2.25rem - env(safe-area-inset-bottom));
  min-height: 30rem;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 10px;
  background: radial-gradient(circle at 30% 20%, #1f3d35, #070d0b 75%);
  color: #cfe8dc;
  font-family: ui-monospace, Menlo, Consolas, "Courier New", monospace;
  box-shadow: 0 4px 16px rgb(0 0 0 / .5);
}
.os [hidden] { display: none !important; }
.os-back { color: #7dffb0; text-decoration: none; padding: .4rem 0; }
.button.secondary { background: #3b4a44; margin-bottom: .5rem; }
.os-bar {
  display: flex;
  justify-content: space-between;
  height: 2rem;
  align-items: center;
  padding: 0 .75rem;
  background: rgb(0 0 0 / .55);
  font-size: .85rem;
}
.os-icons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 1rem;
  padding: 1.25rem;
}
.os button.os-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  width: auto;
  min-height: 0;
  margin: 0;
  padding: .5rem;
  background: none;
  color: inherit;
  font: inherit;
  font-size: .85rem;
}
.os-icon .ico {
  display: grid;
  place-items: center;
  width: 3.4rem;
  height: 3.4rem;
  border: 1px solid #3a8a66;
  border-radius: 12px;
  background: #0f1f1a;
  color: #7dffb0;
  font-size: 1.3rem;
  font-weight: bold;
}
.window {
  position: absolute;
  inset: 2rem 0 0 0;
  display: flex;
  flex-direction: column;
  background: #0c100f;
}
.win-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: .75rem;
  background: #1a2420;
  font-size: .9rem;
  flex: 0 0 auto;
}
.os button.win-close {
  width: 44px;
  height: 44px;
  min-height: 0;
  margin: 0;
  padding: 0;
  background: none;
  color: inherit;
  font-size: 1.6rem;
  line-height: 1;
}
.win-body { flex: 1; overflow: auto; padding: .75rem; -webkit-overflow-scrolling: touch; }
.os pre { margin: 0; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
.os input {
  min-height: 44px;
  font-family: inherit;
  font-size: 16px;
  color: #e6fff2;
  background: #050807;
  border: 1px solid #3a8a66;
}
.os button { background: #1f6b4a; }

/* Terminal */
.term { background: #000; color: #8cff9e; font-size: .9rem; line-height: 1.45; cursor: text; }
.term .line { white-space: pre-wrap; overflow-wrap: anywhere; }
.term .cmd { color: #fff; }
.term .err, .vault-msg.err, .decrypt .vault-msg { color: #ff7a7a; }
.term .ok, .vault-msg.ok { color: #7dffb0; font-weight: bold; }
.term .warn { color: #ffd166; }
.term .muted { color: #8a9a92; }
.term-line { display: flex; gap: .6ch; align-items: center; }
#term-prompt { color: #7dffb0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; }
.os #term-input {
  flex: 1;
  width: auto;
  min-width: 3ch;
  min-height: 2rem;
  padding: 0;
  border: 0;
  background: transparent;
  outline: none;
  caret-color: #7dffb0;
}

/* Dateien */
.files-path { color: #7dffb0; margin-bottom: .5rem; font-size: .85rem; }
.files-list { display: flex; flex-direction: column; }
.os button.file-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: .5rem;
  text-align: left;
  background: none;
  color: inherit;
  font: inherit;
  border-bottom: 1px solid #1d2a25;
  border-radius: 0;
}
.file-ico { width: 1.5rem; text-align: center; }

/* Tresor & Entschlüsseln */
.vault, .decrypt { text-align: center; }
.vault { display: flex; flex-direction: column; justify-content: center; }
.vault input, .decrypt input { text-align: center; letter-spacing: .2em; font-size: 1.3rem; max-width: 16rem; }
.vault button, .decrypt button { max-width: 16rem; margin-left: auto; margin-right: auto; }

/* Gelöst */
.os-solved {
  position: absolute;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1rem;
  background: rgb(0 0 0 / .88);
}
.os-solved .big { font-size: 1.6rem; color: #7dffb0; letter-spacing: .2em; }
.os-solved .button { max-width: 16rem; margin: 1rem auto 0; }
.os button.ghost { background: none; border: 1px solid #3a8a66; max-width: 16rem; margin: .75rem auto 0; }

@media (min-width: 640px) {
  .window { inset: 3rem 6% 6% 6%; border: 1px solid #2c5c47; border-radius: 8px; overflow: hidden; box-shadow: 0 10px 30px rgb(0 0 0 / .6); }
  #win-viewer { inset: 4.5rem 3% 3% 14%; }
  #win-vault { inset: 5rem 20% 15% 20%; }
}

/* Beweisstück in der Fallakte */
.section-title {
  margin: 1.75rem 0 .5rem;
  font-family: "Courier New", monospace;
  font-size: 1.2rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  border-bottom: 2px solid var(--ink);
}
.evidence-list { display: flex; flex-direction: column; gap: .9rem; margin-bottom: 1.5rem; }
.evidence {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: .9rem;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
  background: #fffaf0;
  border: 2px dashed var(--ink);
  border-radius: 4px;
  transform: rotate(.5deg);
}
.evidence:nth-child(even) { transform: rotate(-.5deg); }
.evidence:active { background: #f1e6cf; filter: none; }
.evidence img { width: 5.5rem; height: 5.5rem; object-fit: cover; border: 1px solid var(--ink); flex: 0 0 auto; }
.evidence-ico { font-size: 2.6rem; flex: 0 0 auto; width: 4rem; text-align: center; }
.evidence-text { display: flex; flex-direction: column; gap: .2rem; }
.evidence-text strong { font-family: "Courier New", monospace; text-transform: uppercase; letter-spacing: .05em; }
.evidence-state { font-size: .85rem; color: var(--accent); font-weight: bold; }

/* Sperrbildschirm */
.os-lock { display: flex; flex-direction: column; }
.lock {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: 1.5rem;
  text-align: center;
}
.lock-avatar {
  display: grid;
  place-items: center;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  background: #0f1f1a;
  border: 2px solid #3a8a66;
  color: #7dffb0;
  font-size: 2.4rem;
}
.lock-user { margin: 0 0 .5rem; font-size: 1.1rem; }
.lock input { max-width: 16rem; text-align: center; }
.lock button { max-width: 16rem; margin-top: .25rem; }
.lock-msg { color: #ff7a7a; font-weight: bold; margin: .25rem 0 0; }
.lock-hint { color: #8a9a92; font-size: .9rem; margin: .5rem 0 0; }

/* Bildbetrachter */
.viewer {
  width: 100%;
  max-width: 100vw;
  height: 100%;
  max-height: 100dvh;
  margin: 0;
  padding: max(3rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  border: 0;
  background: rgb(10 8 6 / .96);
  color: var(--paper);
  text-align: center;
  overflow: auto;
}
.viewer::backdrop { background: rgb(0 0 0 / .7); }
.viewer[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 70dvh; object-fit: contain; }
.viewer-title { margin: .75rem 0 0; font-weight: bold; font-family: "Courier New", monospace; }
.viewer-text { margin: .25rem 0 0; }
.viewer-orig { margin-top: .75rem; color: var(--paper); font-size: .9rem; }
.viewer form { position: absolute; top: max(.25rem, env(safe-area-inset-top)); right: .25rem; }
button.viewer-close {
  width: 48px;
  height: 48px;
  min-height: 0;
  margin: 0;
  padding: 0;
  font-size: 2rem;
  line-height: 1;
  background: none;
  color: var(--paper);
}
@media (min-width: 640px) {
  .evidence { width: 100%; }
}

/* Admin */
.admin-file { margin: 1.5rem 0 0; padding-top: 1rem; border-top: 1px solid #a89a80; }
.admin-file h2 { margin: 0 0 .5rem; font-family: "Courier New", monospace; font-size: 1.05rem; }
.admin-file textarea {
  width: 100%;
  padding: .7rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 16px;
  border: 1px solid #a89a80;
  border-radius: 4px;
  background: #fffaf0;
  color: var(--ink);
  resize: vertical;
}
.admin-meta { margin: .4rem 0 0; font-size: .85rem; color: #6b5d48; }
button.secondary { background: #6b5d48; }

/* Abschlussseite */
.finish-text { white-space: pre-wrap; font-family: "Courier New", monospace; font-size: 1.1rem; }
.admin-h {
  margin: 1.75rem 0 .5rem;
  font-family: "Courier New", monospace;
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  border-bottom: 2px solid var(--ink);
}
.admin-reset { margin-top: .75rem; }
label.check { display: flex; align-items: center; gap: .6rem; min-height: 44px; font-weight: normal; }
label.check input { width: 1.4rem; height: 1.4rem; min-height: 0; margin: 0; flex: 0 0 auto; }
button.danger { background: #a3241a; }

/* Einmalige Hinweismeldung (z. B. nach gelöstem Rätsel) */
.flash {
  max-width: 44rem;
  margin: 0 auto .75rem;
  padding: .75rem 1rem;
  color: #fff;
  font-weight: bold;
  background: var(--ok);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgb(0 0 0 / .4);
  animation: flash-in .35s ease-out;
}
@keyframes flash-in { from { opacity: 0; transform: translateY(-.5rem); } }
