:root {
    --bg: #f6f2e7;
    --ink: #1c2f5a;
    --ink-soft: #2f6fcc;
    --card: #ffffff;
    --accent: #f2b84b;
    --danger: #c93a49;
    --shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] {
    --bg: #0f1726;
    --ink: #e6edf7;
    --ink-soft: #9fc4ff;
    --card: #16243b;
    --accent: #e6bf57;
    --danger: #ef7a8b;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Open Sans", Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 18% 12%, rgba(47, 111, 204, 0.24), transparent 42%),
        radial-gradient(circle at 82% 10%, rgba(242, 184, 75, 0.22), transparent 40%),
        radial-gradient(circle at 75% 90%, rgba(30, 168, 164, 0.16), transparent 44%),
        radial-gradient(circle at top, #faf7ef 0%, var(--bg) 72%);
    display: flex;
    justify-content: center;
    padding: 20px 16px 28px;
}

.page {
    width: min(100%, 720px);
    text-align: center;
}

h1 {
    margin: 0;
    font-size: clamp(1.8rem, 2.8vw, 2.5rem);
}

.instructions {
    margin: 10px auto 16px;
    max-width: 560px;
    color: var(--ink-soft);
}

.quick-links {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 auto 14px;
}

.quick-links a {
    text-decoration: none;
    color: var(--ink);
    border: 1px solid rgba(47, 111, 204, 0.2);
    background: var(--card);
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 700;
}

.hud {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.account-panel,
.league-overview,
.shop,
.leaderboard {
    width: min(100%, 520px);
    margin: 14px auto 0;
    background: var(--card);
    border: 1px solid rgba(47, 111, 204, 0.16);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
    text-align: left;
}

.account-header,
.leaderboard-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.account-header h2,
.league-copy h2,
.shop h2,
.leaderboard h2 {
    margin: 0 0 6px;
    text-align: left;
    font-size: 1.1rem;
}

.account-header p,
.league-copy p,
.leaderboard-head p,
.auth-status {
    margin: 0;
    color: var(--ink-soft);
    line-height: 1.45;
}

.auth-badge,
.leaderboard-meta {
    align-self: center;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 800;
    background: rgba(47, 111, 204, 0.12);
    color: var(--ink);
}

.auth-badge.online {
    background: rgba(49, 153, 96, 0.14);
    color: #1f6d47;
}

.auth-badge.syncing {
    background: rgba(242, 184, 75, 0.22);
    color: #7a5400;
}

.auth-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0 10px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 700;
}

.auth-field input {
    width: 100%;
    border: 1px solid rgba(47, 111, 204, 0.22);
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
    color: var(--ink);
}

.auth-field input:disabled,
.auth-field input[readonly] {
    background: rgba(47, 111, 204, 0.08);
    color: var(--ink);
}

.auth-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: end;
    grid-column: 1 / -1;
}

.league-overview {
    display: grid;
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.league-current-card {
    border-radius: 12px;
    padding: 14px;
    background:
        radial-gradient(circle at top left, rgba(242, 184, 75, 0.26), transparent 42%),
        linear-gradient(145deg, rgba(47, 111, 204, 0.08), rgba(255, 255, 255, 0.94));
    border: 1px solid rgba(47, 111, 204, 0.16);
    text-align: center;
}

.league-eyebrow {
    margin: 0 0 8px;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.league-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 124px;
    min-height: 46px;
    border-radius: 999px;
    padding: 10px 18px;
    font-size: 1rem;
    font-weight: 800;
    color: #102543;
    background: linear-gradient(135deg, #d3b271, #f7df99);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.league-range {
    margin: 10px 0 0;
    font-weight: 700;
    color: var(--ink-soft);
}

[data-league="bronze"] {
    background: linear-gradient(135deg, #a86a3b, #d99d6c);
    color: #fff8ef;
}

[data-league="guest"] {
    background: linear-gradient(135deg, #2d7a6b, #8fdcc8);
    color: #f4fffb;
}

[data-league="silver"] {
    background: linear-gradient(135deg, #9da7b4, #d9e0e7);
}

[data-league="gold"] {
    background: linear-gradient(135deg, #c5921f, #f4d16a);
}

[data-league="sapphire"] {
    background: linear-gradient(135deg, #2767b3, #7eb8ff);
    color: #eff6ff;
}

[data-league="ruby"] {
    background: linear-gradient(135deg, #b73052, #f3859f);
    color: #fff0f4;
}

[data-league="emerald"] {
    background: linear-gradient(135deg, #198a5f, #7be1b5);
    color: #effff8;
}

[data-league="amethyst"] {
    background: linear-gradient(135deg, #7a49c3, #c6a0ff);
    color: #fbf6ff;
}

[data-league="pearl"] {
    background: linear-gradient(135deg, #cec7d3, #fffefb);
}

[data-league="obsidian"] {
    background: linear-gradient(135deg, #243142, #66768f);
    color: #f4f7fb;
}

[data-league="diamond"] {
    background: linear-gradient(135deg, #8ec9ff, #f9fcff);
}

.hud-item {
    background: var(--card);
    border: 1px solid rgba(47, 111, 204, 0.16);
    border-radius: 10px;
    padding: 10px 8px;
    font-weight: 700;
    box-shadow: var(--shadow);
}

.hud-item-wide {
    grid-column: span 4;
}

#game {
    width: min(100%, 520px);
    height: 560px;
    margin: 0 auto;
    border: 3px solid var(--ink);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #f7f5ec 46%, #eef6fb 100%);
    box-shadow: var(--shadow);
    touch-action: none;
}

#player {
    position: absolute;
    bottom: 14px;
    left: 0;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
    z-index: 3;
}

#player::before {
    content: "";
    width: 100%;
    height: 100%;
    background-image: var(--cart-image, url('einkaufswägen/Klassisch.png'));
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.16));
}

#player.cart-skin-classic { --cart-image: url('einkaufswägen/Klassisch.png'); }
#player.cart-skin-sky { --cart-image: url('einkaufswägen/Himmelblau.png'); }
#player.cart-skin-mint { --cart-image: url('einkaufswägen/Mint.png'); }
#player.cart-skin-rose { --cart-image: url('einkaufswägen/Rose.png'); }
#player.cart-skin-violet { --cart-image: url('einkaufswägen/Violett.png'); }
#player.cart-skin-jumper { --cart-image: url('einkaufswägen/Springer.png'); }

.item {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 2rem;
    line-height: 1;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    will-change: transform;
    user-select: none;
}

.item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.emoji-item {
    font-size: 2rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}


.shabbat-item {
    border: none;
    box-shadow: none;
    background: transparent;
}

.bubble-item {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.95);
    background: radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.95) 0%, rgba(173, 222, 255, 0.88) 52%, rgba(110, 165, 243, 0.88) 100%);
    box-shadow: 0 8px 16px rgba(0, 32, 78, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 10px;
    line-height: 1.05;
}

.bubble-emoji {
    font-size: 1.2rem;
}

.bubble-text {
    font-size: 0.56rem;
    font-weight: 700;
    text-align: center;
    color: #0c2a4f;
    text-wrap: balance;
}

.shabbat-item-forbidden .bubble-text {
    color: #681515;
}

.shabbat-item-allowed {
    background: radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.96) 0%, rgba(193, 241, 215, 0.92) 52%, rgba(109, 206, 152, 0.9) 100%);
}

.powerup {
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.powerup-shield {
    background: #6ab1ff;
}

.powerup-slow {
    background: #73d8c4;
}

.powerup-double {
    background: #f0c44d;
}

.powerup-life {
    background: #e8818d;
}

.powerup-grow {
    background: #9acb6f;
}

.powerup-magnet {
    background: #c38af2;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    background: rgba(14, 28, 51, 0.92);
    color: #fff;
    z-index: 5;
    padding: 20px;
    text-align: center;
}

#shabbatIntroScreen {
    background: #ffffff;
    color: #102543;
}

#shabbatIntroTitle,
#shabbatIntroText {
    color: #102543;
    text-shadow: none;
}

#startScreen h2 {
    margin: 0 0 6px;
}

#startScreen p {
    margin: 0 0 12px;
    max-width: 360px;
    line-height: 1.45;
}


#startScreen h2,
#startScreen p,
#gameOverTitle,
#resultText {
    color: #f8fbff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

#resultText {
    font-weight: 700;
    line-height: 1.5;
    max-width: 34ch;
}


.mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 8px;
    max-width: 460px;
    text-align: left;
}

.mode-toggle input {
    margin: 0;
    accent-color: var(--accent);
}

#startButton,
#restartButton,
#saveLeaderboardButton,
#skipLeaderboardButton,
.auth-actions button {
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: #102543;
    font-weight: 800;
    padding: 10px 18px;
    cursor: pointer;
}

.status {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(28, 47, 90, 0.95);
    color: #fff;
    border-radius: 999px;
    padding: 6px 12px;
    font-weight: 700;
    font-size: 0.9rem;
    z-index: 4;
}

.danger {
    background: rgba(201, 58, 73, 0.94);
}

.shop-tabs {
    display: flex;
    gap: 8px;
    margin: 8px 0 10px;
}

.shop-tab {
    flex: 1;
    border: 1px solid rgba(47, 111, 204, 0.22);
    border-radius: 8px;
    padding: 8px 10px;
    background: #edf3ff;
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
}

.shop-tab.active {
    background: var(--accent);
}

.shop-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.shop-item {
    border: 1px solid rgba(47, 111, 204, 0.2);
    border-radius: 10px;
    padding: 10px;
    background: #f9fbff;
}

.shop-item h3 {
    margin: 0 0 6px;
    font-size: 1rem;
}

.shop-power,
.shop-description,
.shop-status {
    margin: 0 0 6px;
    font-size: 0.85rem;
}

.shop-item button {
    width: 100%;
    border: none;
    border-radius: 8px;
    padding: 8px 10px;
    background: var(--accent);
    color: #102543;
    font-weight: 700;
    cursor: pointer;
}

.shop-item.selected {
    border-color: #58b77f;
    background: #ebfff2;
}

.shop-item.locked {
    opacity: 0.68;
}

.coin-result {
    margin: 0 0 8px;
    font-weight: 700;
    color: #f8d37f;
}

.leaderboard-head {
    margin-bottom: 10px;
}

.league-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
}

.league-tab {
    border: 1px solid rgba(47, 111, 204, 0.18);
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(47, 111, 204, 0.06);
    color: var(--ink);
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.league-tab:hover,
.league-tab:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(47, 111, 204, 0.3);
    box-shadow: 0 4px 12px rgba(28, 47, 90, 0.12);
}

.league-tab.active {
    border-color: transparent;
    box-shadow: 0 6px 18px rgba(28, 47, 90, 0.16);
}

.leaderboard ol {
    margin: 0;
    padding-left: 22px;
}

.leaderboard li {
    margin: 4px 0;
    font-weight: 600;
    padding: 6px 8px;
    border-radius: 10px;
}

.leaderboard li.current-user {
    background: rgba(242, 184, 75, 0.22);
}

.leaderboard li.promotion-zone {
    background: rgba(53, 164, 97, 0.2);
    border: 1px solid rgba(53, 164, 97, 0.35);
}

.leaderboard li.demotion-zone {
    background: rgba(194, 61, 74, 0.2);
    border: 1px solid rgba(194, 61, 74, 0.35);
}

.leaderboard li.bot-entry {
    font-style: italic;
}


.developer-options {
    width: min(100%, 820px);
    margin: 0 auto 16px;
    background: rgba(8, 18, 35, 0.08);
    border: 1px solid rgba(47, 111, 204, 0.24);
    border-radius: 14px;
    padding: 14px;
}

.developer-options-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.developer-options h2 {
    margin: 0;
    font-size: 1.1rem;
}

.developer-options p {
    margin: 10px 0 0;
}

.developer-badge {
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    background: rgba(47, 111, 204, 0.16);
    border: 1px solid rgba(47, 111, 204, 0.28);
}

.developer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}


.mobile-controls {
    margin: 16px auto 0;
    width: min(100%, 520px);
    display: none;
    gap: 12px;
}

.mobile-controls button {
    flex: 1;
    border: 2px solid var(--ink);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font-size: 1.4rem;
    font-weight: 700;
    padding: 10px;
    touch-action: none;
}

.hidden {
    display: none;
}

@media (max-width: 760px) {
    .hud {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .auth-grid,
    .league-overview {
        grid-template-columns: 1fr;
    }

    .hud-item-wide {
        grid-column: span 2;
    }

    #game {
        height: 500px;
    }

    .mobile-controls {
        display: flex;
    }

    .shop-list {
        grid-template-columns: 1fr;
    }
}


.secondary {
    background: #c7d5ee;
}

.ghost {
    background: transparent;
    border: 1px solid rgba(47, 111, 204, 0.28);
    color: var(--ink);
}

.leaderboard-optin {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(100%, 320px);
    background: rgba(8, 18, 35, 0.7);
    border: 1px solid rgba(233, 244, 255, 0.34);
    border-radius: 12px;
    padding: 12px;
}

.leaderboard-optin p {
    margin: 0;
    color: #f2f8ff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

#playerNameLabel {
    color: #f2f8ff;
    font-weight: 600;
}

.leaderboard-optin input {
    width: 100%;
    border: 1px solid rgba(47, 111, 204, 0.22);
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
    color: var(--ink);
}

.leaderboard-optin input[readonly] {
    background: rgba(47, 111, 204, 0.08);
}

.leaderboard-auth-hint {
    margin: 0;
    font-size: 0.9rem;
    color: rgba(242, 248, 255, 0.9);
}

.auth-status.error,
.leaderboard-auth-hint.error {
    color: var(--danger);
}

.optin-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}


.quick-links .theme-toggle-link {
    border: 1px solid rgba(47, 111, 204, 0.24);
    background: var(--paper, var(--card, #fff));
    color: var(--ink);
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 700;
    cursor: pointer;
}

[data-theme="dark"] body {
    background:
        radial-gradient(circle at 18% 12%, rgba(112, 167, 255, 0.22), transparent 42%),
        radial-gradient(circle at 82% 10%, rgba(230, 191, 87, 0.18), transparent 40%),
        radial-gradient(circle at 75% 90%, rgba(68, 208, 181, 0.16), transparent 44%),
        radial-gradient(circle at top, #182338 0%, var(--bg) 72%);
}
