@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 400;
  src: url('fredoka_400.ttf') format('truetype');
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 600;
  src: url('fredoka_600.ttf') format('truetype');
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 700;
  src: url('fredoka_700.ttf') format('truetype');
}

:root {
    --bg-color: #8BC34A; 
    --hud-bg: rgba(255, 255, 255, 0.95);
    --text-color: #333;
    --primary: #FF9800; 
    --primary-dark: #F57C00;
}

* { box-sizing: border-box; user-select: none; }

/* --- Ultra-Sharp High-Definition Rendering für Icons, Sprites & Canvas --- */
canvas, img, .tower-icon img, .lexicon-icon img, .panel-mascot img, .hero-icon img, .intro-sprite img, .menu-card img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: smooth;
    image-rendering: high-quality;
}

body {
    margin: 0; padding: 0;
    font-family: 'Fredoka', sans-serif;
    /* Modern dark background for the surrounding area */
    background: radial-gradient(circle at center, #2c3e50 0%, #1a1a1a 100%);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    height: 100vh; height: 100dvh; overflow: hidden;
}

/* --- Unified Top Bar inside Game Container --- */
.game-top-bar {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 4px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 25;
    pointer-events: none;
}
.game-top-bar > * {
    pointer-events: auto;
}
/* Unified Controls Panel ("Ein einziger eleganter Kasten") */
.top-right-group {
    position: absolute;
    right: -8px;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(18, 22, 36, 0.88);
    border: 2px solid rgba(255, 213, 79, 0.45);
    border-radius: 20px;
    padding: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 30;
    pointer-events: auto;
}
.top-control-item {
    width: 38px;
    height: 38px;
    min-width: 38px;
    padding: 0;
    margin: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    color: #FFF;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    position: relative;
    box-sizing: border-box;
}
.top-control-item:hover {
    background: #FFD54F;
    color: #000;
    border-color: #FFF;
    transform: scale(1.08);
    box-shadow: 0 2px 10px rgba(255, 213, 79, 0.5);
}
.top-control-item:active {
    transform: scale(0.95);
}
.speed-toggle-btn {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.speed-label {
    font-size: 0.8rem;
    font-weight: 800;
    color: inherit;
    line-height: 1;
}
.speed-toggle-btn.speed-turbo {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: #FFF;
    border-color: #FFD54F;
    box-shadow: 0 0 12px rgba(255, 152, 0, 0.8);
}
#game-container {
    position: relative; width: 100%; max-width: 1100px; height: 100%; max-height: 820px;
    background-color: transparent;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    border-radius: 16px; display: flex; flex-direction: column; overflow: hidden;
    transition: max-width 0.3s ease, max-height 0.3s ease;
}
#game-container.size-standard { width: 1100px; height: 820px; max-width: 98vw; max-height: 98vh; }
#game-container.size-large { width: 1450px; height: 960px; max-width: 98vw; max-height: 98vh; }
#game-container.size-xl { width: 1800px; height: 1150px; max-width: 98vw; max-height: 98vh; }
#game-container.size-max {
    width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh;
    border-radius: 0; position: fixed; top: 0; left: 0; right: 0; bottom: 0; margin: 0; z-index: 5;
}

/* --- Modern Glassmorphism Comic HUD --- */
#hud, #hud-stats-bar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    z-index: 25;
    margin: 0;
    font-weight: 700;
    color: #FAFAFA;
}
#hud-stats-bar {
    position: static !important;
    gap: 10px;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 0 !important;
    font-size: 1.15rem;
}
#hud, .top-controls-hud {
    position: static !important;
    gap: 14px;
    background: rgba(18, 22, 36, 0.88);
    padding: 6px 14px;
    border-radius: 28px;
    border: 2px solid rgba(255, 213, 79, 0.45);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    font-size: 1.1rem;
    margin: 0 !important;
}

/* Build Menu Bottom Controls */
.build-menu-utils {
    display: flex;
    align-items: center;
    gap: 8px;
}
.build-utils-left {
    margin-right: 6px;
    padding-right: 10px;
    border-right: 2px solid rgba(255, 213, 79, 0.25);
}
.size-toggle-btn {
    background: rgba(30, 36, 56, 0.95);
    border: 2px solid rgba(255, 213, 79, 0.4);
    color: #FFD700;
    font-weight: bold;
    font-size: 0.88rem;
    padding: 6px 12px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    transition: all 0.2s;
}
.size-toggle-btn:hover {
    background: #FFD54F;
    color: #000;
    transform: translateY(-2px);
}
.build-menu-utils .hud-icon-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    font-size: 1.3rem !important;
    align-self: center;
    border: 2px solid rgba(255, 213, 79, 0.4);
    border-radius: 14px;
    background: rgba(30, 36, 56, 0.95);
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.build-menu-utils .hud-icon-btn:hover {
    background: #FFB74D !important;
    border-color: #FFF !important;
    transform: translateY(-2px);
}
@media (max-width: 900px) {
    .size-toggle-btn { display: none !important; }
}

/* Gruppen-Trennung (immer einzeilig horizontal) */
.hud-group {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 12px;
}
.hud-divider {
    display: none;
}

.stat {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    padding: 6px 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s, background 0.15s, border-color 0.15s;
}
.stat:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 213, 79, 0.6);
}

.stat span {
    display: flex;
    align-items: center;
    gap: 6px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Specific Stat Highlights */
#health { color: #FF5252; font-weight: 800; }
#wave { color: #40C4FF; font-weight: 800; }
#money { color: #FFD54F; font-weight: 800; }

/* Interactive HUD Toggle Buttons */
.speed-stat { cursor: pointer; width: 44px; justify-content: center; }
.hud-icon-btn {
    cursor: pointer;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
}
.hud-icon-btn:hover {
    transform: scale(1.25) rotate(5deg);
}
.hud-icon-btn:active {
    transform: scale(0.95);
}

/* Floating Volume Slider Popup */
.volume-container {
    position: relative;
}
.volume-popup {
    display: none;
    position: absolute;
    top: 0;
    bottom: auto;
    left: auto;
    right: calc(100% + 12px);
    transform: none;
    background: rgba(18, 22, 36, 0.96);
    border: 2px solid #FFD54F;
    border-radius: 22px;
    padding: 16px 14px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.8), inset 0 2px 4px rgba(255, 255, 255, 0.15);
    flex-direction: column;
    align-items: center;
    gap: 14px;
    z-index: 100;
    min-width: 95px;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
.volume-popup.active {
    display: flex;
    animation: fadeInUp 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translate(-50%, 12px) scale(0.9); }
    to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.volume-popup-title {
    font-size: 0.85rem;
    color: #FFD54F;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.slider-vertical-wrap {
    width: 40px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px 0;
}
#volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 110px;
    height: 10px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    outline: none;
    transition: background 0.2s;
    cursor: pointer;
    transform: rotate(-90deg);
    margin: 0;
}
#volume-slider:hover {
    background: rgba(255, 213, 79, 0.5);
}
#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #FFD54F;
    border: 2px solid #E65100;
    box-shadow: 0 2px 6px rgba(0,0,0,0.6);
    transition: transform 0.15s, background 0.15s;
    cursor: pointer;
}
#volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
    background: #FFF;
}
#volume-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #FFD54F;
    border: 2px solid #E65100;
    box-shadow: 0 2px 6px rgba(0,0,0,0.6);
    cursor: pointer;
    transition: transform 0.15s;
}
#volume-slider::-moz-range-thumb:hover {
    transform: scale(1.3);
    background: #FFF;
}
.mute-btn {
    background: rgba(255, 82, 82, 0.25);
    border: 1px solid #FF5252;
    color: #FFF;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.mute-btn:hover {
    background: #FF5252;
    transform: scale(1.05);
}

#main-area { 
    flex-grow: 1; display: flex; justify-content: center; align-items: center; 
    overflow: hidden; min-height: 0; position: relative; width: 100%;
}
#canvas-container {
    position: relative; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center;
}
canvas { 
    touch-action: none; 
    width: 100%;
    height: 100%;
    max-width: 100%; 
    max-height: 100%; 
    object-fit: contain; 
}

#build-menu {
    display: flex; gap: 8px; z-index: 10; justify-content: space-between; align-items: center;
    background: rgba(20, 20, 30, 0.85); padding: 8px 14px; border-radius: 20px;
    margin: 4px auto 10px auto;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: nowrap;
    width: 98%;
    max-width: 1400px;
}
.towers-dock {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 213, 79, 0.4) transparent;
    padding: 4px 6px;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-start;
}
.towers-dock::-webkit-scrollbar {
    height: 4px;
}
.towers-dock::-webkit-scrollbar-thumb {
    background: rgba(255, 213, 79, 0.4);
    border-radius: 4px;
}
.build-utils-left {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 6px;
    padding-right: 12px;
    border-right: 2px solid rgba(255, 213, 79, 0.25);
    flex-shrink: 0;
}
.build-utils-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 6px;
    padding-left: 12px;
    border-left: 2px solid rgba(255, 213, 79, 0.25);
    flex-shrink: 0;
}

.tower-card, .tower-btn {
    background: linear-gradient(135deg, #2A2D3E, #1F212E);
    border: 2px solid #3F445E; border-radius: 14px;
    padding: 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
    transition: transform 0.15s, background 0.2s, border-color 0.15s, box-shadow 0.15s; outline: none;
    width: 72px; height: 72px; min-width: 72px; min-height: 72px; box-sizing: border-box; touch-action: pan-x;
    position: relative; user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none !important;
}
.tower-card *, .tower-btn * {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-user-drag: none !important;
}
.tower-card:hover, .tower-btn:hover { background: linear-gradient(135deg, #3A3E56, #2A2D3E); border-color: #FFB74D; transform: translateY(-3px); box-shadow: 0 6px 15px rgba(255, 183, 77, 0.25); }
.tower-card:active, .tower-btn:active { transform: scale(0.95); }
.tower-card.selected, .tower-btn.selected { border: 3px solid #FFD54F !important; box-shadow: 0 0 20px #FF9800, inset 0 0 12px rgba(255, 193, 7, 0.5) !important; transform: scale(1.08); background: linear-gradient(135deg, #5D3A1A, #3A220E) !important; }
.tower-card .cost, .tower-btn .cost { font-size: 0.78rem; font-weight: 800; color: #FFD54F; background: rgba(0, 0, 0, 0.55); padding: 2px 6px; border-radius: 8px; width: 100%; text-align: center; box-sizing: border-box; border: 1px solid rgba(255, 213, 79, 0.3); }
.tower-card .tower-icon, .tower-btn .tower-icon { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; overflow: hidden; margin: 2px 0; }
.tower-card .tower-icon img, .tower-btn .tower-icon img, .tower-btn .icon-img { width: 44px; height: 44px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6)); transition: transform 0.15s; }
.tower-card:hover .tower-icon img, .tower-btn:hover .tower-icon img { transform: scale(1.15); }
.tower-card .name, .tower-btn .name { display: none; }

.tower-card.locked, .tower-btn.locked {
    filter: grayscale(100%);
    opacity: 0.55;
    cursor: not-allowed;
    background: #252525 !important;
    border-color: #424242 !important;
}
.tower-card.locked:hover, .tower-btn.locked:hover {
    transform: none;
    background: #252525 !important;
}
.tower-card.locked .cost, .tower-btn.locked .cost {
    color: #FFD54F;
}

.tower-card.unaffordable:not(.locked), .tower-btn.unaffordable:not(.locked) {
    filter: grayscale(80%) brightness(0.8);
    opacity: 0.55;
    border-color: rgba(255, 255, 255, 0.2) !important;
}
.tower-card.unaffordable:not(.locked):hover, .tower-btn.unaffordable:not(.locked):hover {
    transform: none !important;
    box-shadow: none !important;
    background: rgba(30, 36, 52, 0.9) !important;
}
.tower-card.unaffordable:not(.locked) .cost, .tower-btn.unaffordable:not(.locked) .cost {
    color: #FF8A80 !important;
    border-color: rgba(255, 82, 82, 0.3) !important;
}

/* Custom Tooltip (Mouseover + Touch Longpress) */
.tower-card::after, .tower-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 108%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 22, 36, 0.96);
    color: #FAFAFA;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    width: 230px;
    min-height: 44px;
    white-space: normal;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
    box-shadow: 0 6px 18px rgba(0,0,0,0.7);
    border: 2px solid #FFD54F;
    backdrop-filter: blur(10px);
    box-sizing: border-box;
}
.tower-card:hover::after, .tower-btn:hover::after, .tower-card.show-tooltip::after, .tower-btn.show-tooltip::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-3px);
}
@media (max-width: 900px) {
    .tower-card:not(.show-tooltip)::after, .tower-btn:not(.show-tooltip)::after {
        display: none !important;
    }
    .tower-card.show-tooltip::after, .tower-btn.show-tooltip::after {
        display: flex !important;
        opacity: 1 !important;
        position: fixed !important;
        bottom: 88px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 88vw !important;
        max-width: 320px !important;
        z-index: 999999 !important;
        pointer-events: none !important;
        background: rgba(18, 22, 36, 0.96) !important;
        border: 2px solid #FFD54F !important;
        box-shadow: 0 8px 24px rgba(0,0,0,0.85) !important;
        color: #FAFAFA !important;
        padding: 10px 14px !important;
        border-radius: 12px !important;
        font-size: 0.85rem !important;
        line-height: 1.4 !important;
    }
}

/* Overlays */
.overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(10px);
    display: none; flex-direction: column; justify-content: center; align-items: center;
    color: white; z-index: 9999; text-align: center; overflow-y: auto; padding: 15px; box-sizing: border-box;
}
.overlay.active { display: flex !important; }
#pause-overlay.active { display: flex !important; z-index: 99999 !important; }

.logo {
    font-size: clamp(2.5rem, 5vw, 4.2rem);
    font-weight: 900;
    color: #FFD54F;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-shadow: 0 8px 20px rgba(0,0,0,0.7), 0 3px 0 #FFA000, 0 6px 0 #FF6F00, 0 9px 0 #E65100, 0 12px 0 #BF360C;
    background: none;
    -webkit-text-fill-color: initial;
    margin-bottom: 15px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}
.logo-emoji {
    -webkit-text-fill-color: initial;
    text-shadow: none;
    font-size: 3.5rem;
}

.overlay p { font-size: 1.3rem; margin-bottom: 20px; max-width: 80%; }
.diff-btn {
    width: 100%;
    max-width: 280px;
    margin: 5px auto;
    display: block;
    font-size: 1rem;
}

/* --- Comic Celebration Panels (Victory & Game Over) --- */
.comic-panel {
    background: linear-gradient(145deg, rgba(30, 20, 10, 0.95), rgba(15, 10, 5, 0.96));
    border: 4px solid #FFD700;
    border-radius: 24px;
    padding: 30px;
    width: 90%;
    max-width: 620px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.8), 0 0 0 6px #5D4037, inset 0 0 20px rgba(255, 215, 0, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: comicPopIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}
.comic-panel.gameover-card {
    border-color: #EF5350;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.8), 0 0 0 6px #3E2723, inset 0 0 20px rgba(239, 83, 80, 0.15);
}
@keyframes comicPopIn {
    0% { opacity: 0; transform: scale(0.6) translateY(40px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}
.panel-mascot {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: -10px;
    margin-bottom: 10px;
}
.panel-mascot img {
    width: 65px;
    height: 65px;
    object-fit: contain;
    filter: drop-shadow(0 6px 10px rgba(0,0,0,0.6));
    animation: bounceSlow 2s ease-in-out infinite alternate;
}
.panel-mascot img:nth-child(2) { animation-delay: 0.3s; }
.panel-mascot img:nth-child(3) { animation-delay: 0.6s; }

.comic-stars {
    font-size: 2.8rem;
    margin: 10px 0 15px 0;
    display: flex;
    gap: 12px;
    justify-content: center;
}
.comic-stars .star {
    filter: grayscale(100%) opacity(0.3);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.4s ease;
    transform: scale(0.8);
}
.comic-stars .star.active {
    filter: none;
    transform: scale(1.15) rotate(-5deg);
    text-shadow: 0 0 15px #FFD700;
}
.comic-stars .star.active:nth-child(2) { transform: scale(1.25) translateY(-5px); }
.comic-stars .star.active:nth-child(3) { transform: scale(1.15) rotate(5deg); }

.cleansheet-badge {
    background: linear-gradient(135deg, #FFD700, #FF8F00);
    color: #000;
    padding: 10px 20px;
    border-radius: 50px;
    margin: 10px auto 18px auto;
    font-weight: 900;
    font-size: 1.05rem;
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.6), 0 0 0 3px #FFF;
    text-transform: uppercase;
    letter-spacing: 1px;
    animation: pulse 1.5s infinite;
}
.stats-box {
    background: rgba(0, 0, 0, 0.45);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 16px;
    padding: 18px 24px;
    width: 90%;
    margin: 10px 0 22px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.15rem;
    color: #FFF;
    border-bottom: 1px dashed rgba(255,255,255,0.15);
    padding-bottom: 6px;
}
.stat-row:last-child { border-bottom: none; padding-bottom: 0; }
.panel-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    width: 100%;
}

.tut-content {
    background: rgba(0,0,0,0.2);
    padding: 15px; border-radius: 10px;
    font-size: 1.1rem; line-height: 1.5;
}
.tut-content p { margin: 10px 0; }
.tut-content h3 { margin: 10px 0 5px 0; font-size: 1.2rem; }

/* Custom Scrollbar for Lexicon */
.tut-content::-webkit-scrollbar { width: 8px; }
.tut-content::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 4px; }
.tut-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.4); border-radius: 4px; }
/* --- Elegant & Playful Start Menu --- */
#start-menu {
    background: radial-gradient(circle at center, rgba(15, 30, 15, 0.88), rgba(5, 15, 5, 0.96));
}
.menu-card {
    background: rgba(30, 50, 25, 0.75);
    backdrop-filter: blur(16px);
    border: 2px solid rgba(255, 213, 79, 0.35);
    border-radius: 30px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.15);
    padding: 35px 40px;
    max-width: 650px;
    width: 92%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: auto;
}
.menu-dackel-mascot {
    position: absolute;
    top: -55px;
    width: 85px;
    height: 85px;
    pointer-events: none;
    animation: dogBounce 0.4s ease-in-out infinite alternate;
}
.menu-dackel-mascot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 6px 10px rgba(0,0,0,0.5));
}
.mascot-left { left: 40px; transform: rotate(-8deg); }
.mascot-right { right: 40px; transform: scaleX(-1) rotate(-8deg); animation-delay: 0.2s; }

.menu-card .logo {
    font-size: 3.2rem;
    margin-top: 10px;
    margin-bottom: 25px;
}

/* Top Actions (Resume / Endless) */
.menu-top-actions {
    display: flex;
    gap: 15px;
    width: 100%;
    margin-bottom: 15px;
}
.btn-resume, .btn-endless {
    flex: 1;
    padding: 14px !important;
    font-size: 1.15rem !important;
    border-radius: 16px !important;
}
.btn-resume { background: linear-gradient(135deg, #43A047, #2E7D32) !important; border-color: #81C784 !important; }
.btn-endless { background: linear-gradient(135deg, #8E24AA, #6A1B9A) !important; border-color: #BA68C8 !important; }

/* Hero Campaign Button */
.btn-hero-campaign {
    width: 100%;
    background: linear-gradient(135deg, #00897B, #00695C) !important;
    border: 3px solid #4DB6AC !important;
    border-radius: 20px !important;
    padding: 16px 22px !important;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 137, 123, 0.4) !important;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    margin-bottom: 25px;
}
.btn-hero-campaign:hover {
    background: linear-gradient(135deg, #009688, #00796B) !important;
    transform: translateY(-4px) scale(1.02) !important;
    box-shadow: 0 12px 30px rgba(0, 137, 123, 0.6) !important;
}
.hero-icon { font-size: 2.5rem; margin-right: 15px; }
.hero-text { display: flex; flex-direction: column; flex: 1; }
.hero-title { font-size: 1.4rem; font-weight: 800; color: white; text-shadow: 1px 1px 2px rgba(0,0,0,0.5); }
.hero-sub { font-size: 0.95rem; font-weight: 400; color: #B2DFDB; margin-top: 2px; }
.hero-arrow { font-size: 1.8rem; color: #B2DFDB; font-weight: bold; transition: transform 0.2s; }
.btn-hero-campaign:hover .hero-arrow { transform: translateX(5px); color: white; }

/* Divider */
.menu-divider {
    width: 100%;
    display: flex;
    align-items: center;
    text-align: center;
    color: rgba(255,255,255,0.6);
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 18px;
}
.menu-divider::before, .menu-divider::after {
    content: '';
    flex: 1;
    border-bottom: 2px solid rgba(255,255,255,0.15);
}
.menu-divider span { padding: 0 15px; text-transform: uppercase; letter-spacing: 1px; }

/* Difficulty Grid */
.menu-diff-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    margin-bottom: 25px;
}
.diff-card {
    background: rgba(0,0,0,0.3) !important;
    border: 2px solid rgba(255,255,255,0.15) !important;
    border-radius: 16px !important;
    padding: 14px 10px !important;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.diff-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 6px 15px rgba(0,0,0,0.4) !important;
}
.diff-easy:hover { background: rgba(139, 195, 74, 0.25) !important; border-color: #8BC34A !important; }
.diff-medium:hover { background: rgba(255, 152, 0, 0.25) !important; border-color: #FF9800 !important; }
.diff-hard:hover { background: rgba(244, 67, 54, 0.25) !important; border-color: #F44336 !important; }

.diff-header { font-size: 1.05rem; font-weight: 700; color: white; margin-bottom: 6px; display: flex; align-items: center; gap: 5px; justify-content: center; }
.diff-desc { font-size: 0.8rem; font-weight: 400; color: #DDD; line-height: 1.3; }
.diff-desc b { color: #FFD54F; }

/* Footer Bar */
.menu-footer-bar {
    display: flex;
    gap: 15px;
    width: 100%;
    border-top: 2px solid rgba(255,255,255,0.12);
    padding-top: 20px;
}
.btn-util {
    flex: 1;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    background: rgba(255,255,255,0.08) !important;
    border: 2px solid rgba(255,255,255,0.2) !important;
    border-radius: 14px !important;
    padding: 12px 16px !important;
    font-size: 1.05rem !important;
    font-weight: 600 !important;
    color: #EEE !important;
    transition: all 0.2s;
    cursor: pointer;
}
.btn-util:hover {
    background: rgba(255,255,255,0.18) !important;
    border-color: rgba(255,255,255,0.4) !important;
    color: white !important;
    transform: translateY(-2px) !important;
}

@media (max-width: 600px) {
    .menu-diff-grid { grid-template-columns: 1fr; }
    .menu-card { padding: 25px 20px; }
    .menu-dackel-mascot { width: 65px; height: 65px; top: -45px; }
    .mascot-left { left: 20px; }
    .mascot-right { right: 20px; }
    .hero-icon { font-size: 2rem; }
    .hero-title { font-size: 1.2rem; }
}

button, [onclick], .tower-card, .top-control-item, .btn-hero-campaign, .diff-card, .level-grid-btn {
    cursor: pointer;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
}

.overlay button, #upgrade-menu button {
    background: var(--primary); border: 3px solid var(--primary-dark); color: white;
    font-family: 'Fredoka', sans-serif; font-size: 1.2rem; font-weight: 600;
    padding: 15px 30px; border-radius: 15px; cursor: pointer; transition: transform 0.1s, background 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.overlay button:hover, #upgrade-menu button:hover { background: #FFB74D; transform: translateY(-3px); }
.overlay button:active, #upgrade-menu button:active { transform: scale(0.95); }

/* Upgrade Menu */
#upgrade-menu {
    position: absolute; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px;
    background: rgba(255,255,255,0.95); padding: 12px; border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4); z-index: 20;
    transform: translate(-50%, -120%);
    pointer-events: auto;
    width: 320px;
    min-height: 64px;
    box-sizing: border-box;
}
#upgrade-menu.hidden { display: none; }
#upgrade-menu button { height: 40px; padding: 0 10px; font-size: 0.9rem; border-radius: 8px; border-width: 2px; color: white; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; font-weight: bold;}
#btn-upgrade { flex: 1 1 150px; min-width: 150px; }
#btn-sell { flex: 1 1 110px; min-width: 110px; background: #E53935; border-color: #C62828; }
#btn-close-upgrade { width: 40px; min-width: 40px; padding: 0; background: #757575; border-color: #424242;}
#btn-sell:hover { background: #EF5350; }

/* ==========================================================================
   ULTIMATE MOBILE LANDSCAPE & TOUCH OPTIMIZATION
   Triggered on tablets, smartphones, and short height screens (Querformat)
   ========================================================================== */
@media (max-width: 1024px), (max-height: 580px) {
    /* 2. Fullscreen Game Container */
    #game-container { 
        border-radius: 0 !important; 
        width: 100vw !important; 
        height: 100vh !important; 
        height: 100dvh !important; 
        max-width: none !important; 
        max-height: none !important; 
        box-shadow: none !important; 
        display: flex !important; 
        flex-direction: column !important; 
        justify-content: space-between !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #0d121c !important;
        z-index: 1 !important;
    }

    /* 3. Floating HUD Overlays (Top-Left Stats, Top-Right Controls) */
    .game-top-bar {
        top: max(6px, env(safe-area-inset-top)) !important;
        left: max(8px, env(safe-area-inset-left)) !important;
        right: max(8px, env(safe-area-inset-right)) !important;
    }
    #hud-stats-bar, #hud, .top-controls-hud {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        z-index: 15 !important;
        margin: 0 !important;
        position: static !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
    }
    #hud-stats-bar {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        padding: 0 !important;
    }
    #hud, .top-controls-hud {
        padding: 4px 10px !important;
        width: auto !important;
        min-height: 32px !important;
        background: rgba(15, 20, 32, 0.82) !important;
        border: 1px solid rgba(255, 213, 79, 0.4) !important;
        border-radius: 20px !important;
        box-shadow: 0 4px 10px rgba(0,0,0,0.6) !important;
        backdrop-filter: blur(8px) !important;
    }
    .top-right-group {
        padding: 4px !important;
        gap: 4px !important;
        border-radius: 14px !important;
    }
    .top-control-item {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        font-size: 1.1rem !important;
        border-radius: 10px !important;
    }
    .speed-toggle-btn {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        padding: 0 !important;
    }
    .hud-group { 
        gap: 6px !important; 
        display: flex !important;
        flex-direction: row !important; 
        flex-wrap: nowrap !important; 
        align-items: center !important; 
    }
    .stat { font-size: 0.82rem !important; padding: 2px 6px !important; border-radius: 10px !important; }
    .size-stat, .size-toggle-btn, .volume-container { display: none !important; } /* Resolution toggle and volume slider are desktop-only */

    /* 4. Main Area & Canvas (Spielfeld im absoluten Mittelpunkt!) */
    #main-area { 
        flex: 1 !important; 
        display: flex !important; 
        justify-content: center !important; 
        align-items: center !important; 
        min-height: 0 !important; 
        overflow: hidden !important; 
        padding: 0 !important;
        width: 100% !important;
        height: 100% !important;
    }
    #canvas-container { 
        width: 100% !important; 
        height: 100% !important; 
        display: flex !important; 
        justify-content: center !important; 
        align-items: center !important; 
    }
    canvas { 
        width: 100% !important; 
        height: 100% !important; 
        max-width: 100% !important; 
        max-height: 100% !important; 
        object-fit: contain !important; 
    }

    /* 5. Ergonomic Touch Build Menu Drawer (Footer) */
    #build-menu { 
        position: relative !important;
        height: auto !important; 
        min-height: 58px !important; 
        max-height: 66px !important; 
        padding: 4px 8px !important; 
        gap: 8px !important; 
        justify-content: flex-start !important; 
        overflow: hidden !important; 
        margin: 0 auto max(24px, env(safe-area-inset-bottom, 24px)) auto !important;
        padding: 4px max(8px, env(safe-area-inset-right)) 4px max(8px, env(safe-area-inset-left)) !important;
        width: 98% !important;
        max-width: 780px !important;
        z-index: 15 !important;
        background: rgba(18, 22, 36, 0.9) !important;
        border-radius: 18px !important;
        border: 1.5px solid rgba(255, 255, 255, 0.15) !important;
    }
    #build-menu::-webkit-scrollbar { display: none !important; }
    .towers-dock {
        gap: 6px !important;
        padding: 2px !important;
        flex: 1 1 0 !important;
        min-width: 0 !important;
        justify-content: flex-start !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        touch-action: pan-x !important;
    }
    .build-utils-left {
        margin-right: 4px !important;
        padding-right: 6px !important;
    }
    .build-utils-right {
        margin-left: 4px !important;
        padding-left: 6px !important;
    }
    .superpower-btn {
        width: 46px !important;
        height: 46px !important;
        border-radius: 12px !important;
    }
    .superpower-btn .super-icon-stack {
        font-size: 1.1rem !important;
        letter-spacing: -2px !important;
    }
    .tower-card, .tower-btn { 
        width: 52px !important; 
        height: 52px !important; 
        min-width: 52px !important; 
        min-height: 52px !important;
        border-radius: 12px !important; 
        border-width: 2px !important; 
        padding: 2px !important; 
        touch-action: pan-x !important;
    }
    .tower-icon { font-size: 1.4rem !important; }
    .tower-icon img { width: 34px !important; height: 34px !important; }
    .cost { font-size: 0.65rem !important; padding: 1px 4px !important; }
    .tower-card:not(.show-tooltip)::after, .tower-btn:not(.show-tooltip)::after { display: none !important; }

    /* 6. Compact Upgrade Popup for Touch */
    #upgrade-menu { 
        padding: 8px !important; 
        gap: 6px !important; 
        border-radius: 12px !important; 
        z-index: 25 !important;
        width: 280px !important;
        min-height: 52px !important;
    }
    #upgrade-menu button { height: 36px !important; padding: 0 6px !important; font-size: 0.8rem !important; }
    #btn-upgrade { flex: 1 1 130px !important; min-width: 130px !important; }
    #btn-sell { flex: 1 1 95px !important; min-width: 95px !important; }
    #btn-close-upgrade { width: 36px !important; min-width: 36px !important; }

    /* 7. Overlay Screens fit inside short landscape screens */
    .overlay {
        padding: 10px 10px 40px 10px !important;
        align-items: center !important;
        justify-content: flex-start !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        height: 100vh !important;
        height: 100dvh !important;
    }
    .menu-card, .tut-content, .lexicon-card, .comic-panel, #level-select > div, #level-start > div, #victory-overlay > div, #level-complete > div, #game-over > div, #trophy-overlay > div, #highscore-overlay > div, #pause-overlay > div {
        max-height: 76vh !important;
        max-height: 76dvh !important;
        width: 94vw !important;
        max-width: 600px !important;
        padding: 10px 12px !important;
        margin: 6px auto !important;
        overflow-y: auto !important;
        flex-shrink: 0 !important;
        border-radius: 14px !important;
        border-width: 2px !important;
        font-size: 0.85rem !important;
        line-height: 1.35 !important;
    }
    #level-start h1, #level-complete h1, #game-over h1, #start-menu h1, .tut-content h2, .lexicon-card h2, #trophy-overlay h2 {
        font-size: clamp(1.1rem, 3.2vh, 1.5rem) !important;
        margin: 4px 0 !important;
    }
    #level-start p, #level-complete p, #game-over p, .tut-content p, .lexicon-card p {
        font-size: clamp(0.8rem, 2vh, 0.92rem) !important;
        margin: 4px 0 !important;
    }
    #ls-enemies {
        margin: 6px auto 10px auto !important;
        max-height: 25vh !important;
        overflow-y: auto !important;
    }
    .bombastic-title {
        font-size: clamp(1.6rem, 4.5vw, 2.4rem) !important;
        margin-top: 4px !important;
        margin-bottom: 8px !important;
        letter-spacing: 2px !important;
    }
    .menu-dackel-mascot {
        width: 44px !important;
        height: 44px !important;
        top: -22px !important;
    }
    .mascot-left { left: 10px !important; }
    .mascot-right { right: 10px !important; }
    .overlay button {
        padding: 6px 14px !important;
        font-size: clamp(0.85rem, 2.2vh, 1rem) !important;
        margin: 4px auto !important;
        border-radius: 10px !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    .menu-diff-grid {
        gap: 6px !important;
        margin: 6px 0 !important;
    }
    .diff-card {
        padding: 6px !important;
    }
    .diff-header {
        font-size: 0.85rem !important;
    }
    .diff-desc {
        font-size: 0.72rem !important;
    }
    .menu-footer-bar {
        gap: 6px !important;
        margin-top: 8px !important;
    }
    .btn-util {
        padding: 6px 10px !important;
        font-size: 0.8rem !important;
    }
    .btn-hero-campaign {
        padding: 8px 12px !important;
        margin: 6px auto !important;
    }
    .hero-title { font-size: 1.05rem !important; }
    .hero-sub { font-size: 0.75rem !important; }
    #tutorial-overlay .tut-content div[style*="grid-template-columns"] {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        margin-bottom: 12px !important;
    }
    #tutorial-overlay .tut-content div[style*="padding: 18px"] {
        padding: 8px !important;
    }
    #level-grid {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr)) !important;
        gap: 8px !important;
        max-height: 58vh !important;
        overflow-y: auto !important;
        padding: 6px !important;
    }
    .level-grid-btn {
        height: 65px !important;
        font-size: 0.9rem !important;
    }
    .lexicon-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        max-height: 58vh !important;
    }
    .lexicon-item {
        padding: 8px !important;
    }
}

/* Highscore Table */
.highscore-table {
    width: 100%; border-collapse: collapse; margin-top: 15px; font-size: 1rem;
    background: rgba(255,255,255,0.9); border-radius: 8px; overflow: hidden; color: #333;
}
.highscore-table th, .highscore-table td {
    padding: 10px 14px; border-bottom: 1px solid rgba(0,0,0,0.1); text-align: left;
}
.highscore-table th { background: #FF9800; color: white; font-weight: bold; }
.highscore-table tr:nth-child(even) { background: rgba(0,0,0,0.05); }

/* Early wave button animation & distinctive energetic style inside unified controls box */
#btn-early-wave {
    background: rgba(0, 230, 118, 0.22);
    border-color: rgba(0, 230, 118, 0.6);
    color: #FFF;
    animation: earlyPulseUnified 1.5s infinite alternate;
}
@keyframes earlyPulseUnified {
    from { box-shadow: 0 0 4px rgba(0, 230, 118, 0.3); }
    to { box-shadow: 0 0 14px rgba(105, 240, 174, 0.8); border-color: #FFF; }
}
#btn-early-wave:hover {
    background: #00E676;
    color: #000;
    border-color: #FFF;
    box-shadow: 0 0 18px #00E676;
}

/* --- Superwaffe Button (Knochenregen - Quadratisch & Kompakt) --- */
.superpower-btn {
    background: linear-gradient(135deg, #FFD700, #FF6F00);
    color: #000;
    border: 2.5px solid #FFF;
    width: 58px;
    height: 58px;
    padding: 0;
    border-radius: 16px;
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    font-weight: 800;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.5), inset 0 2px 3px rgba(255, 255, 255, 0.4);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: superPulse 1.5s infinite alternate;
    position: relative;
    user-select: none;
}
.superpower-btn .super-icon-stack {
    font-size: 1.3rem;
    line-height: 1;
    letter-spacing: -3px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}
.superpower-btn:hover .super-icon-stack {
    transform: scale(1.15);
}
.superpower-btn #super-cooldown {
    position: absolute;
    font-size: 1.15rem;
    font-weight: 900;
    color: #FFF;
    text-shadow: 0 0 4px #000, 0 1px 3px #000, 0 -1px 2px #000;
    z-index: 2;
}
@keyframes superPulse {
    from { box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4); transform: scale(1); }
    to { box-shadow: 0 6px 22px rgba(255, 143, 0, 0.9); border-color: #FFF; transform: scale(1.06); }
}
.superpower-btn:hover {
    background: linear-gradient(135deg, #FFF176, #FF9800);
    transform: translateY(-3px) scale(1.08);
}
.superpower-btn.on-cooldown {
    background: #424242 !important;
    border-color: #757575 !important;
    box-shadow: none !important;
    animation: none !important;
    cursor: not-allowed;
    transform: none !important;
}
.superpower-btn.on-cooldown .super-icon-stack {
    opacity: 0.35;
    filter: grayscale(100%);
    transform: none !important;
}

/* --- Achievement Toast Notification --- */
.achievement-toast {
    position: fixed;
    top: -120px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #1b5e20, #003300);
    border: 3px solid #FFD700;
    color: #FFD700;
    padding: 14px 28px;
    border-radius: 50px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 900;
    font-size: 1.25rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8), 0 0 20px rgba(255, 215, 0, 0.6);
    z-index: 100000;
    pointer-events: none;
    opacity: 0;
    transition: top 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}
.achievement-toast.show {
    top: 30px;
    opacity: 1;
}

/* --- Trophy Room Cards --- */
.trophy-card {
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
    text-align: left;
}
.trophy-card.unlocked {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 143, 0, 0.1));
    border-color: #FFD700;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.25);
}
.trophy-card.locked {
    filter: grayscale(100%) opacity(0.5);
    border-color: #757575;
}
.trophy-icon {
    font-size: 2.8rem;
    min-width: 60px;
    text-align: center;
}
.trophy-info h3 {
    margin: 0 0 4px 0;
    font-size: 1.15rem;
    color: #FFD700;
}
.trophy-card.locked .trophy-info h3 {
    color: #BDBDBD;
}
.trophy-info p {
    margin: 0;
    font-size: 0.9rem;
    color: #E0E0E0;
    line-height: 1.3;
}

/* Bombastic Intro Overlay Styles */
#intro-overlay {
    background: radial-gradient(circle at center, #2E7D32 0%, #1B5E20 50%, #052507 100%);
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    cursor: pointer;
}
.bombastic-title {
    font-size: clamp(3.5rem, 9vw, 7.5rem);
    font-weight: 900;
    color: #FFD54F;
    text-transform: uppercase;
    letter-spacing: 6px;
    text-shadow: 0 10px 25px rgba(0,0,0,0.7), 0 3px 0 #FFA000, 0 6px 0 #FF6F00, 0 9px 0 #E65100, 0 12px 0 #BF360C;
    margin-bottom: 8vh; margin-top: -20vh;
    animation: bombasticPulse 2s ease-in-out infinite alternate;
    z-index: 10;
}
@keyframes bombasticPulse {
    0% { transform: scale(1) translateY(0); }
    100% { transform: scale(1.05) translateY(-10px); }
}
.intro-fullscreen-track {
    display: flex;
    position: absolute;
    bottom: 15vh;
    left: 0;
    width: 100vw;
    justify-content: center;
    align-items: center;
    gap: 45px;
    animation: runIntoCenter 3.8s cubic-bezier(0.15, 0.85, 0.35, 1) forwards;
}
@keyframes runIntoCenter {
    0% { transform: translateX(-120vw); }
    100% { transform: translateX(0); }
}
#intro-overlay.fade-to-black {
    transition: opacity 1.2s ease-in-out, background 1.2s ease-in-out;
    background: #000000 !important;
    opacity: 0;
    pointer-events: none;
}
#intro-overlay.fade-to-black * {
    transition: opacity 0.8s ease-in-out;
    opacity: 0;
}
.intro-fullscreen-track .intro-sprite {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: dogBounce 0.35s ease-in-out infinite alternate;
}
@keyframes dogBounce {
    0% { transform: translateY(0) rotate(-3deg); }
    100% { transform: translateY(-15px) rotate(3deg); }
}
.intro-fullscreen-track .intro-sprite img {
    width: 130px;
    height: 130px;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.6));
}
.intro-bubble {
    position: absolute;
    top: -35px;
    background: white;
    color: #333;
    padding: 5px 12px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
    animation: bubbleFloat 1s ease-in-out infinite alternate;
}
.intro-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: white transparent;
    display: block;
    width: 0;
}
@keyframes bubbleFloat {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(-4px) scale(1.08); }
}

/* 100 Level Grid Styles */
.level-grid-btn {
    background: linear-gradient(135deg, #43A047, #1B5E20);
    color: #FAFAFA;
    border: 2px solid #81C784;
    border-radius: 12px;
    padding: 10px 4px;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 10px rgba(0,0,0,0.35), inset 0 1px 2px rgba(255,255,255,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 4px;
    line-height: 1.2;
}
.level-grid-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 16px rgba(0,0,0,0.45), inset 0 1px 2px rgba(255,255,255,0.3);
    background: linear-gradient(135deg, #66BB6A, #2E7D32);
    border-color: #A5D6A7;
}
.level-grid-btn.locked {
    background: linear-gradient(135deg, rgba(30, 38, 56, 0.85), rgba(18, 22, 36, 0.85));
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #78909C;
    cursor: not-allowed;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
}
.level-grid-btn.locked:hover {
    transform: none;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
    background: linear-gradient(135deg, rgba(30, 38, 56, 0.85), rgba(18, 22, 36, 0.85));
    border-color: rgba(255, 255, 255, 0.12);
}
.level-grid-btn.boss {
    background: linear-gradient(135deg, #D32F2F, #8E0000);
    border-color: #FF8A80;
    box-shadow: 0 0 12px rgba(211, 47, 47, 0.5), inset 0 1px 2px rgba(255,255,255,0.25);
}
.level-grid-btn.boss:hover {
    background: linear-gradient(135deg, #E53935, #B71C1C);
    border-color: #FFCDD2;
    box-shadow: 0 0 18px rgba(229, 57, 53, 0.8);
}

/* ==========================================================================
   ULTIMATE MOBILE PORTRAIT (HOCHFORMAT) OPTIMIZATION
   Applies to smartphones & vertical screens (e.g., width <= 768px, orientation: portrait)
   ========================================================================== */
@media (max-width: 768px) and (orientation: portrait), (max-width: 480px) {
    /* 1. Overlay Container & Scrolling in Portrait */
    .overlay {
        padding: 20px 12px 45px 12px !important;
        justify-content: center !important;
        align-items: center !important;
        overflow-y: auto !important;
        height: 100vh !important;
        height: 100dvh !important;
    }

    /* 2. All Menu Cards & Modal Boxes */
    .menu-card, .tut-content, .lexicon-card, .comic-panel, #level-select > div, #level-start > div, #victory-overlay > div, #level-complete > div, #game-over > div, #trophy-overlay > div, #highscore-overlay > div, #pause-overlay > div {
        width: 94vw !important;
        max-width: 440px !important;
        max-height: 82vh !important;
        max-height: 82dvh !important;
        padding: 24px 18px 40px 18px !important;
        margin: auto !important;
        border-radius: 20px !important;
        border-width: 3px !important;
        box-shadow: 0 12px 35px rgba(0,0,0,0.85) !important;
        font-size: 0.98rem !important;
        line-height: 1.45 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    /* 3. Start Menu (#start-menu & .menu-card) - Borderless & No-Scroll on Mobile */
    #start-menu .menu-card {
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        width: 100% !important;
        max-width: 460px !important;
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
        padding: 4px 10px 14px 10px !important;
    }
    .bombastic-title {
        font-size: clamp(1.35rem, 5.8vw, 1.95rem) !important;
        letter-spacing: 1.2px !important;
        margin: -15vh 0 10px 0 !important;
        line-height: 1.1 !important;
        text-align: center !important;
        word-break: break-word !important;
    }
    #startscreen-stats-pill {
        margin: 0 auto 10px auto !important;
        padding: 6px 10px !important;
    }
    .menu-dackel-mascot {
        width: 44px !important;
        height: 44px !important;
        top: -20px !important;
    }
    .mascot-left { left: 10px !important; }
    .mascot-right { right: 10px !important; }
    /* Hide decorative rotated side-mascots on mobile so they don't overlap edges */
    .menu-card .menu-dackel-mascot[style*="left: -35px"],
    .menu-card .menu-dackel-mascot[style*="right: -35px"] {
        display: none !important;
    }

    /* 4. Hero Campaign Button */
    .btn-hero-campaign {
        width: 100% !important;
        padding: 11px 12px !important;
        margin: 4px auto 8px auto !important;
        border-radius: 14px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        box-sizing: border-box !important;
    }
    .hero-icon { font-size: 1.7rem !important; }
    .hero-title { font-size: 1.1rem !important; display: block !important; }
    .hero-sub { font-size: 0.78rem !important; display: block !important; }

    /* Half-Width Hero Buttons inside 2-Column Grid on Mobile */
    .btn-hero-half {
        padding: 10px 8px !important;
        gap: 6px !important;
        border-radius: 14px !important;
    }
    .btn-hero-half .hero-icon { font-size: 1.35rem !important; }
    .btn-hero-half .hero-title { font-size: 0.95rem !important; line-height: 1.15 !important; }
    .btn-hero-half .hero-sub { font-size: 0.72rem !important; line-height: 1.15 !important; }

    .menu-diff-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        width: 100% !important;
        margin: 14px 0 !important;
    }
    .diff-card {
        width: 100% !important;
        padding: 14px !important;
        min-height: 68px !important;
        border-radius: 16px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: border-box !important;
    }
    .diff-header {
        font-size: 1.1rem !important;
        margin-bottom: 4px !important;
    }
    .diff-desc {
        font-size: 0.88rem !important;
    }

    /* 5. Meta-Gameplay 2x2 Grid (Uniform size) */
    #start-menu-new-game-section > div[style*="grid-template-columns"] {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* 6. Footer Bar Buttons (Uniform 3-Column Grid) */
    .menu-footer-bar {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 8px !important;
        width: 100% !important;
        margin-top: 14px !important;
        padding-top: 14px !important;
        box-sizing: border-box !important;
    }
    .menu-footer-bar .btn-util {
        flex: 1 1 calc(33.333% - 8px) !important;
        min-width: 95px !important;
        height: 44px !important;
        min-height: 44px !important;
        padding: 6px 4px !important;
        font-size: 0.78rem !important;
        margin: 0 !important;
    }
    .btn-util {
        padding: 10px !important;
        font-size: 0.95rem !important;
        height: 54px !important;
        min-height: 54px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 12px !important;
        text-align: center !important;
        box-sizing: border-box !important;
        width: 100% !important;
    }

    /* 7. Level Selection Grid */
    #level-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)) !important;
        gap: 10px !important;
        max-height: 68vh !important;
        max-height: 68dvh !important;
        padding: 10px !important;
        margin: 15px 0 !important;
    }
    .level-grid-btn {
        height: 72px !important;
        font-size: 0.95rem !important;
        border-radius: 14px !important;
        padding: 8px 4px !important;
    }

    /* 8. Tutorial, Lexicon & Trophy Grids (Single Column Stacked) */
    #tutorial-overlay .tut-content div[style*="grid-template-columns"],
    #lexicon-content,
    #trophy-content {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .tut-content h2, .lexicon-card h2, #trophy-overlay h2, #highscore-overlay h2 {
        font-size: 1.5rem !important;
        margin-bottom: 12px !important;
    }
    .tut-content p, .tut-content li, .lexicon-card p {
        font-size: 0.95rem !important;
        line-height: 1.45 !important;
    }
    .lexicon-item, .trophy-item {
        padding: 14px !important;
        font-size: 0.95rem !important;
        border-radius: 14px !important;
    }

    /* 9. General Modal Buttons */
    .overlay button {
        padding: 12px 24px !important;
        font-size: 1.05rem !important;
        min-height: 48px !important;
        margin: 8px auto !important;
        border-radius: 14px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}



@media (max-width: 900px) {
    #mobile-menu-toggle { display: flex !important; }
    #top-right-group.collapsed { display: none !important; }
}
