:root {
  --panel: rgba(20, 24, 36, 0.72);
  --panel-solid: #1b2130;
  --border: rgba(255, 255, 255, 0.14);
  --text: #f4f6fb;
  --muted: #aab3c5;
  --accent: #4ade80;
  --accent-dark: #16a34a;
  --gold: #facc15;
  --red: #ef4444;
  --blue: #38bdf8;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1020; color: var(--text); font-family: var(--font); }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Login ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 50;
  background: radial-gradient(ellipse at top, rgba(56, 189, 248, 0.35), transparent 60%), linear-gradient(180deg, #7cc6ff 0%, #3f8f3a 70%, #2f5e22 100%); }
.login-box { width: min(440px, calc(100vw - 32px)); background: var(--panel); border: 2px solid var(--border); border-radius: 14px;
  padding: 24px; backdrop-filter: blur(6px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4); max-height: calc(100vh - 32px); overflow-y: auto; }
.logo { margin: 0; text-align: center; font-size: clamp(34px, 9vw, 52px); font-weight: 900; letter-spacing: 2px; color: #f3f4f6;
  text-shadow: 0 3px 0 #6b7280, 0 6px 0 #374151, 0 10px 18px rgba(0, 0, 0, 0.5); }
.logo span { display: block; font-size: 0.72em; letter-spacing: 10px; margin-top: -4px; color: #f97316;
  text-shadow: 0 3px 0 #9a3412, 0 6px 0 #431407, 0 10px 18px rgba(0, 0, 0, 0.5); }
.logo-sub { text-align: center; font-weight: 800; letter-spacing: 3px; font-size: 13px; color: #e5e7eb; margin: 6px 0 18px;
  text-shadow: 0 2px 0 #111; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tab { flex: 1; padding: 9px 4px; background: rgba(255, 255, 255, 0.06); color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; font-weight: 700; font-size: 13px; }
.tab.active { background: var(--accent-dark); color: #fff; border-color: var(--accent); }
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.form input, .form select { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: rgba(0, 0, 0, 0.35);
  color: var(--text); font-size: 15px; outline: none; }
.form input:focus { border-color: var(--accent); }
.form label:has(input[type=checkbox]) { flex-direction: row; align-items: center; }
.btn { padding: 10px 16px; border-radius: 9px; border: none; background: linear-gradient(180deg, #4ade80, #16a34a); color: #fff;
  font-weight: 800; font-size: 15px; box-shadow: 0 4px 0 #0f5f2c; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #0f5f2c; }
.btn.big { padding: 13px; font-size: 17px; width: 100%; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.ghost { background: rgba(255, 255, 255, 0.08); box-shadow: none; border: 1px solid var(--border); margin-top: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.hint { font-size: 12px; color: var(--muted); margin: 2px 0; }
.center { text-align: center; margin-top: 10px; }
.error { color: #fca5a5; font-size: 14px; min-height: 18px; margin-top: 10px; text-align: center; font-weight: 600; }
.controls-help { margin-top: 14px; font-size: 11px; color: var(--muted); line-height: 1.5; border-top: 1px solid var(--border); padding-top: 10px; }
#resume { text-align: center; }
.loading-text { font-size: 22px; font-weight: 800; text-shadow: 0 2px 0 #000; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; user-select: none; }
#hud button, #hud input, #chat { pointer-events: auto; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.panel.small { padding: 4px 10px; font-size: 13px; font-weight: 700; }

#playerCard { position: absolute; top: 12px; left: 12px; display: flex; gap: 10px; padding: 8px 12px 8px 8px; width: 270px; }
#avatar { width: 56px; height: 56px; border-radius: 8px; border: 2px solid rgba(255, 255, 255, 0.3); image-rendering: pixelated; background: #333; }
.level { position: absolute; left: 12px; top: 60px; background: #111827; border: 1px solid var(--border); border-radius: 6px;
  font-size: 11px; font-weight: 800; padding: 1px 6px; }
.card-info { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.pname { font-weight: 800; font-size: 15px; text-shadow: 0 1px 0 #000; }
.bar { position: relative; height: 13px; background: rgba(0, 0, 0, 0.5); border-radius: 4px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.12); }
.bar > div { height: 100%; transition: width 0.2s; }
.bar.hp > div { background: linear-gradient(180deg, #4ade80, #16a34a); }
.bar.hp.low > div { background: linear-gradient(180deg, #f87171, #b91c1c); }
.bar.xp > div { background: linear-gradient(180deg, #fde047, #ca8a04); }
.bar span { position: absolute; inset: 0; font-size: 10px; line-height: 12px; text-align: center; font-weight: 800; text-shadow: 0 1px 1px #000; }
.money { display: flex; gap: 14px; font-size: 12px; }

#clock { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); }
#topButtons { position: absolute; top: 12px; right: 206px; display: flex; gap: 6px; }
.icon-btn { width: 38px; height: 38px; border-radius: 9px; background: var(--panel); border: 1px solid var(--border); color: #fff; font-size: 18px; }
#mapBox { position: absolute; top: 10px; right: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
#minimap { width: 180px; height: 180px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.55); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4); }

#crosshair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%, -50%); }
#crosshair::before, #crosshair::after { content: ""; position: absolute; background: rgba(255, 255, 255, 0.85); box-shadow: 0 0 2px #000; }
#crosshair::before { left: 10px; top: 2px; width: 2px; height: 18px; }
#crosshair::after { top: 10px; left: 2px; height: 2px; width: 18px; }
#mineBar { position: absolute; left: 50%; top: calc(50% + 22px); width: 60px; height: 6px; transform: translateX(-50%); background: rgba(0, 0, 0, 0.5);
  border-radius: 3px; overflow: hidden; display: none; }
#mineFill { height: 100%; width: 0; background: #fff; }

#hotbar { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 5px; padding: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.slot { position: relative; width: 54px; height: 54px; background: rgba(0, 0, 0, 0.4); border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.slot img { width: 38px; height: 38px; image-rendering: pixelated; pointer-events: none; }
.slot .n { position: absolute; right: 4px; bottom: 1px; font-size: 12px; font-weight: 800; text-shadow: 0 1px 1px #000, 0 0 3px #000; }
.slot .k { position: absolute; left: 4px; top: 1px; font-size: 10px; color: var(--muted); font-weight: 700; }
.slot.sel { border-color: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35), inset 0 0 12px rgba(255, 255, 255, 0.15); }
.slot.picked { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
#heldName { position: absolute; bottom: 84px; left: 50%; transform: translateX(-50%); font-weight: 800; font-size: 14px;
  text-shadow: 0 1px 2px #000; opacity: 0; transition: opacity 0.3s; }

#rightButtons { position: absolute; right: 12px; bottom: 14px; display: flex; gap: 8px; align-items: flex-end; }
.big-btn { width: 76px; height: 76px; border-radius: 12px; background: var(--panel); border: 2px solid rgba(255, 255, 255, 0.28); color: #fff;
  font-weight: 800; font-size: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.big-btn .ic { font-size: 26px; line-height: 1; }
.big-btn:hover { border-color: #fff; }
#btnLoot .ic { color: #a3e635; }
#lootValue { font-size: 13px; color: var(--gold); }

#chat { position: absolute; left: 12px; bottom: 14px; width: min(420px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 4px; }
#chatTabs { display: flex; gap: 4px; flex-wrap: wrap; }
.ctab { padding: 3px 9px; font-size: 12px; font-weight: 700; border-radius: 6px; background: rgba(0, 0, 0, 0.45); color: var(--muted);
  border: 1px solid var(--border); }
.ctab.active { background: rgba(74, 222, 128, 0.25); color: #fff; border-color: var(--accent); }
.ctab .badge { background: var(--red); color: #fff; border-radius: 8px; padding: 0 5px; margin-left: 4px; font-size: 10px; }
.ctab .x { margin-left: 6px; opacity: 0.6; }
#chatLog { height: 190px; overflow-y: auto; background: rgba(0, 0, 0, 0.35); border-radius: 8px; padding: 6px 8px; font-size: 13px;
  line-height: 1.35; scrollbar-width: thin; }
#chat:not(.active) #chatLog { background: transparent; scrollbar-width: none; mask-image: linear-gradient(transparent, #000 30%); }
#chat:not(.active) #chatLog::-webkit-scrollbar { display: none; }
.msg { text-shadow: 0 1px 1px #000, 0 0 2px #000; word-wrap: break-word; white-space: pre-wrap; }
.msg .who { font-weight: 800; cursor: pointer; }
.msg .who:hover { text-decoration: underline; }
.msg.system { color: #fde68a; }
.msg.join { color: #9ca3af; font-style: italic; }
.msg.kill { color: #fca5a5; }
.msg.admin { color: #f472b6; }
.msg.broadcast { color: #fbbf24; font-weight: 800; }
.msg.reward { color: #86efac; font-weight: 700; }
.msg.pm { color: #c4b5fd; }
.role-admin { color: #f87171; }
.role-moderator { color: #60a5fa; }
#chatInput { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: rgba(0, 0, 0, 0.6); color: #fff;
  font-size: 14px; outline: none; opacity: 0.55; }
#chat.active #chatInput { opacity: 1; border-color: var(--accent); }

#toasts { position: absolute; top: 90px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { background: rgba(0, 0, 0, 0.6); padding: 6px 14px; border-radius: 8px; font-weight: 800; color: var(--gold); animation: toast 2.6s forwards; }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 10%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#hurt { position: absolute; inset: 0; box-shadow: inset 0 0 120px rgba(220, 0, 0, 0.8); opacity: 0; transition: opacity 0.4s; }
#hurt.on { opacity: 1; transition: none; }
#clickToPlay { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.6); padding: 10px 20px;
  border-radius: 10px; font-weight: 800; }
#safeZone { position: absolute; top: 50px; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 800; color: #86efac;
  background: rgba(0, 0, 0, 0.45); padding: 3px 10px; border-radius: 6px; }

/* ---------- Fenster ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; z-index: 30; }
.window { background: var(--panel-solid); border: 2px solid var(--border); border-radius: 14px; width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.window.wide { width: min(900px, calc(100vw - 32px)); }
.win-head { padding: 12px 16px; font-weight: 800; font-size: 17px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.win-head .close { margin-left: auto; background: none; border: none; color: #fff; font-size: 18px; }
.win-body { padding: 14px 16px; overflow-y: auto; overflow-x: hidden; }
.sub { font-weight: 800; font-size: 13px; color: var(--muted); margin: 8px 0 6px; }
.inv-layout { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; }
@media (max-width: 860px) { .inv-layout { grid-template-columns: minmax(0, 1fr); } }
.recipe .rname { min-width: 0; overflow-wrap: anywhere; }
.slot-grid { display: grid; grid-template-columns: repeat(8, 54px); gap: 5px; }
.slot-grid .slot { cursor: pointer; }
@media (max-width: 520px) { .slot-grid { grid-template-columns: repeat(6, 46px); } .slot-grid .slot { width: 46px; height: 46px; } }
.recipe { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); margin-bottom: 5px; }
.recipe img { width: 28px; height: 28px; image-rendering: pixelated; }
.recipe .rname { font-weight: 700; font-size: 13px; flex: 1; }
.recipe .need { font-size: 11px; color: var(--muted); }
.recipe .need .miss { color: #fca5a5; }
.recipe button { padding: 5px 10px; font-size: 12px; box-shadow: 0 3px 0 #0f5f2c; }
.shop-money { font-size: 14px; color: var(--gold); }
#shopGrid, #gemSkinGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.shop-item { background: rgba(255, 255, 255, 0.05); border: 2px solid var(--border); border-radius: 12px; padding: 10px; text-align: center; }
.shop-item canvas { width: 96px; height: 120px; image-rendering: pixelated; }
.shop-item .iname { font-weight: 800; font-size: 14px; margin: 4px 0; }
.shop-item .rar { font-size: 11px; text-transform: uppercase; font-weight: 800; letter-spacing: 1px; }
.rar.common { color: #d1d5db; } .rar.uncommon { color: #4ade80; } .rar.rare { color: #60a5fa; } .rar.epic { color: #c084fc; } .rar.legendary { color: #fbbf24; }
.shop-item.legendary { border-color: #fbbf24; } .shop-item.epic { border-color: #c084fc; } .shop-item.rare { border-color: #60a5fa; }
.shop-item .btn { width: 100%; margin-top: 6px; font-size: 13px; padding: 7px; }
.shop-item.equipped { box-shadow: 0 0 0 2px var(--accent); }
#playersList .prow, #tabList .prow { display: flex; justify-content: space-between; padding: 6px 10px; border-radius: 6px; gap: 12px; }
#playersList .prow { cursor: pointer; }
#playersList .prow:hover { background: rgba(255, 255, 255, 0.08); }
#tabList { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 20; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px; min-width: 300px; max-height: 70vh; overflow-y: auto; pointer-events: none; }
#tabList h3 { margin: 0 0 6px; font-size: 14px; text-align: center; }
.death-box { text-align: center; background: rgba(60, 0, 0, 0.75); padding: 30px 40px; border-radius: 14px; border: 2px solid rgba(255, 100, 100, 0.4);
  max-width: calc(100vw - 32px); }
.death-box h2 { margin: 0 0 10px; font-size: 32px; color: #fca5a5; text-shadow: 0 3px 0 #000; }

@media (max-width: 760px) {
  #playerCard { width: 220px; transform: scale(0.9); transform-origin: top left; }
  #mapBox { transform: scale(0.7); transform-origin: top right; }
  #topButtons { right: 140px; }
  .slot { width: 40px; height: 40px; } .slot img { width: 28px; height: 28px; }
  #rightButtons { bottom: 80px; } .big-btn { width: 60px; height: 60px; }
  #chatLog { height: 120px; }
  #clock { top: 210px; }
}

/* ---------- Admin: Spieler-Profil ---------- */
.prof-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.prof-stats div { background: rgba(255, 255, 255, 0.05); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.prof-stats b { display: block; font-size: 15px; }
.prof-stats small { color: var(--muted); font-weight: 700; }
.prof-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.btn.danger { background: linear-gradient(180deg, #f87171, #b91c1c); box-shadow: 0 4px 0 #7f1d1d; }
.pbadge { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; margin-left: 4px; background: #374151; }
.pbadge.bot { background: #7c3aed; } .pbadge.guest { background: #6b7280; } .pbadge.admin { background: #b91c1c; }
.pbadge.dead { background: #111; } .pbadge.muted { background: #92400e; }
#profilePanel .slot.sel { border-color: var(--gold); }
#flyMode { position: absolute; top: 76px; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 800; color: #7dd3fc;
  background: rgba(0, 0, 0, 0.55); padding: 4px 12px; border-radius: 6px; }
.slot.drop { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.slot[draggable=true] { cursor: grab; }
.win-head { cursor: move; user-select: none; }
.win-head.dragging { cursor: grabbing; }
.win-head .close { cursor: pointer; }

/* ---------- Coins aufladen ---------- */
#coinGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 8px; }
.coin-card { position: relative; background: linear-gradient(180deg, rgba(250, 204, 21, 0.12), rgba(250, 204, 21, 0.03)); border: 2px solid rgba(250, 204, 21, 0.35);
  border-radius: 12px; padding: 12px 10px 10px; text-align: center; }
.coin-card .coin-ic { font-size: 30px; }
.coin-card .coin-n { font-weight: 900; font-size: 16px; color: var(--gold); }
.coin-card .coin-name { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.coin-card .btn { width: 100%; padding: 7px; font-size: 14px; }
.coin-badge { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); background: var(--red); color: #fff; font-size: 10px; font-weight: 800;
  padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--muted); margin: 4px 0 12px; line-height: 1.4; }
.consent input { margin-top: 2px; }
.pay-window { width: min(460px, calc(100vw - 24px)); height: min(760px, calc(100vh - 24px)); }
#payFrame { flex: 1; width: 100%; border: 0; background: #fff; border-radius: 0 0 4px 4px; }
.pay-foot { padding: 8px 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
.pay-foot a { color: #7dd3fc; }

/* ---------- Shop-Tabs ---------- */
.shop-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.shop-tab-btn { padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.06); color: var(--muted);
  font-weight: 800; font-size: 13px; }
.shop-tab-btn:hover { color: #fff; }
.shop-tab-btn.active { background: var(--accent-dark); border-color: var(--accent); color: #fff; }
#offerGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.offer-card { background: rgba(255, 255, 255, 0.05); border: 2px solid var(--border); border-radius: 12px; padding: 12px 10px; text-align: center; }
.offer-card img { width: 52px; height: 52px; image-rendering: pixelated; }
.offer-card .offer-name { font-weight: 800; font-size: 14px; margin-top: 4px; }
.offer-card .offer-amount { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.offer-card .btn { width: 100%; padding: 7px; font-size: 14px; }
.offer-card.gems { border-color: rgba(96, 200, 255, 0.45); }
.pay-thanks { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; padding: 14px 16px; border-radius: 12px;
  background: rgba(34, 197, 94, 0.15); border: 2px solid #22c55e; text-align: center; }
.pay-thanks b { font-size: 17px; color: #bbf7d0; }
.pay-thanks span { font-size: 13px; color: var(--muted); }

/* ---------- Items fallen lassen ---------- */
.drop-zone { margin-top: 12px; padding: 12px; border: 2px dashed rgba(248, 113, 113, 0.5); border-radius: 10px; text-align: center;
  font-size: 13px; color: var(--muted); cursor: pointer; }
.drop-zone.over, .drop-zone:hover { border-color: #f87171; color: #fecaca; background: rgba(248, 113, 113, 0.1); }
/* Mülleimer: Item hierher ziehen = für immer weg */
.inv-bottom { display: flex; gap: 10px; align-items: stretch; }
.inv-bottom .drop-zone { flex: 1; margin-top: 12px; }
.trash-slot { margin-top: 12px; align-self: flex-end; font-size: 26px; line-height: 1; cursor: pointer;
  border-style: dashed; border-color: rgba(248, 113, 113, 0.5); }
.trash-slot.over, .trash-slot:hover { border-style: solid; border-color: #f87171; background: rgba(248, 113, 113, 0.18); }
.confirm-overlay { z-index: 60; }
.confirm-window { width: min(500px, calc(100vw - 32px)); }
.confirm-item { display: flex; gap: 14px; align-items: center; }
.confirm-item img { width: 56px; height: 56px; image-rendering: pixelated; flex-shrink: 0; }
.ask-icon { width: 56px; height: 56px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 34px; }
.ask-icon img { width: 48px; height: 48px; image-rendering: pixelated; }
.confirm-item b { font-size: 16px; }
.confirm-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 16px; }

/* ---------- Spieler-Menü & Handeln ---------- */
.player-menu { position: fixed; z-index: 70; min-width: 190px; background: var(--panel-solid); border: 2px solid var(--border); border-radius: 12px;
  padding: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); display: flex; flex-direction: column; gap: 2px; }
.player-menu-head { padding: 6px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 14px; }
.player-menu button { text-align: left; padding: 9px 12px; border: 0; border-radius: 8px; background: transparent; color: #fff; font-weight: 800;
  font-size: 14px; cursor: pointer; }
.player-menu button:hover { background: rgba(255, 255, 255, 0.1); }
.player-menu button.muted { color: var(--muted); font-weight: 600; }
#tradeInvites { position: fixed; top: 140px; left: 50%; transform: translateX(-50%); z-index: 65; display: flex; flex-direction: column; gap: 8px; }
.trade-invite { background: var(--panel-solid); border: 2px solid var(--accent); border-radius: 12px; padding: 12px 16px; text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); min-width: 260px; }
.trade-invite small { display: block; color: var(--muted); margin-top: 2px; }
.trade-invite-btns { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.trade-invite-btns .btn { margin-top: 0; }
.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 8px; }
.trade-side { background: rgba(0, 0, 0, 0.2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.trade-grid { grid-template-columns: repeat(3, 54px); justify-content: center; }
.trade-gems { display: block; margin-top: 10px; font-size: 13px; font-weight: 700; }
.trade-gems input { width: 90px; margin-left: 6px; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border); background: rgba(0, 0, 0, 0.35); color: #fff; font-weight: 700; }
.trade-ok { color: #4ade80; font-weight: 800; }
.trade-btns { display: flex; gap: 10px; justify-content: flex-end; }
.trade-btns .btn { margin-top: 0; }
@media (max-width: 860px) { .trade-cols { grid-template-columns: 1fr; } }


/* ---------- Weltkarte (M) ---------- */
.map-window { width: min(1100px, calc(100vw - 32px)); height: min(820px, calc(100vh - 32px)); display: flex; flex-direction: column; }
.map-wrap { position: relative; flex: 1; min-height: 0; }
#bigMap { width: 100%; height: 100%; display: block; cursor: grab; border-radius: 0 0 12px 12px; }
#bigMap.dragging { cursor: grabbing; }
.map-loading { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.6); padding: 6px 12px;
  border-radius: 8px; font-size: 13px; }
.map-tools { position: absolute; right: 12px; top: 40px; display: flex; flex-direction: column; gap: 6px; }
.map-tools .btn { margin-top: 0; min-width: 44px; }
.map-legend { position: absolute; left: 12px; bottom: 12px; background: rgba(0, 0, 0, 0.6); border-radius: 10px; padding: 8px 12px;
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 12px; max-width: calc(100% - 24px); }
.map-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; border: 1px solid #000; }
.map-legend small { color: var(--muted); }

/* ---------- Einstellungen: Tabs & Hilfe ---------- */
.set-tabs { margin-bottom: 16px; }
.set-page.help { max-height: min(60vh, 560px); overflow-y: auto; padding-right: 4px; }
.help-group { margin-bottom: 14px; }
.help-group h4 { margin: 0 0 6px; font-size: 14px; }
.help-row { display: grid; grid-template-columns: minmax(150px, 40%) 1fr; gap: 10px; padding: 6px 8px; border-radius: 8px; font-size: 13px; align-items: center; }
.help-row:nth-child(even) { background: rgba(255, 255, 255, 0.04); }
.help-row span:last-child { color: var(--muted); }
kbd { display: inline-block; min-width: 22px; padding: 2px 7px; margin: 1px 2px; border-radius: 6px; background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25); border-bottom-width: 3px; font-weight: 700; font-size: 12px; text-align: center; color: #fff; }
#leaveBtn { margin-top: 14px; }

/* ================= Handy & Tablet (Touch) ================= */
#joyBase, #joyHint, #touchBtns, #touchTop, #rotateHint { display: none; }
body.touch { touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.touch #game { touch-action: none; }
body.touch .window, body.touch .win-body, body.touch #chatLog { touch-action: pan-y; }
body.touch #clickToPlay { display: none !important; }

/* Joystick */
body.touch #joyBase { display: block; position: fixed; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12); border: 2px solid rgba(255, 255, 255, 0.35); pointer-events: none; z-index: 12; }
body.touch #joyBase.hidden { display: none; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.55); border: 2px solid rgba(255, 255, 255, 0.8); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); }
body.touch #joyHint { display: block; position: absolute; left: max(24px, env(safe-area-inset-left)); bottom: 110px; width: 120px; height: 120px;
  border-radius: 50%; border: 2px dashed rgba(255, 255, 255, 0.35); color: rgba(255, 255, 255, 0.75); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; text-align: center; }
body.touch #joyHint.hidden { display: none; }

/* Aktions-Knöpfe rechts */
body.touch #touchBtns { display: grid; position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: 96px; pointer-events: auto;
  grid-template-columns: 64px 84px; grid-template-rows: 64px 84px; gap: 10px; align-items: center; justify-items: center; }
.touch-btn { width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.45); background: rgba(15, 23, 42, 0.55);
  color: #fff; font-size: 26px; touch-action: none; -webkit-tap-highlight-color: transparent; }
.touch-btn.big { width: 84px; height: 84px; font-size: 34px; }
.touch-btn.on { background: rgba(34, 197, 94, 0.55); border-color: #86efac; transform: scale(0.94); }
.touch-btn.hidden { display: none; }
#tbUse { grid-column: 1; grid-row: 2; }
#tbAttack { grid-column: 2; grid-row: 2; }
#tbJump { grid-column: 2; grid-row: 1; }
#tbDown { grid-column: 1; grid-row: 1; }

/* obere Knöpfe */
body.touch #touchTop { display: flex; position: absolute; top: 12px; right: 150px; gap: 6px; pointer-events: auto; }
body.touch #touchTop .hidden { display: none; }
body.touch #topButtons { right: calc(150px + 4 * 44px); }

/* HUD kompakter */
body.touch #rightButtons { top: 60px; bottom: auto; right: 150px; flex-direction: row; }
body.touch .big-btn { width: 54px; height: 54px; font-size: 10px; border-radius: 12px; }
body.touch .big-btn .ic { font-size: 20px; }
body.touch .big-btn small { display: none; }
body.touch #mapBox { transform: scale(0.72); transform-origin: top right; }
body.touch #chat { left: 12px; top: 96px; bottom: auto; width: min(340px, 42vw); }
body.touch #chatLog { height: 90px; font-size: 12px; }
body.touch #chat:not(.active) #chatInput { display: none; }
body.touch #chat.active { z-index: 40; }
body.touch #chat.active #chatLog { height: 150px; }
body.touch #hotbar { bottom: max(8px, env(safe-area-inset-bottom)); }
body.touch #hotbar .slot { width: 46px; height: 46px; }
body.touch #hotbar .slot img { width: 32px; height: 32px; }
body.touch #heldName { bottom: 70px; }
body.touch #playerCard { transform: scale(0.85); transform-origin: top left; }
body.touch #toasts { top: 60px; }
body.touch .drop-zone { padding: 16px; }
body.touch .win-head { cursor: default; }

/* Hochformat-Hinweis */
body.touch #rotateHint { display: block; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(15, 23, 42, 0.92);
  border: 2px solid var(--accent); padding: 14px 18px; border-radius: 14px; font-weight: 800; text-align: center; width: min(320px, 86vw); z-index: 50; }
body.touch #rotateHint.hidden { display: none; }

/* Kleine Handys quer (z.B. 740×360) */
@media (max-height: 430px) {
  body.touch #playerCard { transform: scale(0.72); }
  body.touch #chat { top: 74px; }
  body.touch #chatLog { height: 64px; }
  body.touch #touchBtns { bottom: 70px; grid-template-columns: 56px 74px; grid-template-rows: 56px 74px; }
  body.touch .touch-btn { width: 56px; height: 56px; font-size: 22px; }
  body.touch .touch-btn.big { width: 74px; height: 74px; font-size: 30px; }
  body.touch #joyHint { bottom: 76px; width: 100px; height: 100px; }
  body.touch #hotbar .slot { width: 40px; height: 40px; }
  body.touch #hotbar .slot img { width: 28px; height: 28px; }
  body.touch .window { max-height: calc(100vh - 16px); }
}

/* Chat: Griff zum Größe-Ändern (nur sichtbar, wenn der Chat offen ist) */
#chatResize { position: absolute; top: -6px; right: -6px; width: 26px; height: 26px; border-radius: 8px; display: none; align-items: center;
  justify-content: center; background: var(--accent-dark); border: 2px solid var(--accent); color: #fff; font-size: 15px; font-weight: 900;
  cursor: nesw-resize; touch-action: none; z-index: 2; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }
#chat.active #chatResize, #chatResize:active { display: flex; }
body.touch #chatResize { top: auto; bottom: -6px; cursor: nwse-resize; }

/* Hinweis: als App installieren (nur Handy) */
.app-hint { position: relative; margin-top: 14px; padding: 12px 34px 12px 14px; border-radius: 12px; background: rgba(34, 197, 94, 0.12);
  border: 2px solid rgba(34, 197, 94, 0.55); font-size: 13px; line-height: 1.45; text-align: left; }
.app-hint > b { display: block; font-size: 14px; margin-bottom: 4px; color: #bbf7d0; }
.app-hint .btn { margin: 6px 0; }
.app-hint-close { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border: 0; border-radius: 6px; background: rgba(255, 255, 255, 0.1);
  color: #fff; font-size: 13px; }
.ios-share { display: inline-block; padding: 0 5px; border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 5px; font-size: 11px; }
.app-hint { margin: 0 0 14px; }
/* Login auf Handys im Querformat: kompakter */
@media (max-height: 500px) {
  .login-box { padding: 14px 18px; }
  .logo { font-size: 30px; }
  .logo span { display: inline; }
  .logo-sub { margin: 2px 0 10px; font-size: 11px; }
  .controls-help { display: none; }
}

/* Handy: Karte rechts, links bleibt der Joystick frei (man kann mit offener Karte laufen) */
body.touch #mapPanel { justify-content: flex-end; background: transparent; pointer-events: none; }
body.touch #mapPanel .window { pointer-events: auto; width: 56vw; height: calc(100vh - 16px); margin-right: 8px; transform: none !important; }
body.touch #mapPanel .map-legend small { display: none; }

/* Handy: Joystick fest unten links, Knöpfe unten rechts, Hotbar dazwischen */
body.touch #joyBase { display: block; position: absolute; left: max(22px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom));
  top: auto; margin: 0; width: 130px; height: 130px; }
body.touch #joyBase.on { background: rgba(255, 255, 255, 0.2); border-color: rgba(255, 255, 255, 0.6); }
body.touch #touchBtns { bottom: max(14px, env(safe-area-inset-bottom)); right: max(16px, env(safe-area-inset-right)); }
body.touch #hotbar .slot { width: 42px; height: 42px; }
body.touch #hotbar .slot img { width: 30px; height: 30px; }
body.touch #hotbar { gap: 3px; padding: 4px; }
@media (max-height: 430px) {
  body.touch #joyBase { width: 112px; height: 112px; left: max(16px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); }
  body.touch #touchBtns { bottom: max(10px, env(safe-area-inset-bottom)); }
  body.touch #hotbar .slot { width: 38px; height: 38px; }
  body.touch #hotbar .slot img { width: 26px; height: 26px; }
}
/* Handy: Uhr unter die Minimap statt mitten ins Bild */
body.touch #clock { top: 168px; left: auto; right: 12px; transform: none; }
@media (max-height: 430px) { body.touch #clock { top: 158px; padding: 3px 8px; font-size: 12px; } }

body.touch #clock { top: 16px; left: 252px; right: auto; transform: none; }
@media (max-height: 430px) { body.touch #clock { top: 12px; left: 214px; } }

/* Karte: Finger bewegen nur die Karte, nie die Kamera */
#bigMap { touch-action: none; }
/* Minimap antippen/anklicken = große Karte öffnen (fängt die Berührung ab, Kamera bleibt stehen) */
#minimap { pointer-events: auto; cursor: pointer; touch-action: none; }

/* Hotbar-Felder anklickbar/antippbar machen (lagen vorher "unter" dem Spielfeld) */
#hotbar .slot { pointer-events: auto; }

/* Handelsfenster: zwei Angebote nebeneinander, je 3x3, darunter Diamanten und "Handeln" */
#tradePanel .window { width: min(620px, calc(100vw - 24px)); }
.trade-cols { gap: 14px; }
.trade-side { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px; }
.trade-name { width: 100%; text-align: center; font-weight: 800; font-size: 14px; padding: 7px 8px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trade-gems { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0; font-size: 14px; font-weight: 800; }
.trade-gems input { width: 92px; text-align: right; }
.trade-gems small { color: var(--muted); font-weight: 600; }
.btn.trade-go { width: 100%; margin-top: 0; padding: 10px; font-size: 15px; background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border); box-shadow: none; color: #fff; }
.btn.trade-go.on { background: var(--accent-dark); border-color: var(--accent); }
.btn.trade-go:disabled { opacity: 1; }
#tradeInv { justify-content: center; }
#tradePanel .trade-btns { justify-content: center; margin-top: 12px; }
#tradeInfo { text-align: center; margin: 10px 0 4px; }
@media (max-width: 520px) { .trade-grid { grid-template-columns: repeat(3, 46px); } }
.trade-gems { min-height: 38px; }
.trade-side { justify-content: space-between; }

/* Handelsfenster kompakter: kleinere Felder, weniger Rand */
#tradePanel .window { width: min(505px, calc(100vw - 20px)); }
#tradePanel .win-body { padding: 12px; }
#tradePanel .trade-grid { grid-template-columns: repeat(3, 54px); gap: 5px; }
#tradeInv { grid-template-columns: repeat(8, 54px); gap: 5px; }
#tradePanel .trade-cols { gap: 10px; margin-bottom: 4px; }
#tradePanel .trade-side { padding: 8px; gap: 7px; }
#tradePanel .trade-name { padding: 5px 6px; font-size: 13px; }
#tradePanel .btn.trade-go { padding: 7px; font-size: 14px; }
#tradePanel .trade-gems { min-height: 30px; font-size: 13px; }
#tradePanel .trade-gems input { width: 72px; padding: 5px 6px; }
#tradePanel #tradeInfo { font-size: 12px; margin: 6px 0 2px; }
#tradePanel .sub { margin: 8px 0 5px; font-size: 12px; }
#tradePanel .sub small { font-weight: 600; }
#tradePanel .trade-btns { margin-top: 10px; }
/* schmale Handys: gleiche Größe wie im Inventar (46px) */
@media (max-width: 520px) {
  #tradePanel .trade-grid { grid-template-columns: repeat(3, 46px); }
  #tradeInv { grid-template-columns: repeat(8, 46px); }
}

/* Chat-Griff: Pfeil zeigt in die Richtung, in die man ziehen kann */
#chatResize::after { content: '⤢'; font-size: 15px; line-height: 1; }        /* PC: Griff oben rechts -> nach oben rechts ziehen */
body.touch #chatResize::after { content: '⤡'; }                               /* Handy: Griff unten rechts -> nach unten rechts ziehen */

/* ---------- Seitenfenster: Statistik / Clan / Freunde (U) ---------- */
.side-panel { position: fixed; left: 0; top: 0; bottom: 0; width: min(420px, 92vw); z-index: 35; display: flex; flex-direction: column;
  background: var(--panel-solid); border-right: 2px solid var(--border); box-shadow: 8px 0 30px rgba(0, 0, 0, 0.45); }
.side-panel.hidden { display: none; }
.side-head { display: flex; align-items: flex-start; gap: 8px; padding: 12px 10px 0 12px; border-bottom: 1px solid var(--border); }
.side-head .shop-tabs { flex: 1; margin-bottom: 10px; }
.side-head .shop-tab-btn { padding: 7px 10px; font-size: 12px; }
.side-head .close { margin-left: auto; }
.side-body { padding: 14px 12px; overflow-y: auto; flex: 1; }
.stat-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.stat-head canvas { border-radius: 8px; background: rgba(0, 0, 0, 0.3); }
.stat-head b { font-size: 18px; }
#socialXp { margin-bottom: 14px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-grid div { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.stat-grid small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-grid b { font-size: 17px; }
.friend-row { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: 13px; }
.friend-row .fname { font-weight: 800; }
.friend-row .facts { margin-left: auto; display: flex; gap: 6px; }
.friend-row .btn { margin-top: 0; padding: 5px 9px; font-size: 12px; }
.fdot { width: 9px; height: 9px; border-radius: 50%; background: #6b7280; flex: 0 0 9px; }
.fdot.on { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
body.touch .side-panel { width: min(360px, 60vw); }

/* ---------- Mystery Box: Gewinn-Anzeige ---------- */
#boxWin { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); z-index: 45; pointer-events: none; }
#boxWin.hidden { display: none; }
.box-card { background: rgba(15, 23, 42, 0.92); border: 3px solid #64748b; border-radius: 16px; padding: 16px 26px; text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6); min-width: 230px; }
.box-card img { width: 72px; height: 72px; image-rendering: pixelated; margin: 6px 0; }
.box-title { font-size: 13px; color: var(--muted); font-weight: 800; letter-spacing: 1px; }
.box-name { font-size: 20px; font-weight: 900; }
.box-rarity { font-size: 13px; font-weight: 800; letter-spacing: 1px; margin-top: 2px; }
.box-card.common { border-color: #94a3b8; } .box-card.common .box-rarity { color: #cbd5e1; }
.box-card.rare { border-color: #38bdf8; box-shadow: 0 0 30px rgba(56, 189, 248, 0.45); } .box-card.rare .box-rarity { color: #7dd3fc; }
.box-card.epic { border-color: #c084fc; box-shadow: 0 0 34px rgba(192, 132, 252, 0.5); } .box-card.epic .box-rarity { color: #d8b4fe; }
.box-card.legendary { border-color: #facc15; box-shadow: 0 0 44px rgba(250, 204, 21, 0.65); } .box-card.legendary .box-rarity { color: #fde047; }
.box-card.pop { animation: boxpop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes boxpop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
/* mehrere Gewinne aus einer Truhe untereinander */
#boxItems { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 6px; }
.box-item { display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, 0.06); border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px; padding: 6px 12px; font-weight: 800; font-size: 16px; }
.box-item img { width: 40px; height: 40px; image-rendering: pixelated; }
.box-item.rare { border-color: #38bdf8; } .box-item.epic { border-color: #c084fc; }
.box-item.legendary { border-color: #facc15; box-shadow: 0 0 16px rgba(250, 204, 21, 0.5); }
.box-card .box-name { font-size: 13px; color: var(--muted); font-weight: 700; }

/* ---------- Clan ---------- */
.clan-create, .clan-invite { background: rgba(255, 255, 255, 0.05); border: 2px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.clan-create b, .clan-invite b { display: block; font-size: 15px; margin-bottom: 4px; }
.clan-create input, .clan-invite-form input { width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35); color: #fff; font-weight: 700; margin: 6px 0; }
.clan-create .btn { width: 100%; }
.clan-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.clan-name { font-size: 22px; color: #fde047; text-decoration: underline; text-underline-offset: 4px; }
.clan-invite-form { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.clan-invite-form .btn { margin-top: 0; white-space: nowrap; }
.clan-members { margin-bottom: 10px; }
.clan-leader { color: #fde047; text-decoration: underline; text-underline-offset: 3px; }
.clan-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.clan-actions .btn { margin-top: 0; }
