* { box-sizing: border-box; margin: 0; padding: 0; }
:root { --gold: #ffd98a; --panel: rgba(22, 28, 18, .86); --line: rgba(230, 200, 120, .35); }
html, body { height: 100%; overflow: hidden; background: #0b0f0a; font-family: 'Trebuchet MS', system-ui, sans-serif; color: #f3ecd8; user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
canvas#game:active { cursor: grabbing; }
#ov { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; text-align: center; font-size: 12px; white-space: nowrap; text-shadow: 0 1px 2px #000, 0 0 4px #000; color: #fff3c4; will-change: transform; }
.lbl .foe { color: #ff9a8a; } .lbl .oth { color: #cfe0ff; }
.lbl.fx { font-size: 15px; }
.lbl .alert { color: #ffe14a; font-size: 20px; }
.hpb { width: 40px; height: 5px; background: rgba(0,0,0,.6); margin: 2px auto 0; border-radius: 3px; overflow: hidden; }
.hpb i { display: block; height: 100%; background: #ff5050; }
.bub { background: rgba(255,250,235,.95); color: #2a2014; text-shadow: none; border-radius: 9px; padding: 3px 9px; margin-bottom: 3px; font-size: 12.5px; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; box-shadow: 0 4px 14px rgba(0, 0, 0, .4); }

#hud { position: fixed; left: 10px; top: 10px; width: 290px; pointer-events: none; }
#stats { display: flex; gap: 10px; align-items: center; }
#portrait { width: 60px; height: 60px; border-radius: 50%; border: 2px solid #d9a441; flex: none; background: #223; }
.sinfo { flex: 1; min-width: 0; }
.nm { font-weight: bold; font-size: 16px; color: var(--gold); }
.rk { font-size: 11px; opacity: .85; margin-bottom: 2px; }
.bl { font-size: 9.5px; opacity: .75; margin-top: 2px; }
.bar { height: 7px; background: rgba(0, 0, 0, .5); border-radius: 5px; overflow: hidden; }
.bar.thin { height: 3px; margin-top: 4px; }
.bar > i { display: block; height: 100%; width: 0; transition: width .2s; }
#lives { font-size: 11px; color: #bfe3ff; margin-top: 3px; letter-spacing: 1px; }
#quest { margin-top: 8px; font-size: 13px; line-height: 1.35; }
#quest:empty { display: none; }
#quest h4 { color: var(--gold); font-size: 13.5px; }
#quest .ch { font-size: 11px; opacity: .7; }
#quest .ms { margin-top: 6px; border-top: 1px solid rgba(255, 255, 255, .12); padding-top: 4px; color: #bfe3ff; font-size: 12px; }

#topright { position: fixed; right: 10px; top: 10px; text-align: right; pointer-events: none; }
#minimap { border-radius: 10px; border: 2px solid var(--line); display: block; margin-left: auto; background: #000; }
#clock { margin-top: 6px; font-size: 12px; line-height: 1.4; display: inline-block; }
#clock b { color: var(--gold); font-weight: normal; }
#menubar { position: fixed; right: 10px; top: 240px; display: flex; flex-direction: column; gap: 6px; }
#menubar button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: #fff; font-size: 18px; }
#menubar button:hover { background: rgba(80, 70, 30, .9); }

#carry { position: fixed; left: 10px; bottom: 12px; font-size: 12.5px; pointer-events: none; display: none; }
#hint { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: rgba(0, 0, 0, .7); border: 1px solid var(--line); padding: 7px 16px; border-radius: 20px; font-size: 14px; pointer-events: none; white-space: nowrap; }
#toasts { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); width: min(520px, 60vw); display: flex; flex-direction: column; gap: 6px; pointer-events: none; z-index: 5; }
.toast { background: rgba(30, 24, 12, .9); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; font-size: 13.5px; text-align: center; animation: tin .3s; transition: opacity .5s; }
.toast.out { opacity: 0; }
@keyframes tin { from { transform: translateY(-10px); opacity: 0; } }

#dialog { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); width: min(780px, 94vw); display: flex; gap: 14px; background: rgba(18, 22, 14, .95); border: 2px solid #b8904a; border-radius: 16px; padding: 14px; z-index: 10; box-shadow: 0 8px 30px rgba(0, 0, 0, .6); cursor: pointer; }
#dialog.narr { border-color: #6a7a9a; background: rgba(14, 18, 30, .95); }
#dlgPortrait { width: 128px; height: 128px; border-radius: 14px; border: 2px solid #b8904a; flex: none; }
.dlgBody { flex: 1; min-width: 0; position: relative; }
#dlgName { color: var(--gold); font-weight: bold; font-size: 16px; margin-bottom: 4px; }
#dlgText { font-size: 16px; line-height: 1.45; min-height: 46px; }
#dialog.narr #dlgText { font-style: italic; color: #d8e0f5; }
#dlgChoices { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.choice { text-align: left; background: rgba(80, 64, 30, .6); color: #fff; border: 1px solid #b8904a; border-radius: 10px; padding: 8px 12px; font-size: 14.5px; }
.choice:hover { background: rgba(140, 110, 40, .8); }
#dlgNext { position: absolute; right: 0; bottom: -4px; color: var(--gold); animation: bob 1s infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }

#panel { position: fixed; inset: 5vh 5vw; background: rgba(18, 22, 14, .96); border: 2px solid #b8904a; border-radius: 16px; padding: 16px 20px; overflow: auto; z-index: 20; }
.phead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.phead h2 { color: var(--gold); }
.x { background: none; border: 1px solid var(--line); color: #fff; border-radius: 8px; width: 34px; height: 34px; font-size: 16px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button, .mb button, .skill button { background: rgba(60, 50, 26, .8); color: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 13px; }
.tabs button.on, .mb button.on { background: #b8904a; color: #1a1408; font-weight: bold; }
button:disabled { opacity: .35; cursor: default; }
h3 { color: var(--gold); margin: 12px 0 6px; font-size: 15px; }
.small { font-size: 12px; opacity: .78; }
.grid2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 20px; }
.cnt td { padding: 2px 14px 2px 0; }
.sbar { display: grid; grid-template-columns: 105px 1fr 95px; gap: 8px; align-items: center; margin: 5px 0; font-size: 13px; }
.bar.big { height: 11px; }
.proph { font-style: italic; color: #bfe3ff; margin: 3px 0; }
.members { display: flex; flex-direction: column; gap: 6px; }
.mem { display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, .04); border-radius: 10px; padding: 6px 8px; }
.mem.me { border: 1px solid #b8904a; }
.mem.star { background: rgba(80, 110, 200, .12); }
.mem img { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.mem > div:nth-child(2) { flex: 1; min-width: 0; }
.mb { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.life { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 6px 0 14px; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 118px; text-align: center; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px; }
.stage img { border-radius: 50%; }
.stage b { color: var(--gold); }
.stage span { font-size: 12px; }
.stage.locked { opacity: .45; }
.stage .q { width: 60px; height: 60px; border-radius: 50%; background: #222; display: flex; align-items: center; justify-content: center; font-size: 28px; }
.arr { color: #b8904a; font-size: 20px; }
.chron p { border-left: 2px solid #b8904a; padding: 3px 10px; margin: 6px 0; font-size: 14px; }
.skill { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px; background: rgba(255, 255, 255, .04); border-radius: 10px; margin: 6px 0; }
.menu { display: flex; flex-direction: column; gap: 10px; max-width: 360px; margin: 10px auto; }
.menu button, #titleBtns button { background: rgba(80, 64, 30, .85); color: #fff; border: 1px solid #b8904a; border-radius: 12px; padding: 12px; font-size: 17px; }
.menu button:hover, #titleBtns button:hover { background: #b8904a; color: #1a1408; }
.menu .danger { background: rgba(110, 30, 30, .7); }
.help { border-collapse: collapse; margin: 8px 0; width: 100%; }
.help td { padding: 5px 10px; border-bottom: 1px solid rgba(255, 255, 255, .08); font-size: 14px; }
.help td:first-child { color: var(--gold); white-space: nowrap; }
#bigmap { display: block; margin: 0 auto; border-radius: 10px; border: 2px solid var(--line); }

#title { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(10, 14, 8, .35), rgba(5, 8, 4, .85)); z-index: 30; padding: 16px; }
.tbox { text-align: center; max-width: 640px; max-height: 100%; overflow: auto; }
.logo { font-size: clamp(44px, 11vw, 92px); font-weight: bold; letter-spacing: 6px; color: var(--gold); text-shadow: 0 0 30px rgba(255, 180, 60, .5), 0 4px 0 #6a4a1a; }
.sub { font-size: 20px; margin-bottom: 14px; color: #f3e0b0; }
.intro { font-size: 15px; line-height: 1.5; opacity: .9; margin-bottom: 18px; }
#titleBtns { display: flex; flex-direction: column; gap: 10px; max-width: 320px; margin: 0 auto; }
#loading { font-style: italic; opacity: .8; }
#titleHelp { margin-top: 14px; text-align: left; background: var(--panel); border-radius: 12px; padding: 10px; }
.credit { margin-top: 18px; font-size: 11px; opacity: .55; }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .45s; z-index: 40; }
#fade.on { opacity: 1; }

#touch { position: fixed; inset: 0; pointer-events: none; z-index: 8; }
#stick { position: absolute; left: 24px; bottom: 30px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255, 255, 255, .08); border: 2px solid rgba(255, 255, 255, .2); pointer-events: auto; }
#knob { position: absolute; left: 40px; top: 40px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255, 220, 140, .45); }
#tbtns { position: absolute; right: 16px; bottom: 24px; display: grid; grid-template-columns: repeat(3, 62px); gap: 8px; pointer-events: auto; direction: rtl; }
#tbtns button { width: 62px; height: 62px; border-radius: 50%; background: rgba(40, 32, 16, .7); color: #fff; border: 2px solid rgba(230, 200, 120, .5); font-size: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; direction: ltr; }
#tbtns button small { font-size: 9px; }
#tbtns button.big { background: rgba(160, 110, 40, .75); }

@media (max-width: 760px) {
  #hud { width: 200px; }
  #portrait { width: 42px; height: 42px; }
  .nm { font-size: 13px; }
  #quest { font-size: 11.5px; }
  #quest h4 { font-size: 12px; }
  #minimap { width: 110px; height: 86px; }
  #clock { font-size: 10px; }
  #menubar { top: auto; bottom: 190px; right: 12px; flex-direction: row; }
  #menubar button { width: 34px; height: 34px; font-size: 15px; }
  #hint { bottom: 180px; font-size: 12px; }
  #dialog { bottom: 8px; padding: 10px; }
  #dlgPortrait { width: 60px; height: 60px; }
  #dlgText { font-size: 14px; }
  .grid2 { grid-template-columns: 1fr; }
  .sbar { grid-template-columns: 80px 1fr 80px; font-size: 11px; }
  #panel { inset: 2vh 2vw; padding: 10px; }
  #carry { bottom: 170px; }
  #toasts { width: 80vw; top: 110px; }
}

/* ===== Große Buch-Titel ===== */
#titlecard { position: fixed; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none; z-index: 25; opacity: 0; }
#titlecard.show { animation: tcard 5s ease forwards; }
#titlecard .tc1 { font-size: clamp(16px, 3vw, 24px); letter-spacing: 8px; text-transform: uppercase; color: #f3e0b0; }
#titlecard .tc2 { font-family: Georgia, 'Times New Roman', serif; font-size: clamp(36px, 8vw, 78px); color: var(--gold); text-shadow: 0 0 30px rgba(255, 170, 60, .7), 0 4px 0 #5a3a10; }
@keyframes tcard { 0% { opacity: 0; transform: scale(1.15); filter: blur(10px); } 15% { opacity: 1; transform: scale(1); filter: blur(0); } 75% { opacity: 1; } 100% { opacity: 0; transform: scale(.97); } }
/* ===== Lebendigerer Titelbildschirm ===== */
.logo { animation: glow 3.5s ease-in-out infinite; }
@keyframes glow { 50% { text-shadow: 0 0 55px rgba(255, 190, 80, .85), 0 4px 0 #6a4a1a; } }
.tbox { animation: rise 1.4s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } }
#dialog { animation: dlgIn .25s ease; }
@keyframes dlgIn { from { transform: translate(-50%, 16px); opacity: 0; } }
.choice { transition: transform .12s, background .12s; }
.choice:hover { transform: translateX(4px); }
#hud .box, #topright .box { backdrop-filter: blur(4px); }

/* ===== Film-Modus bei Story-Szenen ===== */
#cineTop, #cineBot { position: fixed; left: 0; right: 0; height: 0; background: #000; z-index: 9; pointer-events: none; transition: height .6s ease; }
#cineTop { top: 0; } #cineBot { bottom: 0; }
body.cine #cineTop, body.cine #cineBot { height: 9vh; }
#hud, #topright, #menubar, #hint, #carry, #toasts { transition: opacity .5s; }
body.cine #hud, body.cine #topright, body.cine #menubar, body.cine #hint, body.cine #carry { opacity: 0; pointer-events: none; }
body.cine #dialog.narr { background: transparent; border: none; box-shadow: none; justify-content: center; bottom: 11vh; }
body.cine #dialog.narr #dlgText { font-size: clamp(17px, 2.3vw, 24px); text-align: center; text-shadow: 0 2px 6px #000, 0 0 18px #000; color: #f4ecd8; font-family: Georgia, 'Times New Roman', serif; }
body.cine #dialog.narr #dlgNext { right: 50%; }
#titlecard .tc3 { max-width: 640px; margin: 18px auto 0; font-size: clamp(14px, 1.8vw, 18px); font-style: italic; color: #e8dcc0; text-shadow: 0 2px 6px #000; font-family: Georgia, serif; }
#titlecard .tc3 b { color: var(--gold); font-style: normal; }
#titlecard.show { animation-duration: 7s; }
/* ===== Traum-Stimmung ===== */
#dreamFx { position: fixed; inset: 0; pointer-events: none; z-index: 3; opacity: 0; transition: opacity 1.2s; }
body.dream #dreamFx { opacity: 1; background: radial-gradient(ellipse at center, rgba(120,150,255,0) 45%, rgba(40,60,160,.55) 100%); }
body.nightmare #dreamFx { opacity: 1; background: radial-gradient(ellipse at center, rgba(120,0,0,0) 35%, rgba(60,0,0,.75) 100%); }

/* ===== Malstil: Leinwand-Struktur ===== */
#paper { position: fixed; inset: 0; pointer-events: none; z-index: 2; opacity: 0; mix-blend-mode: overlay; background-size: 256px; transition: opacity .6s; }
body.paint #paper { opacity: .22; }

#mousehint { position: fixed; right: 14px; bottom: 14px; background: rgba(0, 0, 0, .55); border: 1px solid rgba(255, 255, 255, .25); padding: 6px 12px; border-radius: 16px; font-size: 13px; pointer-events: none; z-index: 6; }
body.mousemode canvas#game { cursor: crosshair; }
#cutcap { position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%); width: min(760px, 90vw); text-align: center; font-size: 19px; font-style: italic; color: #f4ecd8; text-shadow: 0 2px 8px #000, 0 0 3px #000; pointer-events: none; z-index: 11; opacity: 0; transition: opacity .5s; }
#cutcap.show { opacity: 1; }
