/* ==========================================================
   TheRoof – mobil zuerst
   ========================================================== */
:root {
    --night: #101a3d;
    --night-2: #1b2a5c;
    --glass: rgba(16, 26, 61, .78);
    --ink: #ffffff;
    --muted: #b9c3e6;
    --accent: #e0369a;
    --accent-2: #aa2299;
    --teal: #19a7bd;
    --radius: 16px;
    --crab: clamp(68px, 19vw, 112px);
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--ink);
    background: var(--night);
    -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
input { font-size: 16px; } /* verhindert Auto-Zoom auf iPhone */

.button {
    padding: 12px 22px;
    min-height: 48px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    font-weight: 700;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(224, 54, 154, .35);
    transition: transform .12s ease, filter .12s ease;
}
.button:active { transform: scale(.96); }
.button:disabled { filter: grayscale(.6) brightness(.8); cursor: default; }

.icon-btn {
    width: 48px; height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.14);
    font-size: 24px;
    cursor: pointer;
}
.icon-btn.small { width: 36px; height: 36px; font-size: 16px; }

.layer {
    position: absolute;
    inset: 0;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
}
.layer.tall { top: -35%; bottom: auto; height: 135%; }   /* Hüte: 175 von 500 Einheiten Platz nach oben */

/* ==========================================================
   STARTSEITE / BUILDER
   ========================================================== */
body.home {
    background: var(--night) url('pics/theRoof_BackdropDach.png') center bottom / cover no-repeat fixed;
}
body.home::before {       /* Abdunkeln, damit Text lesbar bleibt */
    content: "";
    position: fixed; inset: 0;
    background: linear-gradient(to bottom, rgba(16,26,61,.35), rgba(16,26,61,.85));
    pointer-events: none;
}

.builder-page {
    position: relative;
    max-width: 560px;
    margin: 0 auto;
    padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(150px + var(--safe-b)) calc(16px + var(--safe-l));
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.builder-head { text-align: center; padding-top: 44px; }
.builder-head h1 { margin: 8px 0 2px; font-size: clamp(26px, 7vw, 38px); text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.builder-head p  { margin: 0; color: var(--muted); }

.preview-card {
    position: relative;
    align-self: center;
    width: min(62vw, 240px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 60%, rgba(255,255,255,.18), rgba(255,255,255,.04) 70%);
}
.crab-preview { position: absolute; inset: 4%; }
.crab-preview.wiggle { animation: wiggle .45s ease; }
.preview-card .icon-btn { position: absolute; right: -4px; bottom: 4px; background: var(--glass); backdrop-filter: blur(6px); }

.login-card {
    display: flex; flex-direction: column; gap: 6px;
    background: var(--glass);
    backdrop-filter: blur(8px);
    border-radius: var(--radius);
    padding: 6px;
}
.name-field {
    display: flex; align-items: center; gap: 10px;
    padding-left: 10px;
}
.name-field span { color: var(--muted); white-space: nowrap; width: 3.6em; }
.field-hint { margin: 2px 10px 6px; font-size: 13px; color: var(--muted); }
.name-field input {
    flex: 1; min-width: 0;
    border: none; outline: none;
    background: rgba(255,255,255,.1);
    border-radius: 12px;
    padding: 12px;
}
.name-field input:focus { background: rgba(255,255,255,.18); }

.picker {
    background: var(--glass);
    backdrop-filter: blur(8px);
    border-radius: var(--radius);
    padding: 4px 0 10px;
}
.picker h2 { font-size: 14px; font-weight: 600; color: var(--muted); margin: 10px 16px 6px; text-transform: uppercase; letter-spacing: .06em; }

.options {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 16px 8px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}
.options::-webkit-scrollbar { display: none; }

.option {
    flex: 0 0 auto;
    width: 68px; height: 68px;
    border-radius: 14px;
    border: 3px solid transparent;
    background-color: rgba(255,255,255,.1);
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    cursor: pointer;
    scroll-snap-align: start;
    transition: transform .12s ease, border-color .12s ease;
}
/* Augen & Mund herangezoomt auf dem Körper zeigen */
.option-eyes  { background-size: 200%; background-position: 52% 0%; }
.option-mouth { background-size: 200%; background-position: 50% 58%; }
.option:active { transform: scale(.92); }
.option.selected { border-color: var(--accent); background-color: rgba(224,54,154,.22); }

.builder-actions {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    padding: 12px calc(16px + var(--safe-r)) calc(12px + var(--safe-b)) calc(16px + var(--safe-l));
    background: linear-gradient(to top, rgba(16,26,61,.98) 75%, rgba(16,26,61,0));
    padding-top: 28px;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.builder-actions .button { width: min(100%, 420px); font-size: 18px; }
#save-status { min-height: 1.2em; font-size: 14px; color: #ffd1e8; text-align: center; }

.wallet {
    align-self: center;
    padding: 8px 16px; border-radius: 999px;
    background: var(--glass); backdrop-filter: blur(8px);
}
.option { position: relative; }
.option.locked { filter: grayscale(.55) brightness(.8); }
.option.locked::after {
    content: "🔒 " attr(data-price);
    position: absolute; left: 50%; bottom: -2px; transform: translateX(-50%);
    padding: 1px 6px; border-radius: 999px;
    background: rgba(16,26,61,.9); color: #fff;
    font-size: 11px; font-weight: 700; white-space: nowrap;
}
.option.locked.selected { filter: none; }
.cost-line { font-size: 14px; text-align: center; color: #fff; }
.cost-line.too-much { color: #ffd1e8; }
.link-btn { border: none; background: none; color: #fff; text-decoration: underline; cursor: pointer; font-size: 14px; padding: 4px; }
.options { padding-bottom: 12px; }

@media (min-width: 900px) {
    .options { flex-wrap: wrap; overflow: visible; }
    .option:hover { transform: scale(1.08); border-color: rgba(255,255,255,.4); }
}

/* ==========================================================
   LOBBY
   ========================================================== */
body.lobby { height: 100dvh; overflow: hidden; overscroll-behavior: none; }

#stage {
    position: fixed; inset: 0;
    background: var(--night) url('pics/theRoof_BackdropDach.png') center bottom / cover no-repeat;
    touch-action: manipulation;
    user-select: none; -webkit-user-select: none;
    overflow: hidden;
    cursor: pointer;
}
#crabs { position: absolute; inset: 0; }

.crab {
    position: absolute;
    left: 0; top: 0;
    width: 0; height: 0;       /* Punkt = Füße der Krabbe */
    will-change: transform;
}
.crab-body {
    position: absolute;
    width: var(--crab); height: var(--crab);
    left: calc(var(--crab) / -2);
    top: calc(var(--crab) * -0.9);
    filter: drop-shadow(0 4px 3px rgba(0,0,0,.35));
}
.crab.walking .crab-body { animation: scuttle .28s ease-in-out infinite alternate; }
.crab-name {
    position: absolute;
    top: 4px; left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 12px; font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(0,0,0,.45);
}
.crab.me .crab-name { background: var(--accent); }

.bubble {
    position: absolute;
    bottom: calc(var(--crab) * 0.95);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: min(60vw, 220px);
    padding: 8px 12px;
    border-radius: 14px;
    background: #fff; color: #1b1b2e;
    font-size: 14px; line-height: 1.3;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    z-index: 5;
}
.bubble::after {
    content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -7px;
    border: 7px solid transparent; border-bottom: 0; border-top-color: #fff;
}
.bubble.pop { animation: pop .25s ease-out; }
.crab:has(.layer.tall) .bubble, .crab:has(.layer.tall) .emote-pop { bottom: calc(var(--crab) * 1.3); }

.tap-marker {
    position: absolute;
    width: 36px; height: 36px; margin: -18px 0 0 -18px;
    border: 3px solid rgba(255,255,255,.85);
    border-radius: 50%;
    pointer-events: none;
    animation: ripple .6s ease-out forwards;
}

.topbar {
    position: fixed;
    top: calc(10px + var(--safe-t)); left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r));
    display: flex; justify-content: space-between; align-items: center;
    pointer-events: none;
    z-index: 20;
}
.pill {
    pointer-events: auto;
    position: relative;
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 44px; padding: 0 16px;
    border-radius: 999px;
    border: none;
    background: var(--glass);
    backdrop-filter: blur(8px);
    color: #fff; text-decoration: none; font-weight: 600;
    cursor: pointer;
}
.badge {
    position: absolute; top: -4px; right: -4px;
    min-width: 22px; height: 22px; padding: 0 6px;
    border-radius: 11px;
    background: var(--accent);
    font-size: 12px; line-height: 22px; text-align: center;
}

.hint {
    position: fixed; left: 50%; top: calc(70px + var(--safe-t));
    transform: translateX(-50%);
    padding: 8px 14px; border-radius: 999px;
    background: var(--glass); color: var(--muted); font-size: 14px;
    pointer-events: none; z-index: 10;
    transition: opacity .5s;
}
.hint.gone { opacity: 0; }
body.chat-open .hint { display: none; }

/* ---------- Chat: auf dem Handy ein Panel von unten ---------- */
#chat {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: min(48dvh, 420px);
    display: flex; flex-direction: column;
    background: var(--glass);
    backdrop-filter: blur(12px);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -6px 24px rgba(0,0,0,.35);
    padding-bottom: var(--safe-b);
    transform: translateY(105%);
    transition: transform .25s ease;
    z-index: 30;
}
#chat.open { transform: none; }
/* Chat offen → Dach rückt nach oben, damit die Krabben sichtbar bleiben */
body.chat-open #stage { bottom: min(48dvh, 420px); }
#stage { transition: bottom .25s ease, right .25s ease; }

.chat-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px 6px 16px;
}
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 4px 12px;
    display: flex; flex-direction: column; gap: 6px;
    overscroll-behavior: contain;
}
.msg {
    align-self: flex-start;
    max-width: 85%;
    padding: 6px 10px;
    border-radius: 12px 12px 12px 4px;
    background: rgba(255,255,255,.12);
    overflow-wrap: anywhere;
}
.msg.mine { align-self: flex-end; background: rgba(224,54,154,.4); border-radius: 12px 12px 4px 12px; }
.msg-name { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
.msg.mine .msg-name { display: none; }

#chat-form {
    display: flex; gap: 8px;
    padding: 8px 12px 10px;
}
#chat-input {
    flex: 1; min-width: 0;
    border: none; outline: none;
    border-radius: 999px;
    padding: 12px 16px;
    background: rgba(255,255,255,.14);
}
#chat-send { padding: 0; width: 48px; font-size: 18px; }
.shake { animation: shake .35s; }
#chat-error { margin: 0 12px; padding: 8px 12px; border-radius: 12px; background: rgba(224,54,154,.35); font-size: 14px; }
#chat-error[hidden] { display: none; }

/* ---------- Benachrichtigungs-Panel ---------- */
.topbar-right { display: flex; gap: 8px; }
#push-toggle.on { background: var(--accent); }
.sheet {
    position: fixed;
    top: calc(64px + var(--safe-t));
    left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r));
    max-width: 380px; margin-left: auto;
    background: var(--night-2);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,.45);
    z-index: 40;
    animation: pop-in .2s ease-out;
}
.sheet[hidden] { display: none; }
.sheet-body { padding: 0 16px 16px; }
.sheet-body p { margin: 6px 0 12px; line-height: 1.4; }
.sheet-body .small { font-size: 13px; color: var(--muted); }
.push-status {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; margin: 4px 0 12px;
    border-radius: 14px;
    font-weight: 700;
    background: rgba(255,255,255,.08);
}
.push-status span { font-size: 20px; }
.push-status.on  { background: rgba(25,167,189,.25); }
.push-status.bad { background: rgba(224,54,154,.18); }
.sheet-label { margin: 16px 0 0 !important; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.steps { margin: 0 0 4px; padding-left: 22px; line-height: 1.7; }
.button.wide { width: 100%; }
.button.ghost { background: rgba(255,255,255,.12); box-shadow: none; }
.row { display: flex; gap: 8px; }
.row .button { flex: 1; padding: 10px 12px; }
.switch {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
    cursor: pointer;
}
.switch input {
    appearance: none; -webkit-appearance: none;
    flex: 0 0 auto;
    width: 46px; height: 28px; margin: 0;
    border-radius: 14px;
    background: rgba(255,255,255,.2);
    position: relative;
    transition: background .2s;
    cursor: pointer;
}
.switch input::after {
    content: ""; position: absolute; top: 3px; left: 3px;
    width: 22px; height: 22px; border-radius: 50%;
    background: #fff; transition: transform .2s;
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }
.invite {
    position: fixed;
    left: 50%; bottom: calc(20px + var(--safe-b));
    transform: translateX(-50%);
    width: min(92vw, 380px);
    padding: 18px 18px 16px;
    background: var(--night-2);
    border-radius: 22px;
    box-shadow: 0 12px 40px rgba(0,0,0,.55);
    text-align: center;
    z-index: 50;
    animation: rise .3s ease-out;
    display: flex; flex-direction: column; gap: 10px;
    max-height: calc(100dvh - 40px - var(--safe-b) - var(--safe-t));
    overflow-y: auto;
}
.invite strong { font-size: 18px; }
.invite p { margin: 0 0 4px; color: var(--muted); line-height: 1.4; }
.invite-icon { font-size: 34px; line-height: 1; }
.invite .row .button { font-size: 14px; }
.install-sheet { text-align: left; max-height: calc(100dvh - 40px - var(--safe-b) - var(--safe-t)); overflow-y: auto; }
.install-sheet > strong, .install-sheet > .invite-icon { text-align: center; }
.install-sheet .close { position: absolute; top: 10px; right: 10px; }
.invite .install-body { text-align: left; }
.invite .install-body .steps { color: var(--ink); }
.device-tag { margin: 0 0 6px !important; }
.steps .sym { display: inline-block; padding: 0 4px; border-radius: 6px; background: rgba(255,255,255,.12); }
.steps-more summary { cursor: pointer; color: var(--muted); font-size: 14px; margin: 8px 0 4px; }
.install-pill { position: absolute; top: calc(12px + var(--safe-t)); right: calc(12px + var(--safe-r)); z-index: 2; font-size: 14px; min-height: 38px; padding: 0 12px; }
#install-open { margin-top: 12px; }
.invite.toast { padding: 12px 16px; font-weight: 600; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Admin ---------- */
#admin-toggle { background: rgba(25,167,189,.55); }
#admin-panel .sheet-body { max-height: min(70dvh, 560px); overflow-y: auto; }
.button.danger, .mini-btn.danger { color: #ffb3d6; }
.button.confirm, .mini-btn.confirm, .msg-del.confirm { background: var(--accent) !important; color: #fff !important; }
.admin-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.admin-row {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px; border-radius: 14px;
    background: rgba(255,255,255,.06);
}
.admin-row.banned { opacity: .6; }
.mini-crab { position: relative; flex: 0 0 40px; width: 40px; height: 40px; }
.admin-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.mini-btn {
    border: none; cursor: pointer;
    padding: 8px 10px; min-height: 36px;
    border-radius: 999px;
    background: rgba(255,255,255,.12);
    font-size: 13px; font-weight: 600; white-space: nowrap;
}
.msg { position: relative; }
.msg-del {
    margin-left: 8px; border: none; cursor: pointer;
    background: rgba(0,0,0,.25); border-radius: 999px;
    font-size: 12px; padding: 2px 8px; vertical-align: middle;
}

/* ---------- admin.php ---------- */
body.admin-page { background: var(--night); min-height: 100dvh; }
.admin-wrap {
    max-width: 720px; margin: 0 auto;
    padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(24px + var(--safe-b)) calc(16px + var(--safe-l));
    display: flex; flex-direction: column; gap: 14px;
}
.admin-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.admin-head h1 { margin: 0; font-size: 24px; }
.card { background: var(--night-2); border-radius: 20px; padding: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 18px; }
.card-head .button { min-height: 40px; padding: 8px 14px; font-size: 14px; }
.login-box { display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.login-box input {
    border: none; outline: none; border-radius: 12px;
    padding: 12px 14px; background: rgba(255,255,255,.12);
}
.err { color: #ffb3d6; margin: 0; }
.msg-list { display: flex; flex-direction: column; gap: 6px; max-height: 50dvh; overflow-y: auto; }
.admin-msg {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
    padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.06);
    overflow-wrap: anywhere;
}
.admin-page .small { font-size: 13px; color: var(--muted); }
.admin-page textarea, .admin-page select {
    width: 100%; border: none; outline: none; border-radius: 12px; padding: 10px 12px;
    background: rgba(255,255,255,.12); font: inherit; color: inherit; resize: vertical;
}
.admin-page select { width: auto; }
.admin-page select option { color: #111; }
.ann-row { align-items: center; justify-content: space-between; margin: 8px 0; }
.small-switch { border: none; padding: 0; font-size: 14px; }
.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin: 6px 0 10px; }
.event-grid .mini-btn { white-space: normal; min-height: 44px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.kpis div { background: rgba(255,255,255,.06); border-radius: 12px; padding: 8px; text-align: center; display: flex; flex-direction: column; }
.kpis b { font-size: 22px; }
.kpis span { font-size: 12px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding-bottom: 18px; }
.bar { flex: 1; height: 100%; position: relative; display: flex; align-items: flex-end; }
.bar span { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars.hours .bar span { background: var(--teal); }
.bar em { position: absolute; bottom: calc(100% - 14px); left: 0; right: 0; text-align: center; font-size: 10px; font-style: normal; color: var(--muted); }
.bar i { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); font-size: 10px; font-style: normal; color: var(--muted); white-space: nowrap; }
.top-list { margin: 4px 0 0; padding-left: 22px; line-height: 1.6; }
.emote-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; min-height: 44px; align-items: center; }
.chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 4px 4px 10px; border-radius: 999px;
    background: rgba(224,54,154,.3); font-size: 22px;
}
.chip button { border: none; cursor: pointer; background: rgba(0,0,0,.25); border-radius: 50%; width: 26px; height: 26px; font-size: 12px; }
.emote-add { display: flex; gap: 8px; margin: 8px 0; }
.emote-add input { flex: 1; min-width: 0; border: none; outline: none; border-radius: 12px; padding: 10px 12px; background: rgba(255,255,255,.12); }
.emote-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin: 8px 0 12px; }
.pal { height: 44px; border: 2px solid transparent; border-radius: 12px; background: rgba(255,255,255,.08); font-size: 22px; cursor: pointer; }
.pal.on { border-color: var(--accent); background: rgba(224,54,154,.25); }

/* ---------- Spiel ---------- */
#shells { position: absolute; inset: 0; pointer-events: none; }
.shell {
    position: absolute;
    width: calc(var(--crab) * .55); height: calc(var(--crab) * .55);
    margin: calc(var(--crab) * -.275) 0 0 calc(var(--crab) * -.275);
    background: url('pics/shell.svg') center / contain no-repeat;
    filter: drop-shadow(0 3px 2px rgba(0,0,0,.35));
    animation: shell-in .5s ease-out, bob 2.4s ease-in-out .5s infinite;
    z-index: 1;
}
.shell.gold { background-image: url('pics/shell-gold.svg'); width: calc(var(--crab) * .65); height: calc(var(--crab) * .65);
    margin: calc(var(--crab) * -.325) 0 0 calc(var(--crab) * -.325);
    filter: drop-shadow(0 0 10px rgba(255,210,63,.9)); }
.shell.grab { transform: scale(1.3); }
.shell.gone { animation: shell-out .3s ease-in forwards; }
.floater {
    position: absolute; transform: translate(-50%, -50%);
    font-weight: 800; font-size: 18px; color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,.6);
    pointer-events: none; white-space: nowrap; z-index: 2000;
    animation: float-up 1.4s ease-out forwards;
}
.floater.gold { color: #ffe066; font-size: 22px; }
.confetti {
    position: absolute; width: 8px; height: 12px; border-radius: 2px;
    pointer-events: none; z-index: 2000;
    animation: confetti 1.1s ease-out forwards;
}
.emote-pop {
    position: absolute; left: 50%;
    bottom: calc(var(--crab) * 0.95);
    transform: translateX(-50%);
    font-size: calc(var(--crab) * .45);
    animation: emote 2.2s ease-out forwards;
    pointer-events: none; z-index: 6;
}
.crab-body { pointer-events: auto; }
.crab.dancing .crab-body { animation: dance .35s ease-in-out infinite alternate; }
.crab.pinching .crab-body { animation: pinch .35s ease-in-out 2; }
.crab.ouch .crab-body { animation: ouch .5s ease-out; }
#my-points { display: inline-block; }
#my-points.bump { animation: bump .4s ease-out; }
#score-pill .sep { opacity: .5; margin: 0 2px; }

#emote-bar {
    position: fixed;
    left: calc(12px + var(--safe-l)); bottom: calc(14px + var(--safe-b));
    display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
    z-index: 25;
}
@media (max-width: 899px) { body.chat-open #emote-bar { display: none; } }
.emote-toggle {
    width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
    font-size: 28px; background: var(--glass); backdrop-filter: blur(8px);
    box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.emote-list {
    display: flex; flex-wrap: wrap; gap: 6px; padding: 6px;
    max-width: calc(100vw - 40px - var(--safe-l) - var(--safe-r));
    background: var(--glass); backdrop-filter: blur(8px);
    border-radius: 28px; box-shadow: 0 4px 14px rgba(0,0,0,.35);
    animation: pop-in .15s ease-out;
}
.emote-list[hidden] { display: none; }
.emote-list button {
    width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
    font-size: 24px; background: rgba(255,255,255,.1);
}
.emote-list button:active { transform: scale(.9); }

.game-toast {
    position: fixed; left: 50%; top: calc(128px + var(--safe-t));
    transform: translateX(-50%);
    width: max-content; max-width: min(92vw, 380px);
    padding: 12px 16px; border-radius: 16px;
    background: var(--night-2); box-shadow: 0 10px 30px rgba(0,0,0,.5);
    text-align: center; line-height: 1.4; z-index: 60;
    animation: rise-top .3s ease-out;
    transition: opacity .4s, transform .4s;
}
.game-toast span { font-size: 13px; color: var(--muted); }
.game-toast.out { opacity: 0; transform: translate(-50%, -10px); }

.tabs { display: flex; gap: 6px; }
.tab {
    border: none; cursor: pointer; padding: 8px 12px; border-radius: 999px;
    background: rgba(255,255,255,.08); font-weight: 700; font-size: 14px;
}
.tab.active { background: var(--accent); }
#game-panel .sheet-body { max-height: min(70dvh, 560px); overflow-y: auto; }
.rank-me { text-align: center; font-size: 16px; }
.rank-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank-list li {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 10px; border-radius: 14px; background: rgba(255,255,255,.06);
}
.rank-list li.me { background: rgba(224,54,154,.3); }
.medal { width: 28px; text-align: center; font-size: 18px; font-weight: 700; }
.rank-name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-pts { font-weight: 800; }
.closet-preview { display: flex; flex-direction: column; align-items: center; padding-top: 36px; }
.rank-list .mini-crab:has(.layer.tall) { margin-top: 14px; }
.closet-preview p { margin: 4px 0 10px; }
.closet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 10px 6px; border-radius: 14px; background: rgba(255,255,255,.06);
    text-align: center;
}
.item.on { background: rgba(25,167,189,.3); outline: 2px solid var(--teal); }
.item.locked { opacity: .7; }
.item-icon { font-size: 30px; }
.item-name { font-weight: 700; font-size: 14px; hyphens: auto; overflow-wrap: anywhere; }
.progress { width: 100%; height: 6px; border-radius: 3px; background: rgba(255,255,255,.15); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }

@keyframes shell-in { from { transform: scale(0) rotate(-40deg); } to { transform: scale(1) rotate(0); } }
@keyframes shell-out { to { transform: scale(1.8) translateY(-20px); opacity: 0; } }
@keyframes bob { 0%,100% { translate: 0 0; } 50% { translate: 0 -5px; } }
@keyframes float-up { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -50px; } }
@keyframes confetti { to { transform: translate(var(--dx), var(--dy)) rotate(540deg); opacity: 0; } }
@keyframes emote { 0% { transform: translateX(-50%) scale(.3); opacity: 0; } 15% { transform: translateX(-50%) scale(1.2); opacity: 1; }
                   25% { transform: translateX(-50%) scale(1); } 80% { opacity: 1; } 100% { transform: translateX(-50%) translateY(-20px); opacity: 0; } }
@keyframes dance { from { transform: rotate(-12deg) translateY(0); } to { transform: rotate(12deg) translateY(-8px); } }
@keyframes pinch { 50% { transform: scale(1.15) rotate(8deg); } }
@keyframes ouch { 20% { transform: translateX(-8px) rotate(-6deg); } 40% { transform: translateX(8px) rotate(6deg); } 60% { transform: translateX(-5px); } }
@keyframes bump { 50% { transform: scale(1.5); } }
@keyframes rise-top { from { opacity: 0; transform: translate(-50%, -12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Highscore-Box ---------- */
.hud {
    position: fixed;
    top: calc(64px + var(--safe-t)); left: calc(10px + var(--safe-l));
    width: 172px;
    padding: 8px 10px;
    border: none; border-radius: 16px;
    background: var(--glass); backdrop-filter: blur(8px);
    text-align: left; font-size: 13px; line-height: 1.35;
    cursor: pointer; z-index: 15;
}
.hud-title { font-weight: 800; margin-bottom: 2px; }
.hud-top { list-style: none; margin: 0; padding: 0; }
.hud-top li { display: flex; justify-content: space-between; gap: 6px; }
.hud-top li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-top li.me { color: #ffd1e8; }
.hud-next { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,.12); }
.hud-next .progress { margin: 4px 0 2px; }
.hud .small { font-size: 12px; color: var(--muted); }
.hint { top: 38% !important; }
@media (min-width: 900px) { .hud { width: 200px; font-size: 14px; } }

/* ---------- Hilfe ---------- */
.help-btn {
    position: fixed;
    right: calc(12px + var(--safe-r)); bottom: calc(14px + var(--safe-b));
    width: 48px; height: 48px; border-radius: 50%; border: none; cursor: pointer;
    font-size: 22px; background: var(--glass); backdrop-filter: blur(8px);
    box-shadow: 0 4px 14px rgba(0,0,0,.35);
    z-index: 25;
}
@media (max-width: 899px) { body.chat-open .help-btn { display: none; } }
@media (min-width: 900px) { body.chat-open .help-btn { right: 376px; } }
.help-pill { position: absolute; top: calc(12px + var(--safe-t)); left: calc(12px + var(--safe-l)); z-index: 2; font-size: 14px; min-height: 38px; padding: 0 12px; }
.help-sheet { text-align: left; bottom: auto; top: 50%; transform: translate(-50%, -50%); animation: help-in .2s ease-out; width: min(94vw, 460px); }
.help-sheet > strong, .help-sheet > .invite-icon { text-align: center; }
.help-sheet .close { position: sticky; top: 0; align-self: flex-end; margin-bottom: -40px; z-index: 5; flex: 0 0 auto; background: var(--night); }
.help-intro { color: var(--muted); margin: 0 0 6px; }
.help-item { border-radius: 12px; background: rgba(255,255,255,.06); margin-bottom: 6px; }
.help-item summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; font-weight: 700;
}
.help-item summary::-webkit-details-marker { display: none; }
.help-item summary::after { content: "›"; margin-left: auto; font-size: 20px; color: var(--muted); transition: transform .2s; }
.help-item[open] summary::after { transform: rotate(90deg); }
.help-item > div { padding: 0 12px 12px 46px; color: var(--muted); line-height: 1.45; font-size: 14px; }
.help-item > div b { color: #fff; }
.help-item ul { margin: 6px 0 0; padding-left: 18px; }
.help-icon { width: 24px; text-align: center; font-size: 20px; }
.help-foot { text-align: center; }
@keyframes help-in { from { opacity: 0; transform: translate(-50%, -46%); } to { opacity: 1; transform: translate(-50%, -50%); } }

/* ==========================================================
   EXTRAS
   ========================================================== */
/* Tageszeit: Tönung über dem Himmel (unter den Krabben) */
#sky { position: absolute; inset: 0; pointer-events: none; transition: background 2s; }
#stage[data-phase="dawn"] #sky { background: linear-gradient(to bottom, rgba(255,150,120,.55), rgba(255,190,150,.25) 45%, rgba(0,0,0,0) 60%); }
#stage[data-phase="day"]  #sky { background: linear-gradient(to bottom, rgba(120,190,255,.88), rgba(170,215,255,.7) 45%, rgba(255,255,255,0) 58%); }
#stage[data-phase="dusk"] #sky { background: linear-gradient(to bottom, rgba(90,50,140,.55), rgba(255,120,80,.45) 45%, rgba(0,0,0,0) 60%); }
#stage[data-phase="night"] #sky { background: linear-gradient(to bottom, rgba(0,0,0,0) 55%, rgba(10,15,40,.22)); }
.celestial { position: absolute; right: 12%; top: 14%; font-size: clamp(34px, 9vw, 64px); filter: drop-shadow(0 0 18px rgba(255,240,180,.8)); }
#stage[data-phase="night"] .celestial { filter: drop-shadow(0 0 14px rgba(255,255,220,.6)); }
@media (max-width: 899px) { .celestial { top: 32%; right: 8%; } }

/* Wetter */
#weather { position: absolute; inset: 0; pointer-events: none; z-index: 1500; overflow: hidden; }
#stage[data-weather="rain"] #weather i {
    position: absolute; top: -10%; width: 2px; height: 18px;
    background: linear-gradient(transparent, rgba(190,220,255,.85));
    animation: rain-fall linear infinite;
}
#stage[data-weather="snow"] #weather i {
    position: absolute; top: -5%; width: 8px; height: 8px; border-radius: 50%;
    background: #fff; opacity: .9;
    animation: snow-fall linear infinite;
}
#stage[data-weather="fog"] #weather {
    background: linear-gradient(to bottom, rgba(220,225,240,.15), rgba(220,225,240,.55) 60%, rgba(220,225,240,.3));
    animation: fog 12s ease-in-out infinite alternate;
}
#stage[data-weather="rain"] #sky, #stage[data-weather="snow"] #sky { box-shadow: inset 0 0 0 2000px rgba(40,50,80,.25); }
@keyframes rain-fall { to { transform: translate(-40px, 115vh); } }
@keyframes snow-fall { to { transform: translate(var(--drift, 0), 110vh); } }
@keyframes fog { from { opacity: .7; } to { opacity: 1; } }

/* Sternschnuppe */
#stars { position: absolute; inset: 0; pointer-events: none; z-index: 1600; }
.star {
    position: absolute; pointer-events: auto;
    width: 64px; height: 64px; margin: -32px 0 0 -32px;
    border: none; background: none; cursor: pointer; padding: 0;
    font-size: 40px; filter: drop-shadow(0 0 12px rgba(255,255,200,.95));
}
.star span { display: block; }
.star.caught { animation: star-caught .4s ease-out forwards; }
@keyframes star-caught { to { transform: scale(2.2); opacity: 0; } }

/* Muschel-Regen: Dach leuchtet leicht */
#stage.raining-shells::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 80px rgba(255,210,63,.35); }

/* Status-Leiste unten in der Mitte */
#event-bar {
    position: fixed; left: 50%; bottom: calc(16px + var(--safe-b));
    transform: translateX(-50%);
    width: max-content; max-width: calc(100vw - 150px);
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    z-index: 24; pointer-events: none;
}
@media (max-width: 899px) { body.chat-open #event-bar { display: none; } }
.chip-evt {
    pointer-events: auto;
    display: block;
    padding: 8px 12px; border-radius: 16px;
    background: var(--glass); backdrop-filter: blur(8px);
    box-shadow: 0 4px 14px rgba(0,0,0,.35);
    font-size: 13px; line-height: 1.3; text-align: center;
}
.chip-evt.announce { display: flex; align-items: center; gap: 8px; background: rgba(224,54,154,.9); font-size: 14px; font-weight: 600; }
.chip-evt.announce button { border: none; background: rgba(0,0,0,.25); border-radius: 50%; width: 24px; height: 24px; cursor: pointer; flex: 0 0 auto; }
.chip-evt.rain { background: rgba(25,167,189,.85); }
.chip-evt.double { background: rgba(245,183,0,.9); color: #1b1b2e; font-weight: 700; }
.chip-evt.tag.me-it { background: rgba(220,40,60,.9); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.05); } }

/* Fangen */
.crab.is-it .crab-body { filter: drop-shadow(0 0 10px rgba(255,40,60,.95)) drop-shadow(0 4px 3px rgba(0,0,0,.35)); }
.crab.is-it::before {
    content: "😈"; position: absolute; left: 50%; transform: translateX(-50%);
    bottom: calc(var(--crab) * 1.05); font-size: calc(var(--crab) * .32); z-index: 4;
}
.crab.is-it:has(.layer.tall)::before { bottom: calc(var(--crab) * 1.35); }
.crab.safe .crab-body { opacity: .6; }
.result-list { text-align: left; margin: 6px 0; padding-left: 20px; }
.result-list li span { color: var(--muted); font-size: 13px; }

/* Wettrennen */
.race-goal { position: absolute; transform: translate(-50%, -80%); z-index: 3; pointer-events: none; font-size: calc(var(--crab) * .6); }
.race-goal::before {
    content: ""; position: absolute; left: 50%; top: 80%; width: calc(var(--crab) * .9); height: calc(var(--crab) * .35);
    transform: translate(-50%, -50%); border-radius: 50%;
    border: 4px dashed #fff; animation: goal-spin 3s linear infinite;
}
.race-goal[hidden] { display: none; }
@keyframes goal-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
#big-count {
    position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%);
    font-size: clamp(48px, 16vw, 120px); font-weight: 900; color: #fff;
    text-shadow: 0 6px 20px rgba(0,0,0,.6), 0 0 30px rgba(224,54,154,.8);
    z-index: 70; pointer-events: none; text-align: center; white-space: nowrap;
}
#big-count[hidden] { display: none; }
#big-count.pop { animation: count-pop .6s ease-out; }
@keyframes count-pop { from { transform: translate(-50%, -50%) scale(2); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

/* Tägliche Belohnung */
.daily-box { top: 50%; bottom: auto; transform: translate(-50%, -50%); animation: help-in .25s ease-out; }
.gift { animation: gift 1s ease-in-out infinite alternate; }
@keyframes gift { from { transform: rotate(-8deg) scale(1); } to { transform: rotate(8deg) scale(1.15); } }
.daily-reward { font-size: 40px; font-weight: 900; color: #ffe066; }
.streak-row { display: flex; justify-content: center; gap: 6px; }
.streak-row span { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.1); font-size: 13px; font-weight: 700; }
.streak-row span.on { background: var(--accent); }

/* Spiele-Tab */
.tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tab { font-size: 13px; padding: 7px 10px; white-space: nowrap; flex: 0 0 auto; }
.game-card { background: rgba(255,255,255,.06); border-radius: 16px; padding: 12px 14px; margin-bottom: 10px; }
.game-card p { margin: 6px 0 10px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.game-card p b { color: #fff; }
.game-title { font-weight: 800; font-size: 17px; }
.small-list { margin: 6px 0 0; padding-left: 4px; list-style: none; font-size: 14px; line-height: 1.6; color: var(--muted); }
.small-list b { color: #fff; }
.seg { display: flex; gap: 4px; background: rgba(255,255,255,.08); border-radius: 999px; padding: 4px; margin-bottom: 8px; }
.seg button { flex: 1; border: none; background: none; border-radius: 999px; padding: 8px; font-weight: 700; cursor: pointer; font-size: 14px; }
.seg button.active { background: var(--accent); }
.center { text-align: center; }
.item.seasonal { background: linear-gradient(135deg, rgba(255,140,0,.18), rgba(224,54,154,.18)); }

/* Profil */
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 36px; }
.profile-head strong { font-size: 20px; }
.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.profile-stats div { background: rgba(255,255,255,.06); border-radius: 12px; padding: 8px 4px; text-align: center; display: flex; flex-direction: column; }
.profile-stats b { font-size: 18px; }
.profile-stats span { font-size: 11px; color: var(--muted); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.pbadge { background: rgba(255,255,255,.05); border-radius: 12px; padding: 8px 6px; text-align: center; opacity: .55; }
.pbadge.have { opacity: 1; background: rgba(255,210,63,.16); outline: 1px solid rgba(255,210,63,.5); }
.pbadge-icon { font-size: 26px; }
.pbadge-name { font-weight: 700; font-size: 13px; }
.pbadge .small { font-size: 11px; color: var(--muted); }

/* Chat: Reaktionen & „schreibt gerade …“ */
.msg { padding-right: 30px; }
.react-add {
    position: absolute; right: 4px; top: 4px;
    width: 24px; height: 24px; border-radius: 50%; border: none; cursor: pointer;
    background: rgba(255,255,255,.12); font-size: 13px; opacity: .7;
}
.msg-reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.msg-reacts:empty { display: none; }
.react { border: none; cursor: pointer; border-radius: 999px; padding: 2px 8px; background: rgba(0,0,0,.25); font-size: 13px; }
.react.mine { background: rgba(224,54,154,.6); }
.react-picker {
    display: flex; gap: 2px; padding: 4px; margin-top: 6px; width: max-content;
    background: var(--night-2); border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,.45);
}
.react-picker button { border: none; background: none; font-size: 22px; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; }
.react-picker button:active { background: rgba(255,255,255,.15); }
#typing-line { min-height: 18px; padding: 0 16px; font-size: 12px; color: var(--muted); font-style: italic; }

/* ---------- Desktop: Chat als Seitenleiste ---------- */
@media (min-width: 900px) {
    #chat {
        left: auto; top: 70px; right: 12px; bottom: 12px;
        width: 340px; height: auto;
        border-radius: 20px;
        transform: translateX(calc(100% + 24px));
    }
    #chat.open { transform: none; }
    body.chat-open #stage { bottom: 0; right: 364px; }
}
@media (max-width: 420px) { .hide-sm { display: none; } }

/* ---------- Animationen ---------- */
@keyframes scuttle { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-4px) rotate(4deg); } }
@keyframes wiggle  { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-8deg) scale(1.05); } 75% { transform: rotate(8deg) scale(1.05); } }
@keyframes pop     { from { transform: translateX(-50%) scale(.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
@keyframes ripple  { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
@keyframes shake   { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

@media (prefers-reduced-motion: reduce) {
    .crab.walking .crab-body, .crab-preview.wiggle, .bubble.pop { animation: none; }
}
