:root {
  --bg: #120c07;
  --panel: #241a10;
  --panel-2: #2f2316;
  --line: #5a4428;
  --text: #f1e4c4;
  --muted: #b39c76;
  --gold: #e8b83c;
  --gold-dark: #9c7420;
  --danger: #e2553a;
  --lapis: #3d6fd1;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Georgia, 'Times New Roman', serif;
}

body {
  background:
    radial-gradient(ellipse at 50% -10%, #3a2812 0%, transparent 60%),
    var(--bg);
}

button, input { font: inherit; }

button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
}
button:hover { border-color: var(--gold); }
button.primary {
  background: linear-gradient(#e8b83c, #b88a26);
  color: #2a1a06;
  border-color: #f4d27a;
  font-weight: bold;
}
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { filter: grayscale(0.8) brightness(0.6); cursor: default; }

input {
  background: #150f09;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 0;
}
input:focus { outline: 2px solid var(--gold-dark); }

.screen { display: none; min-height: 100%; }
.screen.active { display: flex; }
#login, #verify, #menu, #lobby { align-items: center; justify-content: center; padding: 24px 16px; }

.panel {
  background: linear-gradient(var(--panel), #1b130b);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  width: min(560px, 100%);
  box-shadow: 0 20px 60px #0008;
}

h1 {
  font-size: clamp(32px, 7vw, 52px);
  margin: 0;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 2px 0 #6b4a10, 0 0 24px #e8b83c55;
  text-align: center;
}
h2 { margin: 0 0 8px; color: var(--gold); }
h3 { margin: 0 0 6px; color: var(--gold); font-size: 16px; }
.subtitle { text-align: center; color: var(--muted); margin: 4px 0 18px; }
.story { color: #dccba6; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); min-height: 1.4em; }

.field { display: flex; flex-direction: column; gap: 4px; margin: 14px 0; color: var(--muted); }
.row { display: flex; gap: 8px; margin: 8px 0; }
.row > input { flex: 1; }
.row > button.primary { flex: 1; padding: 11px; }
.join input { text-transform: uppercase; letter-spacing: 4px; text-align: center; }

.code {
  font-family: 'Courier New', monospace;
  letter-spacing: 4px;
  background: #150f09;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
}

.group { margin: 14px 0 6px; }
.small { font-size: 13px; }
.account { text-align: center; margin: 6px 0 14px; }
button.link { background: none; border: none; color: var(--gold); text-decoration: underline; padding: 0 4px; }
.resume { background: #2b1f10; border: 1px solid var(--gold-dark); border-radius: 8px; padding: 10px 12px; margin: 8px 0 14px; }
.resume p { margin: 0 0 8px; }
.resume button { width: 100%; padding: 10px; }
.resume-list { display: grid; gap: 6px; margin: 6px 0; }
.resume-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-size: 14px; }
.resume-row span { flex: 1; }
.resume-row button { width: auto; padding: 7px 12px; flex: none; }
.banner {
  position: absolute; left: 50%; top: 18%; transform: translateX(-50%);
  background: #120c07dd; border: 1px solid var(--gold-dark); border-radius: 10px;
  padding: 14px 24px; text-align: center; max-width: 80%; pointer-events: none;
}
.banner h2 { margin: 0 0 4px; font-size: 24px; }
.banner p { margin: 0; color: #dccba6; }
a.link-button { display: inline-block; background: linear-gradient(#e8b83c, #b88a26); color: #2a1a06; padding: 9px 16px; border-radius: 6px; text-decoration: none; font-weight: bold; }
#save-btn, #exit-btn { padding: 6px 10px; }
.sizes { align-items: center; }
.sizes .size { width: 44px; padding: 8px 0; }
.sizes .size.selected { border-color: var(--gold); background: #4a3518; color: var(--gold); font-weight: bold; }
.sizes .size:disabled { opacity: 0.35; cursor: default; }
.sizes #create { flex: 1; }
.count { font-size: 18px; margin: 12px 0 4px; color: var(--gold); }
.members li.waiting { color: var(--muted); border-style: dashed; font-style: italic; }
#force { width: 100%; padding: 9px; }
.members { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 6px; }
.members li {
  display: flex; align-items: center; gap: 10px;
  background: #1a120a; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
}
.swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid #0006; flex: none; }
.members .host { margin-left: auto; color: var(--gold); font-size: 13px; }
#start { width: 100%; padding: 11px; margin: 6px 0; }
.controls { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.controls ul { margin: 0; padding-left: 18px; color: #dccba6; font-size: 14px; }
.controls li { margin: 4px 0; }

/* ---------- Spiel ---------- */
#game { flex-direction: column; height: 100vh; padding: 8px 12px; gap: 8px; }

.hud {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 17px;
}
.lives { color: var(--gold); letter-spacing: 2px; font-size: 20px; min-width: 120px; }
.room-name { color: var(--text); font-style: italic; text-align: center; flex: 1; }
.score { font-family: 'Courier New', monospace; color: var(--gold); min-width: 120px; text-align: right; }

.game-main { flex: 1; display: flex; gap: 10px; min-height: 0; }
.stage {
  flex: 1; position: relative; min-width: 0;
  display: flex; align-items: center; justify-content: center;
}
#canvas {
  image-rendering: pixelated;
  background: #000;
  border: 2px solid var(--line);
  border-radius: 4px;
  max-width: 100%;
  max-height: 100%;
  cursor: none;
  touch-action: none;
}

.overlay {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: #120c07e6; border: 1px solid var(--gold-dark); border-radius: 10px;
  padding: 16px 22px; text-align: center; max-width: 90%;
}
#death { top: 12px; transform: translateX(-50%); padding: 10px 16px; font-size: 14px; max-width: min(520px, 90%); }
#death p { margin: 0 0 8px; }
.overlay.end { padding: 28px 36px; }
.overlay.end h2 { font-size: 30px; }
.hidden { display: none; }

.side { width: 200px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
#minimap { width: 186px; height: 124px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 4px; background: #0b0805; align-self: center; }
.team { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.team li { background: #1a120a; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.team .top { display: flex; align-items: center; gap: 6px; }
.team .where { color: var(--muted); font-size: 12px; }
.team .dead { color: var(--danger); }
.team .icons { font-size: 13px; }
.log {
  flex: 1; overflow: hidden; font-size: 12.5px; color: var(--muted);
  display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-height: 60px;
}
.log .say { color: var(--text); }

.bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.inv-wrap { display: flex; align-items: center; gap: 8px; }
.inventory { display: flex; gap: 4px; }
.slot {
  width: 40px; height: 40px; background: #1a120a; border: 1px solid var(--line); border-radius: 6px;
  padding: 0; display: grid; place-items: center;
}
.slot canvas { width: 32px; height: 32px; image-rendering: pixelated; }
.slot:disabled { opacity: 0.4; cursor: default; }
.keys-help { font-size: 12px; flex: 1; text-align: center; min-width: 200px; }
.quick { display: flex; gap: 4px; flex-wrap: wrap; }
.quick button { padding: 5px 9px; font-size: 13px; }

@media (max-width: 820px) {
  .side { display: none; }
  #game { padding: 6px 8px; }
}

/* ---------- Abspann ---------- */
#credits {
  flex-direction: column; align-items: center; justify-content: flex-start;
  height: 100vh; padding: 18px 16px; gap: 10px; position: relative; overflow: hidden;
  background: radial-gradient(ellipse at 50% 120%, #4a3312 0%, #120c07 60%);
}
#credits-team { width: 540px; max-width: 100%; aspect-ratio: 5 / 1; height: auto; image-rendering: pixelated; }
.credits-window {
  position: relative; width: min(640px, 100%); flex: 1; overflow: hidden;
  mask-image: linear-gradient(transparent, #000 12%, #000 88%, transparent);
  -webkit-mask-image: linear-gradient(transparent, #000 12%, #000 88%, transparent);
}
.credits-roll {
  position: absolute; left: 0; right: 0; top: 100%; text-align: center;
  animation: credits-scroll 55s linear forwards;
}
.credits-roll.paused { animation-play-state: paused; opacity: 0.12; transition: opacity 0.8s; }
@keyframes credits-scroll { to { transform: translateY(calc(-100% - 70vh)); } }
.credits-roll h1 { font-size: clamp(28px, 6vw, 44px); margin: 0 0 24px; }
.credits-roll h2 { font-size: 24px; margin: 40px 0 10px; }
.credits-roll h3 { color: var(--gold); margin: 34px 0 6px; font-size: 18px; letter-spacing: 1px; }
.credits-roll p { margin: 6px auto; max-width: 520px; color: #e8dcc0; line-height: 1.6; }
.credits-roll .big { font-size: 22px; color: var(--text); }
.credits-roll .stat { font-family: 'Courier New', monospace; color: var(--gold); font-size: 18px; }
.credits-end { position: absolute; top: 50%; transform: translateY(-50%); text-align: center; }
.credits-end h2 { font-size: 26px; }
.credits-skip { position: absolute; right: 16px; bottom: 16px; font-size: 13px; padding: 6px 12px; }
.trophy {
  text-align: center; background: linear-gradient(#3a2a10, #24180a); border: 1px solid var(--gold);
  border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; color: var(--gold);
}
@media (prefers-reduced-motion: reduce) {
  .credits-roll { animation: none; position: static; }
  .credits-window { overflow-y: auto; mask-image: none; -webkit-mask-image: none; }
  .credits-end { position: static; transform: none; margin-top: 12px; }
}

/* ---------- Rätseltafel ---------- */
.puzzle { width: min(300px, 92%); padding: 14px 16px; }
.puzzle h3 { margin: 0 0 10px; }
.puzzle-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  background: #3a2a17; padding: 6px; border-radius: 6px; border: 1px solid var(--gold-dark);
}
.pz-tile {
  aspect-ratio: 1; padding: 0; font: bold 20px Georgia, serif; color: #2a1a06;
  background: linear-gradient(#d8b273, #a9834b); border: 1px solid #6e5230; border-radius: 4px;
}
.pz-tile img { width: 70%; height: 70%; image-rendering: pixelated; pointer-events: none; }
.pz-tile.blank { background: #1a120a; border-color: #1a120a; cursor: default; }
.puzzle-grid.solved .pz-tile:not(.blank) { box-shadow: 0 0 8px #f0c53c; }
.puzzle #puzzle-close { margin-top: 6px; }

/* ---------- Sprache, Tarif ---------- */
.lang-switch { display: flex; justify-content: flex-end; gap: 4px; margin: -12px -12px 6px 0; }
.lang-switch .lang { padding: 4px 10px; font-size: 13px; }
.lang-switch .lang.selected { border-color: var(--gold); color: var(--gold); background: #4a3518; }
.plans { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 10px; margin: 12px 0; }
.plans legend { color: var(--muted); padding: 0 6px; }
.plan { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.plan input { margin-top: 4px; accent-color: var(--gold); }
.plan span { display: flex; flex-direction: column; }
.plan small { color: var(--muted); font-size: 12.5px; }
.plan-label { text-align: center; margin: -8px 0 12px; }

/* ---------- Werbung ---------- */
.ad {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 6px; text-align: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 40%, #3a2812ee, #0b0805f2);
  border: 2px solid var(--gold-dark); border-radius: 4px;
}
.ad.hidden { display: none; }
.ad-label {
  position: absolute; top: 8px; left: 10px; font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  color: #2a1a06; background: var(--gold); border-radius: 3px; padding: 1px 6px;
}
#ad-art { width: 96px; height: 96px; image-rendering: pixelated; }
.ad h3 { font-size: 22px; margin: 4px 0 0; }
.ad p { margin: 0; max-width: 420px; color: #e8dcc0; }
.ad-bar { width: min(320px, 80%); height: 6px; background: #241a10; border-radius: 3px; overflow: hidden; margin-top: 6px; }
#ad-progress { height: 100%; width: 0; background: linear-gradient(90deg, #b88a26, #f0c53c); }
.ad .ad-foot { font-size: 12px; color: var(--muted); }
/* Zwei gut sichtbare Angebote: werbefrei für 1,99 € und die Expeditions-Ausrüstung */
.ad-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 10px; }
.ad-free, .ad-gear {
  font-size: 15px; font-weight: bold; border-radius: 6px; padding: 8px 14px; border: 2px solid var(--gold);
  box-shadow: 0 2px 0 #000a;
}
.ad-free { color: #2a1a06; background: linear-gradient(#f0c53c, #b88a26); }
.ad .ad-gear { color: var(--gold); background: #2a1c0c; text-decoration: none; }
.ad .ad-gear:hover { color: #2a1a06; background: linear-gradient(#f0c53c, #b88a26); }

/* Links zu Impressum, Datenschutz und Nutzungsbedingungen */
.legal-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 18px; padding: 12px 16px 18px; font-size: 13px; }
.legal-links a, .title-panel a { color: var(--muted); }
.legal-links a:hover { color: var(--gold); }
body:has(#game.active) .legal-links, body:has(#credits.active) .legal-links { display: none; }

/* Hinweis nach dem Verlassen der Gruft */
.info { color: var(--gold); background: var(--panel-2); border: 1px solid var(--gold-dark); border-radius: 6px; padding: 8px 12px; }

/* Code der Expedition */
.code-pop { min-width: min(420px, 90%); background: var(--panel); z-index: 5; box-shadow: 0 10px 40px #000a; }
.code-pop p { margin: 6px 0 10px; }
.code-value { font: bold 30px/1.2 ui-monospace, Menlo, monospace; letter-spacing: 6px; color: var(--gold); background: var(--bg); border: 1px dashed var(--gold-dark); border-radius: 8px; padding: 10px 14px; margin: 8px 0 14px; user-select: all; word-break: break-all; }
.code-pop .row { justify-content: center; }
.code-chip { width: 100%; margin-bottom: 8px; font-size: 13px; letter-spacing: 1px; }

/* Kauf der werbefreien Version */
.buy { background: var(--panel-2); border: 1px solid var(--gold-dark); border-radius: 8px; padding: 12px 16px; text-align: left; }
.buy h3 { margin: 0 0 6px; }
.buy p { margin: 6px 0; }
.buy .consent { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0; cursor: pointer; }
.buy .consent input { margin-top: 3px; flex: none; }
.buy .row { justify-content: flex-start; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Logo: „HOWARD CARTER'S“ klein zwischen Goldlinien, darunter groß „CURSE“, darunter ein Ankh */
.logo { display: flex; flex-direction: column; align-items: center; line-height: 1; letter-spacing: 0; text-shadow: none; }
.logo-top {
  display: flex; align-items: center; gap: 12px;
  font-size: clamp(13px, 2.8vw, 18px); letter-spacing: 0.32em; color: #e3c172;
}
.logo-top::before, .logo-top::after {
  content: ''; height: 1px; width: clamp(22px, 8vw, 60px);
  background: linear-gradient(to right, transparent, var(--gold));
}
.logo-top::after { background: linear-gradient(to left, transparent, var(--gold)); margin-left: -0.32em; }
.logo-main {
  font-size: clamp(56px, 14vw, 96px); letter-spacing: 0.14em; padding-left: 0.14em; margin-top: 2px;
  background: linear-gradient(180deg, #fff3c8 0%, #f2c94e 42%, #a8761a 68%, #e8b83c 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #5a3c0c) drop-shadow(0 0 18px #e8b83c40);
}
.logo-rule { display: flex; align-items: center; gap: 10px; color: var(--gold); margin-top: 4px; }
.logo-rule::before, .logo-rule::after {
  content: ''; height: 1px; width: clamp(40px, 16vw, 120px);
  background: linear-gradient(to right, transparent, var(--gold-dark));
}
.logo-rule::after { background: linear-gradient(to left, transparent, var(--gold-dark)); }
.credits-roll .logo { margin-bottom: 24px; }
.credits-roll .logo-main { font-size: clamp(48px, 11vw, 80px); }

/* Link zur Expeditions-Ausrüstung im Menü und in der Werbung */
.gear-row { justify-content: center; }
.gear-link { color: var(--gold); text-decoration: none; border: 1px solid var(--gold-dark); border-radius: 6px; padding: 6px 12px; }
.gear-link:hover { background: var(--panel-2); }
.ad .ad-foot a { color: var(--gold); }
