:root { --bg:#12141c; --panel:#1c2030; --line:#2c3250; --fg:#e8ebf5; --muted:#8b93b0; --accent:#6c8cff; }
* { box-sizing: border-box; }
body { margin:0; background:var(--bg); color:var(--fg); font:16px/1.4 system-ui, Segoe UI, sans-serif; }
header { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; padding:14px 20px; border-bottom:1px solid var(--line); }
h1 { font-size:20px; margin:0; }
h2 { font-size:16px; margin:0 0 10px; }
.name { color:var(--muted); font-size:14px; }
input, button { font:inherit; color:var(--fg); background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:8px 12px; }
button { cursor:pointer; }
button:hover:not(:disabled) { border-color:var(--accent); }
button:disabled { opacity:.45; cursor:default; }
button.primary { background:var(--accent); border-color:var(--accent); color:#fff; font-weight:600; }
.screen { max-width:960px; margin:0 auto; padding:20px; }
[hidden] { display:none !important; }
section { background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:16px; margin-bottom:16px; }
.muted { color:var(--muted); font-size:14px; font-weight:400; }
.cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(250px,1fr)); gap:12px; }
.card { text-align:left; background:var(--bg); border-radius:10px; padding:14px; }
.card b { display:block; font-size:17px; margin-bottom:4px; }
.card span { color:var(--muted); font-size:13px; display:block; }
.card em { color:var(--accent); font-style:normal; font-size:13px; }
.rooms .room { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:10px 0; border-top:1px solid var(--line); }
.rooms .room:first-child { border-top:0; }
.row { display:flex; gap:8px; flex-wrap:wrap; }
.players { list-style:none; padding:0; margin:12px 0; display:grid; gap:6px; }
.players li { display:flex; align-items:center; gap:8px; padding:8px 10px; background:var(--bg); border-radius:8px; }
.dot { width:14px; height:14px; border-radius:50%; flex:none; }
.gamebar { display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:8px; }
.chips { display:flex; gap:6px; flex-wrap:wrap; }
.chip { display:flex; align-items:center; gap:6px; background:var(--panel); border:1px solid var(--line); border-radius:99px; padding:3px 10px; font-size:14px; }
.chip.me { border-color:var(--accent); }
.status { min-height:26px; font-weight:600; margin-bottom:8px; }
.stage { display:flex; gap:12px; align-items:flex-start; justify-content:center; flex-wrap:wrap; }
.stage canvas { max-width:100%; height:auto; background:#0b0d14; border:1px solid var(--line); border-radius:10px; touch-action:none; }
.side { width:240px; display:flex; flex-direction:column; gap:8px; }
.chat { height:300px; overflow:auto; background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:8px; font-size:14px; }
.chat div { padding:2px 0; word-break:break-word; }
.chat .sys { color:#7fe3a0; }
.palette { display:flex; gap:6px; flex-wrap:wrap; }
.palette button { width:28px; height:28px; padding:0; border-radius:50%; }
.palette button.sel { outline:2px solid #fff; }
#help { margin-top:10px; text-align:center; }

/* ---------- Politur ---------- */
body { background: radial-gradient(1200px 600px at 50% -10%, #1d2447 0%, var(--bg) 60%) fixed; }
header { background: rgba(20,24,40,.7); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 5; }
h1 { background: linear-gradient(90deg,#8fb0ff,#c58bff); -webkit-background-clip: text; background-clip: text; color: transparent; letter-spacing: .5px; }
section { box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.card { transition: transform .12s, border-color .12s, box-shadow .12s; }
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(108,140,255,.25); }
.stage canvas { box-shadow: 0 0 0 1px #2c3250, 0 10px 40px rgba(0,0,0,.55), 0 0 60px rgba(108,140,255,.12); }
.status { text-align: center; font-size: 18px; }
.board { width: 240px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.board h3 { margin: 0 0 4px; font-size: 14px; color: var(--muted); display: flex; justify-content: space-between; }
.board h3 span { color: #fff; }
.brow { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 9px; background: var(--bg); border-left: 4px solid var(--c); }
.brow.me { background: #252c4a; outline: 1px solid var(--c); }
.brow.dim { opacity: .45; }
.brow img { width: 34px; height: 34px; image-rendering: pixelated; flex: none; }
.brow .dot { background: var(--c); }
.bname { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bname small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.bscore { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
#s-game { max-width: 1280px; }
.stage canvas { flex: 0 1 auto; }

/* ---------- Overlays & Hintergrund ---------- */
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; }
body { background: #0b0e1d; }
section { background: rgba(24,28,48,.78); backdrop-filter: blur(8px); }
.board, .chat, .chip { backdrop-filter: blur(6px); }

.offline { position: fixed; inset: 0; z-index: 100; max-width: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: rgba(8,10,22,.88); backdrop-filter: blur(8px); }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 4px solid rgba(255,255,255,.12); border-top-color: #8fb0ff; border-right-color: #c58bff; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Spielkarten */
.card { position: relative; overflow: hidden; border: 1px solid color-mix(in srgb, var(--gc, #6c8cff) 55%, transparent); background: linear-gradient(135deg, color-mix(in srgb, var(--gc, #6c8cff) 22%, #12162a), #12162a 70%); }
.card::after { content: ''; position: absolute; inset: 0; background: radial-gradient(220px 120px at 100% 0%, color-mix(in srgb, var(--gc) 35%, transparent), transparent); opacity: .6; pointer-events: none; }
.card .ic { font-size: 34px; display: block; margin-bottom: 6px; filter: drop-shadow(0 0 10px var(--gc)); }
.card:hover { border-color: var(--gc); box-shadow: 0 8px 28px color-mix(in srgb, var(--gc) 40%, transparent); }

/* Intro beim Spielstart */
#intro { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; pointer-events: none; background: radial-gradient(circle at 50% 45%, rgba(8,10,22,.55), rgba(8,10,22,.2)); animation: introOut .5s ease 3s forwards; }
.intro-card { text-align: center; padding: 26px 40px; border-radius: 20px; background: rgba(12,15,30,.78); border: 1px solid color-mix(in srgb, var(--gc) 60%, transparent); box-shadow: 0 0 60px color-mix(in srgb, var(--gc) 35%, transparent); animation: pop .45s cubic-bezier(.2,1.4,.4,1); max-width: 520px; }
#intro-icon { font-size: 56px; filter: drop-shadow(0 0 16px var(--gc)); }
#intro h2 { font-size: 32px; margin: 4px 0; text-shadow: 0 0 20px var(--gc); }
#intro p { color: #c9d0ee; margin: 6px 0 10px; }
#intro-count { font-size: 64px; font-weight: 900; line-height: 1; color: var(--gc); text-shadow: 0 0 24px var(--gc); }
@keyframes introOut { to { opacity: 0; visibility: hidden; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Ergebnis-Overlay */
#overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(6,8,18,.72); backdrop-filter: blur(6px); animation: fadeIn .35s ease; }
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ov-card { position: relative; text-align: center; min-width: min(92vw, 420px); max-width: 92vw; padding: 28px 34px; border-radius: 22px; background: linear-gradient(160deg, rgba(34,40,74,.96), rgba(16,19,38,.96)); border: 1px solid rgba(140,160,255,.4); box-shadow: 0 0 80px rgba(108,140,255,.3); animation: pop .5s cubic-bezier(.2,1.4,.4,1); }
.ov-card.win { border-color: #ffd34f; box-shadow: 0 0 90px rgba(255,211,79,.45); }
.ov-card.lose { border-color: #ff6b7a; box-shadow: 0 0 70px rgba(255,107,122,.3); }
#ov-icon { font-size: 64px; animation: bounce 1.2s ease-in-out infinite; }
#ov-title { font-size: 34px; margin: 6px 0 2px; letter-spacing: 1px; }
.win #ov-title { color: #ffd34f; text-shadow: 0 0 24px rgba(255,211,79,.7); }
.lose #ov-title { color: #ff8a96; }
#ov-sub { color: #aab3d6; margin: 0 0 14px; }
#ov-rank { list-style: none; counter-reset: r; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; text-align: left; }
#ov-rank li { counter-increment: r; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: rgba(255,255,255,.05); border-left: 4px solid var(--c); }
#ov-rank li::before { content: counter(r); font-weight: 800; width: 20px; color: var(--muted); }
#ov-rank li b { flex: 1; }
#ov-rank li.me { background: rgba(108,140,255,.18); }
.ov-card .row { justify-content: center; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes bounce { 50% { transform: translateY(-8px) scale(1.06); } }

/* Tower-Defense-Leiste */
.tdbar { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 10px 12px; background: rgba(24,28,48,.85); border: 1px solid var(--line); border-radius: 12px; width: 960px; max-width: 100%; }
.tdbar .gold { font-size: 20px; } .tdbar .gold small { color: var(--muted); font-size: 12px; }
.tdbar .grp { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tdbar button { text-align: left; line-height: 1.15; }
.tdbar button small { display: block; color: var(--muted); font-size: 11px; }
.tdbar button.on { border-color: #ffe14f; background: #3a3a1a; }
.tdbar button.dead { opacity: .45; }
.tdbar .sel { padding-left: 14px; border-left: 2px solid var(--line); }
