* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; background: #87b9e8; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: #f4f6fb; }
/* Spielfläche fest auf Fenstergröße: Overlays ändern nie die Größe */
#game { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; }
.hidden { display: none !important; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 16, 30, 0.55); backdrop-filter: blur(3px); padding: 16px; z-index: 10; }
.panel { background: #151c2c; border: 1px solid #2c3854; border-radius: 12px; padding: 28px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.4); }
.panel h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: .5px; }
.panel h2 { margin: 0 0 12px; }
.sub { margin: 0 0 18px; color: #9aa7c2; font-size: 14px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button { flex: 1; }
.tabs button.active { background: #2f6fed; border-color: #2f6fed; }
label { display: block; font-size: 13px; color: #b9c3d9; margin-bottom: 12px; }
input { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 8px; border: 1px solid #33405e; background: #0e1422; color: #fff; font-size: 15px; }
button { padding: 10px 14px; border-radius: 8px; border: 1px solid #33405e; background: #222c44; color: #fff; font-size: 14px; cursor: pointer; }
button.primary { width: 100%; background: #2f6fed; border-color: #2f6fed; font-weight: 600; margin-top: 4px; }
button:disabled { opacity: .6; cursor: wait; }
.error { color: #ff8a80; min-height: 1.2em; font-size: 14px; margin: 10px 0 0; }
.help { padding-left: 18px; line-height: 1.7; font-size: 14px; color: #cfd7e8; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#crosshair { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 24px; text-shadow: 0 0 3px #000; }
#status { position: absolute; left: 12px; top: 10px; font-size: 13px; background: rgba(0,0,0,.35); padding: 6px 10px; border-radius: 6px; }
#hotbar { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); display: flex; gap: 6px; }
#hotbar .slot { width: 40px; height: 40px; border-radius: 6px; border: 2px solid rgba(255,255,255,.35); position: relative; }
#hotbar .slot.active { border-color: #fff; transform: translateY(-4px); }
#hotbar .slot span { position: absolute; right: 3px; bottom: 1px; font-size: 11px; text-shadow: 0 0 2px #000; }

/* ----- Neue HUD-Elemente ----- */
#hotbar .slot { width: 46px; height: 46px; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; }
#hotbar .slot img, .grid .cell img { width: 30px; height: 30px; image-rendering: pixelated; }
#hotbar .slot .num { position: absolute; left: 3px; top: 1px; font-size: 10px; opacity: .7; text-shadow: 0 0 2px #000; }
#hotbar .slot .cnt, .grid .cell .cnt { position: absolute; right: 3px; bottom: 1px; font-size: 12px; font-weight: 700; text-shadow: 0 0 3px #000, 0 0 2px #000; }
#bars { position: absolute; left: 50%; bottom: 66px; transform: translateX(-50%); width: 470px; display: flex; justify-content: space-between; }
#hearts, #food { display: flex; gap: 1px; font-size: 17px; line-height: 1; text-shadow: 0 0 2px #000; }
#food { flex-direction: row-reverse; }
#hearts span { color: #e53935; }
#hearts span.half { background: linear-gradient(90deg, #e53935 50%, #3a2a2a 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }
#hearts span.empty { color: #3a2a2a; }
#food img { width: 17px; height: 17px; image-rendering: pixelated; }
#food img.empty { opacity: .2; filter: grayscale(1); }
#food img.half { opacity: .55; }
#mapbox { position: absolute; right: 10px; top: 10px; text-align: right; }
#minimap { width: 128px; height: 128px; border-radius: 8px; border: 2px solid rgba(255,255,255,.4); background: #000; image-rendering: pixelated; }
#coords { font-size: 12px; background: rgba(0,0,0,.4); padding: 4px 8px; border-radius: 6px; margin-top: 4px; white-space: pre; }
#toast { position: absolute; left: 50%; bottom: 140px; transform: translateX(-50%); font-size: 15px; background: rgba(0,0,0,.5); padding: 5px 12px; border-radius: 6px; opacity: 0; transition: opacity .4s; }
#toast.show { opacity: 1; }
#hurt-flash { position: absolute; inset: 0; box-shadow: inset 0 0 160px 40px rgba(220,0,0,.75); opacity: 0; transition: opacity .35s; }
#hurt-flash.on { opacity: 1; transition: none; }
.settings { display: flex; gap: 10px; align-items: end; margin: 12px 0; }
.settings label { margin: 0; flex: 1; }
select { display: block; width: 100%; margin-top: 4px; padding: 9px; border-radius: 8px; border: 1px solid #33405e; background: #0e1422; color: #fff; }
.panel.wide { max-width: 860px; }
.panel.center { text-align: center; }
.panel h3 { margin: 0 0 8px; font-size: 16px; }
.small { font-size: 12px; margin: 8px 0; }
.inv-layout { display: flex; gap: 20px; flex-wrap: wrap; }
.inv-left { flex: 1 1 380px; }
.inv-right { flex: 1 1 300px; max-height: 55vh; overflow-y: auto; }
.grid { display: grid; grid-template-columns: repeat(9, 44px); gap: 4px; }
.grid .cell { width: 44px; height: 44px; border-radius: 6px; background: #0e1422; border: 2px solid #2c3854; position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.grid .cell:hover { border-color: #6f8fd8; }
.grid.hb .cell.active { border-color: #fff; }
.recipe { display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: 8px; background: #0e1422; margin-bottom: 6px; border: 1px solid #2c3854; }
.recipe .ing { display: flex; align-items: center; gap: 2px; font-size: 12px; }
.recipe .ing img { width: 22px; height: 22px; image-rendering: pixelated; }
.recipe .ing.missing { opacity: .45; }
.recipe .arrow { opacity: .6; }
.recipe .name { flex: 1; font-size: 13px; }
.recipe button { padding: 5px 9px; font-size: 12px; }
.recipe.can { border-color: #3d7a4a; }

/* ----- Runde 2: Menü, Studio, Chat, Missionen, Schlag ----- */
.overlay.solid { background: radial-gradient(circle at 30% 20%, #2a3d63, #0b1020 70%); backdrop-filter: none; }
#pause { background: rgba(10, 16, 30, 0.35); backdrop-filter: none; }
#pause .panel { max-width: 440px; }
#pause #resumeBtn { margin-bottom: 10px; }
.menu-panel { max-width: 520px; }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; }
.menu-buttons button { padding: 13px; font-size: 16px; text-align: left; }
.menu-buttons button.primary { text-align: center; }
.notice { background: #3a2a14; border: 1px solid #8a6a2a; color: #ffd98a; padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.row-buttons { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.row-buttons.end { justify-content: flex-end; }
.row-buttons.end #st-msg { margin: 0 auto 0 0; }
button.auto { width: auto; margin: 0; }
button.danger { background: #6a2230; border-color: #8a2c3c; }
button.small-btn { width: auto; padding: 7px 12px; margin: 0; font-size: 13px; }
button.linkish { background: none; border: none; color: #8fb4ff; padding: 0; font-size: 12px; text-decoration: underline; }
label.check { display: flex; gap: 8px; align-items: center; }
label.check input { width: auto; margin: 0; display: inline; }
#world-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.world-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: #0e1422; border: 1px solid #2c3854; }
.world-row.own { border-color: #3d6a9a; }
.world-row .info { flex: 1; min-width: 0; }
.wname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wmeta { font-size: 12px; color: #9aa7c2; }
.wcount { font-size: 12px; color: #9fe0a8; white-space: nowrap; }

.studio-panel { max-width: 980px; max-height: calc(100vh - 32px); overflow-y: auto; }
.studio-layout { display: flex; gap: 22px; flex-wrap: wrap; }
.studio-view-wrap { flex: 1 1 320px; }
#studio-view { width: 100%; height: 420px; display: block; border-radius: 12px; background: linear-gradient(#5a86c8, #253655); cursor: grab; }
.studio-controls { flex: 1 1 420px; }
.ctl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.ctl-grid label { margin-bottom: 8px; }
input[type=color] { padding: 2px; height: 36px; cursor: pointer; }
.paint-wrap { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
#st-paint { width: 256px; height: 256px; border-radius: 6px; border: 2px solid #33405e; image-rendering: pixelated; cursor: crosshair; touch-action: none; }
.paint-tools { flex: 1; min-width: 160px; }
#st-palette { display: grid; grid-template-columns: repeat(8, 26px); gap: 4px; }
#st-palette .sw { width: 26px; height: 26px; padding: 0; border-radius: 5px; border: 2px solid #33405e; }
#st-palette .sw.active, #st-eraser.active { outline: 2px solid #fff; outline-offset: 1px; }

/* Chat unten links: Verlauf scrollbar, blendet aus, lesbar */
#chat { position: absolute; left: 12px; bottom: 96px; width: min(460px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 4px; }
#chat-log { max-height: 34vh; overflow: hidden; display: flex; flex-direction: column; gap: 1px; font-size: 14px; line-height: 1.35; }
#chat-log .line { background: rgba(0,0,0,.45); padding: 2px 8px; border-radius: 4px; text-shadow: 0 1px 2px #000; word-wrap: break-word; transition: opacity .8s; }
#chat-log .line.faded { opacity: 0; }
#chat-log .ts { color: #9aa7c2; font-size: 12px; }
#chat-log .name { font-weight: 700; }
#chat-log .line.sys { color: #ffe08a; font-style: italic; }
#chat.open #chat-log { overflow-y: auto; pointer-events: auto; background: rgba(0,0,0,.35); border-radius: 6px; padding: 4px; }
#chat.open #chat-log .line.faded { opacity: 1; }
#chat-input { pointer-events: auto; margin: 0; background: rgba(8,12,22,.85); }

#tip { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); max-width: min(560px, calc(100vw - 300px)); background: rgba(20, 40, 80, .82); border: 1px solid #5b86d6; padding: 10px 16px; border-radius: 10px; font-size: 15px; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
#resume-hint { position: absolute; left: 50%; top: calc(50% + 30px); transform: translateX(-50%); font-size: 13px; background: rgba(0,0,0,.45); padding: 4px 10px; border-radius: 6px; opacity: .85; }
#quest-tracker { position: absolute; right: 10px; top: 186px; width: 210px; background: rgba(0,0,0,.4); border-radius: 8px; padding: 6px 9px; font-size: 12px; }
.qt-title { font-weight: 700; color: #ffd76a; margin-bottom: 2px; }
.qt-part.dim { color: #9aa7c2; margin-top: 3px; }
#xp { position: absolute; left: 50%; bottom: 88px; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: #b9f27a; text-shadow: 0 0 2px #000; }
#xp-bar { width: 300px; height: 6px; background: rgba(0,0,0,.55); border-radius: 3px; overflow: hidden; }
#xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, #7ed957, #c6f56b); transition: width .4s; }
#toast.quest { background: rgba(30, 60, 110, .8); }
#toast.quest-done { background: rgba(40, 110, 50, .88); font-weight: 700; font-size: 16px; padding: 8px 16px; }
.quest { background: #0e1422; border: 1px solid #2c3854; border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.quest.active { border-color: #d6a93a; }
.quest.done { opacity: .65; }
.quest.locked { opacity: .45; }
.q-title { font-weight: 600; font-size: 14px; }
.q-desc { font-size: 12px; color: #9aa7c2; margin: 2px 0; }
.q-part { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-top: 3px; }
.q-bar { flex: 0 0 120px; height: 6px; background: #222c44; border-radius: 3px; overflow: hidden; }
.q-bar.big { flex: 1; height: 8px; }
.q-bar div { height: 100%; background: #d6a93a; }
.q-levelbox { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 13px; }
.q-levelbox .q-bar div { background: #7ed957; }
.q-reward { font-size: 12px; color: #9fe0a8; margin-top: 3px; }
#quests .inv-right { max-height: 60vh; }
#quests .inv-left { max-height: 60vh; overflow-y: auto; }
button, input, select { font-family: inherit; }
#studio-view { height: min(400px, 46vh); }
#st-paint { width: 224px; height: 224px; }
.studio-panel { padding-bottom: 0; }
.studio-panel > .row-buttons.end { position: sticky; bottom: 0; background: #151c2c; padding: 12px 0 18px; margin-top: 8px; border-top: 1px solid #2c3854; }

/* ----- Runde 3: Energie und Schlafen ----- */
#xp { bottom: 112px; }
#energy { position: absolute; left: 50%; bottom: 88px; transform: translateX(-50%); width: 470px; display: flex; justify-content: flex-end; gap: 1px; font-size: 15px; line-height: 1; text-shadow: 0 0 2px #000; }
#energy img { width: 16px; height: 16px; image-rendering: pixelated; }
#energy img.half { opacity: .55; }
#energy img.empty { opacity: .2; filter: grayscale(1); }
#energy.low img:not(.empty) { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
#tired { position: absolute; inset: 0; opacity: 0; transition: opacity 2s; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 35%, rgba(10,5,25,.85) 100%); backdrop-filter: blur(1.2px); }
#tired.on { opacity: 1; animation: tiredPulse 4s ease-in-out infinite; }
@keyframes tiredPulse { 50% { opacity: .75; } }
#sleep { position: fixed; inset: 0; z-index: 12; display: flex; align-items: center; justify-content: center; background: #02030a; opacity: 0; transition: opacity .6s; }
#sleep.on { opacity: .94; }
.sleep-box { text-align: center; max-width: 520px; padding: 20px; }
.sleep-box h2 { font-size: 26px; margin: 0 0 10px; }
#sleepEnergy { font-size: 22px; color: #ffd54f; letter-spacing: 2px; margin: 14px 0 18px; }
#toast.tired { background: rgba(90, 50, 130, .85); }

/* Runde 4: Schloss-Fenster, Grundstück, Meldungen */
#toast.denied { background: rgba(150, 30, 30, .88); font-weight: 600; }
#claim-label { position: absolute; left: 50%; top: 34px; transform: translateX(-50%); font-size: 13px; padding: 3px 10px; border-radius: 6px; background: rgba(0,0,0,.45); }
#claim-label.own { color: #a5d6a7; }
#claim-label.foreign { color: #ff9e9e; }
#lock .panel { max-width: 460px; }
#lock .modes { display: flex; gap: 8px; margin: 10px 0 4px; }
#lock .modes button { flex: 1; padding: 9px 6px; }
#lock .modes button.active { background: #2e7d32; border-color: #66bb6a; color: #fff; font-weight: 700; }
#lockFriends { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; min-height: 26px; }
#lockFriends .chip { display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.12); border-radius: 14px; padding: 3px 4px 3px 10px; font-size: 14px; }
#lockFriends .chip button { width: auto; padding: 0 7px; margin: 0; border-radius: 10px; line-height: 18px; }
#lockFriends .muted { opacity: .65; font-size: 13px; }
#lockFriendsWrap.dim { opacity: .55; }
#lockAddForm { display: flex; gap: 6px; }
#lockAddForm input { flex: 1; margin: 0; }
#lockAddForm button { width: auto; margin: 0; }
#lock .error { min-height: 1em; color: #ff8a80; }
.recipe .station { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; padding: 1px 5px; border-radius: 8px; background: rgba(255,138,42,.25); margin-left: 4px; }
.recipe .station img { width: 14px; height: 14px; }
.recipe .station.missing { background: rgba(200,60,60,.35); }
