:root {
  --ink: #3b2f4a; --muted: #8a7f99; --card: #fffaf2; --line: #eadfce; --pink: #ff8fb1; --violet: #7a5cc2; --mint: #5fe3a1; --sun: #ffd23f; --red: #f25f6b;
  --font: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #bfe6ff; font-family: var(--font); color: var(--ink); user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; border-radius: 14px; padding: 6px 12px; background: #fff; box-shadow: 0 2px 0 #0001, 0 3px 10px #0001; transition: transform .08s; }
button:hover:not(:disabled) { transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
button.big { background: linear-gradient(#ff9fc0, #ff7aa8); color: #fff; font-weight: 800; font-size: 1.15rem; padding: 10px 20px; box-shadow: 0 4px 0 #d9547f, 0 6px 16px #ff7aa855; }
button.big.alt { background: linear-gradient(#9b80e0, #7a5cc2); box-shadow: 0 4px 0 #5a3fa0, 0 6px 16px #7a5cc255; }
button.link { background: none; box-shadow: none; padding: 2px 4px; color: var(--violet); text-decoration: underline; }
button.danger { color: var(--red); }
kbd { font: inherit; font-size: .75em; background: #0000000f; border-radius: 6px; padding: 0 5px; margin-left: 2px; }
input { font: inherit; border: 2px solid var(--line); border-radius: 12px; padding: 6px 10px; background: #fff; color: var(--ink); }
input:focus { outline: none; border-color: var(--pink); }
.muted { color: var(--muted); } .small { font-size: .85em; }

/* Beschriftungen in der Welt */
#labels, #floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; white-space: nowrap; font-weight: 700; font-size: 13px; text-align: center; }
.lbl.player { background: #fffd; padding: 0 10px; border-radius: 10px; box-shadow: 0 2px 6px #0002; }
.lbl.cr span { background: #ffffffc8; padding: 0 7px; border-radius: 8px; font-size: 12px; }
.lbl.cr.mine span { background: #fff4c7e0; }
.lbl .bub { display: block; font-size: 20px; filter: drop-shadow(0 2px 2px #0003); animation: pop .4s; }
.lbl.offer { background: #fff; padding: 1px 9px; border-radius: 10px; box-shadow: 0 2px 8px #0003; font-size: 14px; }
.lbl.offer.poor { opacity: .6; }
.lbl.chest { background: #fff4c7; padding: 0 9px; border-radius: 10px; box-shadow: 0 2px 6px #0002; }
.floater { position: absolute; left: 0; top: 0; font-weight: 800; font-size: 18px; color: #fff; text-shadow: 0 2px 0 #3b2f4a88, 0 0 6px #3b2f4a55; white-space: nowrap; }
.floater.res.dim { opacity: .6; font-size: 14px; } .floater.big { font-size: 30px; } .floater.sm { font-size: 13px; }
@keyframes pop { from { transform: scale(.3); } 60% { transform: scale(1.2); } to { transform: scale(1); } }

/* Anzeige */
#hud { display: none; } #hud.on { display: block; }
#topleft { position: fixed; left: 14px; top: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.money { background: #fff; border-radius: 18px; padding: 2px 16px 2px 10px; font-size: 1.6rem; font-weight: 800; box-shadow: 0 3px 0 #0001, 0 4px 14px #0002; display: flex; gap: 6px; align-items: center; }
.pill { background: #fffe; border-radius: 14px; padding: 3px 10px; display: flex; gap: 12px; font-weight: 700; box-shadow: 0 2px 8px #0002; align-items: center; }
#energy { display: inline-flex; gap: 3px; align-items: center; }
#energy i { width: 11px; height: 16px; border-radius: 4px; background: #e8e0f4; display: inline-block; }
#energy i.full { background: linear-gradient(#ffe066, #ffb703); }
#energy i.part { background: linear-gradient(to top, #ffd23f calc(var(--f) * 100%), #e8e0f4 0); }
#world { position: fixed; right: 14px; top: 12px; background: #fffe; border-radius: 16px; padding: 8px 12px; box-shadow: 0 3px 12px #0002; min-width: 180px; font-weight: 700; }
#world .code { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 4px; letter-spacing: .05em; }
#world .code button { font-size: .85rem; padding: 2px 10px; background: var(--violet); color: #fff; }
#world .pl { display: flex; gap: 6px; align-items: center; font-size: .95rem; } #world .pl.off { opacity: .5; }
#world .pl i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
#toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(640px, 90vw); }
.toast { background: #fff; border-radius: 14px; padding: 6px 16px; font-weight: 700; box-shadow: 0 4px 16px #0003; animation: pop .3s; transition: opacity .5s, transform .5s; text-align: center; }
.toast.good { background: #eafff3; } .toast.bad { background: #ffeef0; } .toast.disc { background: #f3ecff; }
.toast.out { opacity: 0; transform: translateY(-8px); }
#prompt { position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%); background: #3b2f4ae6; color: #fff; padding: 8px 18px; border-radius: 16px; font-weight: 700; font-size: 1.05rem; display: none; cursor: pointer; }
#prompt.on { display: block; animation: pop .25s; }
#prompt kbd { background: #fff; color: var(--ink); padding: 0 8px; margin-right: 6px; }
#bar { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
#bar button { font-weight: 700; padding: 8px 14px; } #bar button.off { opacity: .45; }
#ordersbtn[data-n]:not([data-n=""])::after { content: attr(data-n); background: var(--red); color: #fff; border-radius: 10px; padding: 0 6px; margin-left: 4px; font-size: .8em; }
#conn { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #3b2f4ae0; color: #fff; padding: 14px 22px; border-radius: 18px; font-weight: 700; display: none; }
#conn.on { display: block; }

/* Fenster */
#panel { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: #2a1f3a40; }
#panel.on { display: flex; }
.sheet { position: relative; background: var(--card); border-radius: 26px; width: min(980px, 94vw); max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px #0004; padding: 18px 22px 10px; animation: pop .22s; }
.sheet h2 { margin: 0 0 6px; font-size: 1.7rem; } .sheet h2 small { color: var(--muted); font-size: .9rem; margin-left: 6px; }
.sheet h3 { margin: 14px 0 6px; } .sheet h4 { margin: 10px 0 4px; }
.sheet .body { overflow: auto; padding-right: 6px; padding-bottom: 12px; user-select: text; }
.sheet .x { position: absolute; right: 14px; top: 14px; border-radius: 50%; width: 36px; height: 36px; padding: 0; }
.cgrid { display: flex; flex-wrap: wrap; gap: 8px; }
.ccard { position: relative; width: 108px; display: flex; flex-direction: column; align-items: center; padding: 6px; border-radius: 16px; background: #fff; }
.cgrid.big .ccard { width: 140px; }
.ccard img { width: 92px; height: 92px; } .cgrid.big .ccard img { width: 124px; height: 124px; }
.ccard b { font-size: .95rem; line-height: 1.1; } .ccard small { color: var(--muted); }
.ccard.sel { outline: 3px solid var(--pink); background: #fff0f5; }
.ccard em { position: absolute; top: 4px; left: 6px; background: var(--pink); color: #fff; border-radius: 8px; padding: 0 7px; font-style: normal; font-weight: 800; }
.ccard em.cool { background: #8a7f99; }
.ccard.cool { opacity: .55; }
.itemicon { font-size: 52px; height: 92px; display: flex; align-items: center; }
.mixslots { display: flex; gap: 14px; align-items: center; justify-content: center; }
.slot { width: 150px; height: 170px; border: 3px dashed #d9c9f0; border-radius: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); background: #fff; }
.slot.filled { border-style: solid; border-color: var(--pink); color: var(--ink); }
.slot img { width: 110px; height: 110px; } .slot small { color: var(--muted); }
.plus { font-size: 2.2rem; font-weight: 800; color: var(--violet); }
.hintbox { background: #f4efff; border-radius: 18px; padding: 8px 14px; margin: 10px 0; }
.hints { margin: 0; padding-left: 18px; } .hints li { margin: 2px 0; }
.hints i { font-style: normal; font-size: .78em; color: var(--muted); }
.hints .p-wahrscheinlich { font-weight: 800; } .hints .p-selten { opacity: .7; }
.surprise { font-weight: 800; color: var(--violet); margin: 6px 0 2px; }
.mixbar { display: flex; gap: 10px; align-items: center; }

/* Ergebnis */
#result { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: #2a1f3a66; }
#result.on { display: flex; }
.rcard { position: relative; background: var(--card); border-radius: 30px; width: min(520px, 94vw); padding: 18px 24px; text-align: center; box-shadow: 0 30px 80px #0006; animation: pop .35s; overflow: hidden; }
.rcard h2 { margin: 0; font-size: 1.9rem; color: var(--violet); }
.rshow { width: 100%; height: 260px; display: block; }
.burst { position: absolute; inset: -40%; background: repeating-conic-gradient(from 0deg, #fff6c9 0 10deg, #fffaf2 10deg 20deg); animation: spin 18s linear infinite; z-index: -1; opacity: .9; }
.rcard > *:not(.burst) { position: relative; }
@keyframes spin { to { transform: rotate(360deg); } }
.rname { display: flex; gap: 6px; justify-content: center; margin: 4px 0; } .rname input { font-size: 1.3rem; font-weight: 800; text-align: center; width: 220px; }
.explain { text-align: left; margin: 6px auto; padding-left: 20px; max-width: 420px; } .explain li { margin: 2px 0; } .explain .mut { color: var(--violet); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 8px 0; }
.tags span { background: #fff; border-radius: 12px; padding: 1px 10px; font-weight: 700; font-size: .9rem; box-shadow: 0 1px 4px #0001; }
.rbtn { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }

/* Detail */
.detail { display: grid; grid-template-columns: 330px 1fr; gap: 18px; }
.detail .show { width: 100%; height: 300px; display: block; background: radial-gradient(#fff, #f3ead9); border-radius: 22px; }
.detail .row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.abil { list-style: none; padding: 0; margin: 0; } .abil li { margin: 4px 0; } .abil small { display: block; color: var(--muted); margin-left: 24px; font-size: .82em; }
.bar { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 8px; font-size: .9rem; }
.bar i { height: 9px; border-radius: 6px; background: linear-gradient(90deg, var(--pink) var(--v), #eee6f6 var(--v)); }
.look { border-collapse: collapse; font-size: .92rem; } .look td { padding: 1px 10px 1px 0; } .look td:first-child { color: var(--muted); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; box-shadow: inset 0 0 0 1px #0002; }

/* Basis */
.locks { display: flex; gap: 10px; flex-wrap: wrap; }
.lockopt { display: flex; flex-direction: column; align-items: center; width: 180px; padding: 10px; }
.lockopt big { font-size: 2rem; } .lockopt small { color: var(--muted); }
.lockopt.sel { outline: 3px solid var(--violet); background: #f4efff; }
.allow { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 10px 0; }
.ups { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.up { background: #fff; border-radius: 16px; padding: 10px 12px; } .up p { margin: 2px 0 6px; font-size: .9rem; color: var(--muted); }
.cost { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; font-weight: 700; } .cost .miss { color: var(--red); }
.done { color: #2bb673; font-weight: 800; }

/* Forschungsbuch */
.disc { display: flex; flex-wrap: wrap; gap: 6px; }
.d { background: #efe8f8; border-radius: 10px; padding: 1px 10px; color: #b5a9c7; font-weight: 700; }
.d.on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px #0001; }
.tree { overflow-x: auto; padding: 10px 0; }
.tnode { display: flex; flex-direction: column; align-items: center; }
.tpar { display: flex; gap: 14px; margin-top: 10px; padding-top: 10px; border-top: 2px solid var(--line); }
.tn { display: flex; flex-direction: column; align-items: center; background: #fff; border-radius: 14px; padding: 4px 8px; min-width: 90px; }
.tn img { width: 72px; height: 72px; } .tn small { color: var(--muted); }

/* Aufträge */
.order { background: #fff; border-radius: 16px; padding: 10px 14px; margin: 8px 0; position: relative; }
.order p { margin: 0 70px 6px 0; font-weight: 700; } .order .reward { position: absolute; right: 14px; top: 10px; color: #c48a00; }
.order.empty { color: var(--muted); }
.fit { display: flex; flex-wrap: wrap; gap: 6px; }
.mini { display: flex; align-items: center; gap: 4px; padding: 2px 10px 2px 4px; } .mini img { width: 34px; height: 34px; }
.help li { margin: 4px 0; }

/* Start */
#start { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: radial-gradient(#ffffff55, #7a5cc244); }
#start.on { display: flex; }
.startcard { background: var(--card); border-radius: 34px; padding: 26px 34px; width: min(470px, 94vw); box-shadow: 0 30px 80px #0005; text-align: center; animation: pop .4s; }
.logo { font-size: 4rem; margin: 0; line-height: 1; color: var(--pink); text-shadow: 0 4px 0 #d9547f33; letter-spacing: -1px; }
.logo span { color: var(--violet); }
.tag { margin: 2px 0 14px; color: var(--muted); font-weight: 700; }
.startcard label { display: flex; flex-direction: column; text-align: left; font-weight: 700; gap: 2px; }
.swatches { display: flex; gap: 8px; justify-content: center; margin: 10px 0 14px; }
.sw { width: 30px; height: 30px; border-radius: 50%; padding: 0; } .sw.on { outline: 3px solid var(--ink); outline-offset: 2px; }
.startbtns { display: flex; flex-direction: column; gap: 10px; }
.join { display: flex; gap: 8px; } .join input { width: 110px; text-transform: uppercase; text-align: center; font-weight: 800; letter-spacing: .1em; }
.join button { flex: 1; }
.hint { font-size: .9rem; color: var(--muted); }
.err { color: var(--red); font-weight: 700; min-height: 1.2em; margin: 4px 0; }
.howto { text-align: left; font-size: .9rem; } .howto summary { cursor: pointer; font-weight: 700; }

@media (max-width: 760px) {
  .detail { grid-template-columns: 1fr; } #bar { flex-wrap: wrap; justify-content: center; width: 96vw; } #bar kbd { display: none; }
  #world { min-width: 0; font-size: .85rem; }
}
