/* Trickjäger – Web-Version. Farben wie in der Roblox-Version und auf den Vorschaubildern. */
:root {
  --paper: #FFF4DE;
  --wood: #6E4628;
  --ink: #2D2016;
  --quiet: #78644F;
  --red: #D7372D;
  --green: #3CAA50;
  --green-dark: #1F6B30;
  --orange: #F08C1E;
  --yellow: #FFD73C;
  --sky: #AAD7F5;
  --bubble: #E1F0FF;
  --grey: #C8C3B9;
  --slate: #82828C;
  --blue: #285AC8;
  --found: #28BE5A;
  --mark: #FFC800;
  --night: #2D1E50;
  --magic: #AA5AFF;
  --road: #46464B;
  --round: ui-rounded, "Arial Rounded MT Bold", "Nunito", "Segoe UI", system-ui, sans-serif;
  --text: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --emoji: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #8FD0F2 0%, #CDEBFA 40%, #E8F6FD 100%) fixed;
  color: var(--ink);
  font-family: var(--text);
  font-size: 18px;
  line-height: 1.4;
}

body.has-dialog { overflow: hidden; }

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: var(--wood);
  border-bottom: 4px solid var(--ink);
}
.logo {
  font-family: var(--round); font-weight: 700; font-size: 24px;
  color: var(--paper); text-decoration: none; white-space: nowrap;
}
.topbar-actions { display: flex; gap: 8px; }
.hud-btn {
  border: 3px solid var(--ink); border-radius: 14px;
  background: var(--paper); color: var(--ink);
  padding: 6px 14px; font-family: var(--round); font-weight: 700; font-size: 17px;
  white-space: nowrap;
}
.hud-btn.round { width: 44px; padding: 6px 0; border-radius: 50%; }

/* ---------- Straße ---------- */
#town {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}
/* Asphaltband mit Mittellinie hinter den Läden */
#town::before {
  content: "";
  position: absolute; top: 0; bottom: 0; left: 50%; width: 120px; transform: translateX(-50%);
  background:
    repeating-linear-gradient(180deg, #E8E2D6 0 34px, transparent 34px 68px) center / 8px 100% no-repeat,
    var(--road);
  z-index: -1;
}

.start, .plaza {
  text-align: center;
  background: var(--paper);
  border: 5px solid var(--ink);
  border-radius: 24px;
  padding: 18px 20px;
  margin: 8px 0 28px;
}
.start-sign {
  font-family: var(--round); font-weight: 700; font-size: 34px; color: var(--red);
}
.start p, .plaza p { margin: 6px 0 0; }

.block {
  position: relative;
  display: grid;
  gap: 26px;
  margin-bottom: 26px;
}

/* Laden-Fassade */
.shop {
  position: relative;
  display: block;
  width: 100%;
  padding: 58px 18px 0;
  background: var(--shop, #F0C878);
  border: 6px solid var(--ink);
  border-radius: 14px 14px 6px 6px;
  text-align: center;
  box-shadow: 0 10px 0 rgba(45, 32, 22, .18);
}
.shop .roof {
  position: absolute; left: -14px; right: -14px; top: -14px; height: 44px;
  background: #78322A; border: 6px solid var(--ink); border-radius: 10px;
}
.shop .sign {
  position: relative; display: block;
  margin: 0 auto; max-width: 92%;
  padding: 10px 16px;
  background: #3C281E; color: #FFDC78;
  border-radius: 10px;
  font-family: var(--round); font-weight: 700; font-size: 26px; line-height: 1.15;
}
.shop .face {
  display: flex; align-items: flex-end; justify-content: center; gap: 28px;
  margin-top: 14px;
}
.shop .shop-emoji { font-family: var(--emoji); font-size: 64px; line-height: 1; padding-bottom: 14px; }
.shop .door {
  width: 66px; height: 96px;
  background: #5A3A22; border: 5px solid var(--ink); border-bottom: none;
  border-radius: 14px 14px 0 0;
}
.shop .shop-progress {
  position: absolute; right: 10px; top: 40px;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 999px;
  padding: 2px 12px; font-family: var(--round); font-weight: 700; font-size: 16px;
}
.shop .shop-progress.done { background: var(--found); color: #fff; }
.shop:not(:disabled):hover { transform: translateY(-2px); }

/* Magisches Tor */
.gate {
  position: relative; display: block; width: 100%;
  padding: 0; border: none; background: none;
}
.gate .arch {
  display: block;
  margin: 0 -8px;
  padding: 8px;
  background: #6E5AA0; color: #FFE6FF;
  border: 6px solid #1B1233; border-radius: 16px;
  font-family: var(--round); font-weight: 700; font-size: 24px;
}
.gate .portal {
  display: flex; align-items: center; justify-content: center;
  min-height: 120px; margin: 0 22px;
  padding: 12px;
  border-left: 18px solid #6E5AA0; border-right: 18px solid #6E5AA0;
  outline: 6px solid #1B1233; outline-offset: -6px;
  background: radial-gradient(ellipse at 50% 55%, #FFEBFF 0%, #C882FF 45%, #8C46E6 100%);
  box-shadow: 0 0 40px 8px rgba(190, 120, 255, .55);
}
.gate .gate-status {
  background: rgba(27, 18, 51, .78); color: #fff;
  border-radius: 999px; padding: 6px 16px;
  font-family: var(--round); font-weight: 700; font-size: 18px;
}
.gate.ready .portal { animation: glow 1.4s ease-in-out infinite alternate; }
.gate.open .portal {
  background: rgba(255, 255, 255, .15);
  box-shadow: none;
}
.gate.open .gate-status { background: var(--found); }

@keyframes glow {
  from { box-shadow: 0 0 30px 6px rgba(190, 120, 255, .45); }
  to   { box-shadow: 0 0 70px 22px rgba(220, 160, 255, .9); }
}

/* Gesperrte Abschnitte hinter einem geschlossenen Tor */
.block.locked .shop, .block.locked .gate { filter: grayscale(.7) brightness(.85); }
.fog {
  position: absolute; inset: -8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: rgba(45, 30, 80, .72);
  border-radius: 18px;
  color: #fff; text-align: center;
  font-family: var(--round); font-weight: 700; font-size: 22px;
}
.fog-lock { font-family: var(--emoji); font-size: 48px; }

.plaza .trophy { font-family: var(--emoji); font-size: 72px; line-height: 1.1; }
.plaza-title { font-family: var(--round); font-weight: 700; font-size: 30px; }
.plaza.locked { opacity: .75; }
.plaza.won { background: #FFF1B8; box-shadow: 0 0 40px 10px rgba(255, 215, 60, .8); }

.footer {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px;
  padding: 18px 16px 28px;
  color: var(--quiet); font-size: 15px; text-align: center;
}
.footer a { color: var(--ink); }
.footer-links { display: flex; gap: 14px; }
.noscript { text-align: center; padding: 24px; }

/* ---------- 3D-Welt ---------- */
/* world-on setzt world3d.js erst, wenn die Welt wirklich läuft: sonst bleibt die 2D-Straße sichtbar */
body.world-on { overflow: hidden; }
body.world-on #town, body.world-on .footer { display: none; }
#world {
  position: fixed; left: 0; right: 0; bottom: 0; top: 58px;
  background: #8FD0F2;
  overflow: hidden;
}
#world canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.world-help {
  position: absolute; left: 12px; top: 12px; max-width: calc(100% - 24px);
  padding: 6px 12px;
  background: rgba(255, 244, 222, .92); border: 3px solid var(--ink); border-radius: 12px;
  font-family: var(--round); font-weight: 700; font-size: 14px;
  pointer-events: none;
}
.prompt {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 32px);
  padding: 14px 22px;
  background: var(--yellow); border: 4px solid var(--ink); border-radius: 18px;
  font-family: var(--round); font-weight: 700; font-size: 20px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, .25);
}
.prompt kbd {
  display: inline-block; margin-right: 8px; padding: 0 8px;
  background: #fff; border: 2px solid var(--ink); border-radius: 6px;
  font-family: var(--round);
}
.joystick {
  position: absolute; left: 24px; bottom: 24px; width: 128px; height: 128px;
  display: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .35); border: 4px solid rgba(45, 32, 22, .5);
  touch-action: none;
}
.joystick .knob {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border-radius: 50%; background: rgba(45, 32, 22, .6);
}
@media (pointer: coarse) {
  .joystick { display: block; }
  .prompt { bottom: 170px; }
}

/* ---------- Dialoge ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(20, 10, 40, .55);
}
.dialog {
  width: 100%; max-width: 520px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 20px;
  background: var(--paper);
  border: 6px solid var(--wood);
  border-radius: 24px;
  box-shadow: 0 16px 0 rgba(0, 0, 0, .2);
}
.dialog h2 { font-family: var(--round); margin: 0 0 8px; font-size: 28px; line-height: 1.15; }
.dialog p { margin: 8px 0; }
.dialog-head { display: flex; align-items: center; gap: 12px; }
.dialog-head h2 { flex: 1; margin: 0; }
.big-emoji { font-family: var(--emoji); font-size: 44px; }
.muted { color: var(--quiet); }

.primary, .secondary, .danger {
  display: block; width: 100%;
  margin-top: 14px; padding: 12px 18px;
  border: none; border-radius: 14px;
  font-family: var(--round); font-weight: 700; font-size: 20px;
}
.primary { background: var(--green); color: #fff; }
.secondary { background: var(--grey); color: var(--ink); }
.danger { background: var(--red); color: #fff; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.icon-btn {
  width: 44px; height: 44px; border: none; border-radius: 12px;
  background: var(--grey); font-family: var(--round); font-weight: 700; font-size: 20px;
}

/* Fenster-Zeilen (Karten, Meldungen) */
.row-header { font-family: var(--round); font-weight: 700; color: var(--green-dark); font-size: 20px; }
.row-title { color: var(--red); }
.row-magic-title { color: var(--magic); font-family: var(--round); font-size: 30px; margin: 4px 0; }
.row-quiet { color: var(--quiet); font-size: 16px; }
.row-magic { font-family: var(--round); font-weight: 700; color: #6A2FB8; }

/* Laden innen */
.shop-dialog { border-color: var(--wood); background: linear-gradient(180deg, var(--shop) 0 90px, var(--paper) 90px); }
.counters { display: grid; gap: 12px; margin-top: 12px; }
.counter {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px;
  background: #fff; border: 4px solid var(--wood); border-radius: 16px;
  text-align: left;
}
.counter-sign { font-family: var(--round); font-weight: 700; font-size: 21px; }
.counter-state { white-space: nowrap; font-size: 16px; color: var(--quiet); }
.counter.done { background: #E3F6E6; border-color: var(--found); }
.counter.done .counter-state { color: var(--green-dark); font-weight: 700; }
.note-magic { font-family: var(--round); font-weight: 700; color: #6A2FB8; }

/* Szene */
.scene-dialog { background: transparent; border: none; box-shadow: none; padding: 0; }
.hintbar {
  padding: 12px 14px; margin-bottom: 10px;
  background: var(--paper); border: 4px solid var(--wood); border-radius: 16px;
  font-family: var(--round); font-weight: 700; font-size: 19px; text-align: center;
}
.hintbar.tone-warn { background: #FFE1BE; }
.hintbar.tone-good { background: #CDF0CD; }
.panel {
  display: grid; gap: 8px;
  padding: 16px;
  background: var(--paper); border: 6px solid var(--wood); border-radius: 22px;
}
.el {
  display: block; width: 100%; min-height: 40px;
  padding: 6px 10px;
  border: none; border-radius: 12px; background: transparent;
  font-family: var(--round); font-weight: 700; font-size: 20px; line-height: 1.2;
  text-align: center; overflow-wrap: anywhere;
}
.el-title { color: var(--red); font-size: 28px; }
.el-image { min-height: 86px; background: var(--sky); font-size: 26px; }
.el-text { font-family: var(--text); font-weight: 500; font-size: 18px; }
.el-price { font-size: 25px; }
.el-oldprice { color: var(--quiet); font-size: 21px; }
.el-badge { background: var(--red); color: #fff; font-size: 23px; }
.el-timer { background: var(--red); color: #fff; font-size: 23px; }
.el-wait { background: var(--grey); font-size: 23px; }
.el-stock { color: var(--orange); }
.el-banner { background: var(--yellow); color: var(--red); min-height: 58px; animation: pulse .6s ease-in-out infinite alternate; }
.el-buy { background: var(--green); color: #fff; min-height: 54px; font-size: 23px; }
.el-bigbuy { background: var(--green); color: #fff; min-height: 84px; font-size: 30px; }
.el-skip { background: var(--orange); color: #fff; min-height: 54px; }
.el-no { background: var(--slate); color: #fff; font-size: 17px; }
.el-tiny { font-family: var(--text); font-weight: 400; font-size: 13px; color: var(--quiet); min-height: 28px; }
.el-check { font-family: var(--text); font-weight: 500; font-size: 18px; text-align: left; }
.el-input { font-family: var(--text); font-weight: 400; color: var(--quiet); background: #fff; border: 2px solid var(--quiet); text-align: left; }
.el-sender { color: var(--blue); text-align: left; font-size: 18px; }
.el-chat { font-family: var(--text); font-weight: 500; font-size: 17px; background: var(--bubble); text-align: left; padding: 10px 12px; }
.el-wheel { background: var(--ink); color: var(--yellow); min-height: 56px; font-family: var(--emoji); font-size: 26px; letter-spacing: 2px; white-space: pre; }
.el-swap { background: var(--sky); min-height: 50px; font-size: 21px; }
.el-bar { position: relative; min-height: 26px; padding: 0; background: var(--grey); overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; width: calc(var(--value, 0) * 100%); background: var(--green); }
.bar-caption { position: relative; font-family: var(--text); font-size: 14px; line-height: 26px; }

@keyframes pulse { from { background: var(--yellow); } to { background: var(--orange); } }

/* Markierungen: Rahmen immer; Tönung nur bei Feldern ohne eigenen Hintergrund, damit Schrift lesbar bleibt */
.el.found { outline: 5px solid var(--found); outline-offset: -2px; }
.el.solution, .answer.solution { outline: 5px solid var(--mark); outline-offset: -2px; }
:is(.el-title, .el-text, .el-price, .el-oldprice, .el-stock, .el-tiny, .el-check, .el-sender).found { background-color: rgba(40, 190, 90, .18); }
:is(.el-title, .el-text, .el-price, .el-oldprice, .el-stock, .el-tiny, .el-check, .el-sender).solution { background-color: rgba(255, 200, 0, .25); }

.answers {
  display: grid; gap: 8px; margin-top: 10px;
  padding: 12px;
  background: var(--paper); border: 4px solid var(--wood); border-radius: 18px;
}
.answer {
  padding: 12px; border: none; border-radius: 12px;
  background: var(--sky); font-family: var(--round); font-weight: 700; font-size: 20px;
}
.scene-dialog .leave { max-width: 260px; margin: 12px auto 0; }

/* Tor-Fragen */
.quiz-dialog { background: var(--night); border-color: var(--magic); color: #fff; box-shadow: 0 0 50px rgba(170, 90, 255, .5); }
.quiz-head {
  font-family: var(--round); font-weight: 700; font-size: 18px; color: #E6C8FF;
  text-align: center; margin-bottom: 10px;
}
.quiz-question { font-family: var(--round); font-weight: 700; font-size: 23px; text-align: center; line-height: 1.3; }
.quiz-options { display: grid; gap: 10px; margin-top: 14px; }
.quiz-option {
  padding: 14px; border: none; border-radius: 14px;
  background: var(--sky); color: var(--ink);
  font-family: var(--round); font-weight: 700; font-size: 20px;
}
.quiz-option.right { background: var(--found); color: #fff; }
.quiz-option.wrong { background: var(--red); color: #fff; }
.quiz-option.dim { opacity: .5; }
.quiz-option:disabled { cursor: default; }
.quiz-feedback { font-size: 18px; line-height: 1.4; margin-top: 14px; }
.quiz-dialog .secondary { background: #4B3A78; color: #fff; }

/* Lexikon */
.lex-list { display: grid; gap: 10px; margin-top: 10px; }
.lex-item { background: #fff; border-radius: 14px; padding: 12px 14px; }
.lex-item h3 { margin: 0; font-family: var(--round); font-size: 20px; }
.lex-item p { margin: 4px 0 0; font-size: 16px; }
.lex-item.unknown { background: var(--grey); }

@media (max-width: 480px) {
  body { font-size: 17px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar-actions { gap: 6px; }
  .logo { font-size: 22px; }
  .logo-text { display: none; }
  .hud-btn { font-size: 15px; padding: 6px 9px; }
  .shop .sign { font-size: 22px; }
  .shop .shop-emoji { font-size: 52px; }
  .el-title { font-size: 24px; }
  .el-bigbuy { font-size: 26px; }
  .dialog { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .gate.ready .portal { animation: none; }
  .el-banner { animation: none; }
}
