/* ==========================================================================
   Rechen-Kugel 3D – Vollbild Three.js HUD & Mobile-First Controls
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0f172a;
    color: #f8fafc;
    font-family: var(--le-font-sans);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    -webkit-tap-highlight-color: transparent;
}

button {
    font-family: inherit;
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.mono {
    font-family: var(--le-font-mono);
    font-variant-numeric: tabular-nums;
}

.game-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* ==========================================================================
   HUD OBEN
   ========================================================================== */
.hud-top {
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    z-index: 30;
    pointer-events: none;
}

.hud-stats,
.hud-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
}

.hud-pill {
    min-height: 40px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    font-size: 0.85rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.hud-pill.streak {
    background: rgba(217, 119, 6, 0.9);
    border-color: #fef08a;
    color: #ffffff;
}

.hud-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0 10px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.24);
    backdrop-filter: blur(8px);
    font-size: 1.05rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.12s ease;
}

.hud-btn.is-muted {
    opacity: 0.58;
}

.hud-btn-label {
    gap: 5px;
    font-size: 0.88rem;
    padding: 0 12px;
}

/* ==========================================================================
   AUFGABEN-ANZEIGE OBEN MITTIG
   ========================================================================== */
.task-banner-wrap {
    position: fixed;
    top: max(62px, calc(env(safe-area-inset-top) + 52px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    pointer-events: none;
    width: min(92vw, 440px);
}

.task-card {
    padding: 10px 18px 12px;
    border-radius: 20px;
    background: rgba(15, 23, 42, 0.86);
    border: 2.5px solid #38bdf8;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
    text-align: center;
}

.task-sub {
    display: block;
    font-size: 0.74rem;
    font-weight: 800;
    color: #bae6fd;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.task-expr {
    font-size: clamp(1.45rem, 4.5vw, 2.2rem);
    font-weight: 900;
    color: #fef08a;
    margin-top: 2px;
}

.hit-toast {
    position: fixed;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 10px 20px;
    border-radius: 999px;
    background: rgba(22, 163, 74, 0.94);
    color: #ffffff;
    font-size: 1.15rem;
    font-weight: 900;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
    z-index: 28;
    pointer-events: none;
}

.hit-toast.is-bad {
    background: rgba(225, 29, 72, 0.95);
}

/* ==========================================================================
   TOUCH-STEUERUNG UNTEN
   ========================================================================== */
.touch-controls {
    position: fixed;
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: min(94vw, 560px);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    z-index: 26;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.lane-pad {
    min-height: 58px;
    padding: 0 16px;
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 900;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    transition: transform 0.08s ease, background 0.1s ease, box-shadow 0.1s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.lane-pad:active,
.lane-pad.is-active {
    transform: scale(0.95);
    background: rgba(13, 148, 136, 0.92);
    border-color: #5eead4;
}

.lane-pad.turbo {
    min-width: 122px;
    background: rgba(217, 119, 6, 0.88);
    border-color: #fef08a;
    box-shadow: 0 6px 20px rgba(217, 119, 6, 0.35);
}

.lane-pad.turbo:active,
.lane-pad.turbo.is-active {
    transform: scale(0.96);
    background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
    border-color: #ffffff;
    box-shadow: 0 0 24px rgba(254, 240, 138, 0.75);
}

/* ==========================================================================
   START & GAME-OVER OVERLAYS
   ========================================================================== */
.overlay-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.76);
    backdrop-filter: blur(6px);
    display: grid;
    place-items: center;
    padding: 16px;
    z-index: 50;
}

.overlay-card {
    width: 100%;
    max-width: 560px;
    max-height: 92dvh;
    overflow-y: auto;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid rgba(56, 189, 248, 0.38);
    border-radius: 26px;
    padding: 20px 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: center;
}

.overlay-card.overlay-wide {
    max-width: 760px;
}

.menu-top-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.coins-pill {
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(251, 191, 36, 0.55);
    color: #fef08a;
    font-size: 0.84rem;
    font-weight: 900;
}

.menu-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.menu-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.quick-pill-btn {
    min-height: 46px;
    padding: 8px 12px;
    border-radius: 14px;
    background: rgba(30, 41, 59, 0.9);
    border: 1.5px solid rgba(148, 163, 184, 0.35);
    color: #f8fafc;
    font-size: 0.86rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: border-color 0.12s ease, transform 0.08s ease;
}

.quick-pill-btn:active {
    transform: scale(0.97);
}

.quick-pill-btn:hover {
    border-color: #38bdf8;
}

.map-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.map-card {
    position: relative;
    min-height: 102px;
    padding: 10px 11px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.72);
    border: 2px solid rgba(148, 163, 184, 0.26);
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 6px;
    transition: transform 0.1s ease, border-color 0.14s ease, background 0.14s ease;
}

.map-card.is-tour {
    grid-column: 1 / -1;
    min-height: 76px;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
}

.map-card.active {
    background: rgba(2, 132, 199, 0.26);
    border-color: var(--map-accent, #38bdf8);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.22);
}

.map-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
}

.map-name {
    font-size: 0.92rem;
    font-weight: 900;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 5px;
}

.diff-pill {
    font-size: 0.68rem;
    font-weight: 900;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    white-space: nowrap;
}

.diff-pill.diff-leicht { background: rgba(16, 185, 129, 0.25); color: #6ee7b7; }
.diff-pill.diff-mittel { background: rgba(56, 189, 248, 0.25); color: #7dd3fc; }
.diff-pill.diff-schwer { background: rgba(249, 115, 22, 0.28); color: #fdba74; }
.diff-pill.diff-profi { background: rgba(192, 132, 252, 0.28); color: #e9d5ff; }
.diff-pill.diff-dynamisch { background: rgba(45, 212, 191, 0.28); color: #5eead4; }

.map-sub {
    font-size: 0.76rem;
    color: #cbd5e1;
    font-weight: 700;
    line-height: 1.3;
}

.map-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    font-size: 0.72rem;
    font-weight: 800;
    color: #fef08a;
}

.modal-head-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-align: left;
}

.modal-head-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-sub {
    font-size: 0.82rem;
    color: #cbd5e1;
    margin-top: 2px;
}

.close-modal-btn {
    min-height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.24);
    color: #ffffff;
    font-size: 0.86rem;
    font-weight: 800;
}

.garage-feedback {
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(22, 163, 74, 0.25);
    border: 1px solid #4ade80;
    color: #dcfce7;
    font-size: 0.84rem;
    font-weight: 800;
}

.garage-feedback.is-error {
    background: rgba(225, 29, 72, 0.25);
    border-color: #fb7185;
    color: #ffe4e6;
}

.ball-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
    gap: 10px;
}

.ball-card {
    padding: 12px 10px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.76);
    border: 2px solid rgba(148, 163, 184, 0.24);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.ball-card.active {
    border-color: #2dd4bf;
    background: rgba(13, 148, 136, 0.22);
}

.ball-card-title {
    font-size: 0.84rem;
    font-weight: 900;
    color: #ffffff;
}

.ball-card-rarity {
    font-size: 0.7rem;
    font-weight: 800;
    color: #94a3b8;
}

.ball-action-btn {
    width: 100%;
    min-height: 44px;
    padding: 6px 10px;
    border-radius: 12px;
    background: rgba(2, 132, 199, 0.35);
    border: 1px solid #38bdf8;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 800;
    margin-top: auto;
}

.ball-action-btn.is-buy {
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
    border-color: #fef08a;
    color: #1e293b;
}

.ball-action-btn.is-active-btn {
    background: rgba(13, 148, 136, 0.45);
    border-color: #5eead4;
    color: #ccfbf1;
}

.ball-action-btn:disabled {
    opacity: 0.52;
    cursor: default;
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
    gap: 10px;
}

.badge-card {
    padding: 12px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.72);
    border: 1.5px solid rgba(148, 163, 184, 0.22);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}

.badge-card.unlocked {
    border-color: #fbbf24;
    background: rgba(245, 158, 11, 0.12);
}

.badge-card.locked {
    opacity: 0.65;
}

.badge-art svg {
    width: 64px;
    height: 64px;
    border-radius: 14px;
}

.badge-card strong {
    font-size: 0.88rem;
    color: #ffffff;
}

.badge-card p {
    font-size: 0.74rem;
    color: #cbd5e1;
    line-height: 1.35;
}

.badge-status {
    font-size: 0.72rem;
    font-weight: 900;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    margin-top: auto;
}

.badge-card.unlocked .badge-status {
    background: rgba(22, 163, 74, 0.35);
    color: #86efac;
}

.medals-summary {
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(148, 163, 184, 0.24);
    font-size: 0.82rem;
    color: #cbd5e1;
    font-weight: 700;
}

.end-map-line {
    font-size: 0.88rem;
    font-weight: 800;
    color: #7dd3fc;
}

.end-sec-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.game-badge {
    align-self: center;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(13, 148, 136, 0.25);
    border: 1px solid #2dd4bf;
    color: #5eead4;
    font-size: 0.78rem;
    font-weight: 900;
}

.overlay-card h1,
.overlay-card h2 {
    font-size: 1.65rem;
    font-weight: 900;
    color: #ffffff;
}

.overlay-desc {
    font-size: 0.94rem;
    color: #cbd5e1;
    line-height: 1.5;
}

.tier-select-group {
    display: grid;
    gap: 8px;
}

.tier-card {
    min-height: 54px;
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.65);
    border: 2px solid rgba(148, 163, 184, 0.3);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tier-card strong {
    font-size: 0.94rem;
    color: #ffffff;
}

.tier-card span {
    font-size: 0.78rem;
    color: #94a3b8;
    font-weight: 600;
}

.tier-card.active {
    background: rgba(2, 132, 199, 0.28);
    border-color: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.22);
}

.best-row {
    font-size: 0.88rem;
    color: #fef08a;
    font-weight: 800;
}

.play-cta {
    min-height: 54px;
    padding: 0 22px;
    border-radius: 16px;
    background: linear-gradient(135deg, #0d9488 0%, #0284c7 100%);
    color: #ffffff;
    font-size: 1.06rem;
    font-weight: 900;
    box-shadow: 0 10px 26px rgba(2, 132, 199, 0.38);
}

.sec-cta {
    min-height: 48px;
    padding: 0 18px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.92rem;
    font-weight: 800;
}

.ctrl-hint {
    font-size: 0.78rem;
    color: #94a3b8;
    line-height: 1.45;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.sum-box {
    padding: 10px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(148, 163, 184, 0.2);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sum-box span { font-size: 0.74rem; color: #94a3b8; font-weight: 700; }
.sum-box strong { font-size: 1.15rem; color: #fef08a; }

.end-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@media (max-width: 680px) {
    .map-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hud-pill.biome { display: none; }
    .hud-btn-text { display: none; }
    .hud-btn-label { padding: 0 10px; font-size: 1.05rem; }
}

@media (max-width: 440px) {
    .menu-quick-actions { grid-template-columns: 1fr; }
    .map-grid { grid-template-columns: 1fr; }
    .end-sec-row { grid-template-columns: 1fr; }
}
