* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}
body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Premium off-grey center transitioning into a dark vignette */
    background: radial-gradient(circle, #2d2d2d 0%, #121212 100%);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: #f5f0eb;
}
.canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: grab;
    touch-action: none;
}
.canvas-container:active {
    cursor: grabbing;
}
canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}
/* Separated liquid layers with independent 3D specular shading filters */
#beerCanvas {
    filter: url('#beer-goo');
    z-index: 2;
}
#foamCanvas {
    filter: url('#foam-goo');
    z-index: 3;
}
#glassCanvas {
    z-index: 4;
}
#bgCanvas {
    z-index: 1;
}
.ui-container {
    position: absolute;
    top: 25px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none; /* Let drag events fall through outside the card */
    text-align: center;
    width: 90%;
    max-width: 500px; /* Tightened bounding box */
}
.ui-card {
    position: relative;
    background: rgba(12, 12, 12, 0.35); /* More transparent card background */
    border: 1px solid rgba(212, 120, 10, 0.12); /* Extremely subtle, immersion-safe border */
    border-radius: 10px;
    padding: 12px 25px 18px 25px; /* Symmetrical padding, with extra bottom padding for absolute toggle on desktop */
    pointer-events: auto; /* Restore interaction for text if needed */
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}
.dropdown-toggle {
    position: absolute;
    bottom: 6px;
    right: 15px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: #bfa38a;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    background: rgba(12, 12, 12, 0.65);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid rgba(212, 120, 10, 0.2);
}
.desktop-only {
    display: inline !important;
}
.mobile-only {
    display: none !important;
}
.dropdown-toggle:hover {
    color: #ffe0a3;
    background: rgba(212, 120, 10, 0.15);
    border-color: rgba(212, 120, 10, 0.4);
    transform: scale(1.02);
}
.dropdown-toggle .arrow {
    font-size: 0.6rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-block;
}
.dropdown-toggle.open .arrow {
    transform: rotate(180deg);
}
.dropdown-toggle .click-text {
    font-family: 'Arbutus Slab', serif;
}
.dropdown-box {
    width: 100%;
    margin-top: 10px;
    background-color: #b07d50; /* Cork base color fallback */
    background-image: linear-gradient(rgba(0, 0, 0, 0.58), rgba(0, 0, 0, 0.58)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='cork'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' result='noise'/%3E%3CfeDiffuseLighting in='noise' lighting-color='%23eedcbd' surfaceScale='2.5' result='light'%3E%3CfeDistantLight azimuth='45' elevation='55'/%3E%3C/feDiffuseLighting%3E%3CfeBlend mode='multiply' in='SourceGraphic' in2='light'/%3E%3C/filter%3E%3Crect width='180' height='180' fill='%23b07d50' filter='url(%23cork)'/%3E%3C/svg%3E");
    background-size: cover;
    border: 1px solid rgba(212, 120, 10, 0.12); /* Match the title box (ui-card) border */
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(0, 0, 0, 0.8);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    pointer-events: none;
    transform: translateY(-10px);
    text-align: center;
}
.dropdown-box.open {
    opacity: 1;
    max-height: 260px;
    pointer-events: auto;
    transform: translateY(0);
}
.dropdown-header {
    margin: 0 0 10px 0;
    font-family: 'Arbutus Slab', serif;
    font-size: 1.15rem;
    color: #ffe0a3;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95);
    font-weight: bold;
    text-align: center;
}
.dropdown-list {
    margin: 0;
    padding: 0 0 0 5px;
    text-align: left;
    list-style-type: none; /* Hide default bullets */
}
.dropdown-list li {
    margin: 8px 0;
    font-family: 'Arbutus Slab', serif;
    font-size: 0.9rem;
    line-height: 1.35;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
    position: relative;
    padding-left: 22px; /* Indent to make space for emoji */
}
.dropdown-list li::before {
    content: "📌";
    position: absolute;
    left: 0;
    top: 2px; /* Align precisely with the first line of text */
    font-size: 0.85rem;
}
.dropdown-list li .item-link {
    text-decoration: none;
    transition: color 0.15s ease;
}
.dropdown-list li .item-link:hover .item-title {
    color: #ff9f3b; /* Amber hover highlight */
    text-decoration: underline;
}
.dropdown-list li .item-title {
    font-weight: 900;
    color: #ffe0a3;
    cursor: pointer;
}
.dropdown-list li .hyphen {
    color: rgba(255, 224, 163, 0.45); /* Grey/muted amber hyphen */
    margin: 0 4px;
}
.dropdown-list li .item-desc {
    font-size: 0.8rem; /* Reduced size */
    color: rgba(255, 224, 163, 0.7); /* Softer amber/grey text */
    font-weight: normal;
}
h1 {
    margin: 0 0 6px 0; /* Tightened vertical gap */
    font-family: 'Ultra', serif; /* Solid, thick vintage American wood type */
    font-size: 1.95rem; /* Scaled up for better visibility */
    font-weight: normal;
    letter-spacing: 0.5px;
    color: #ffe0a3;
    text-shadow: 0 3px 6px rgba(0,0,0,0.9);
    line-height: 1.25;
}
.subtext-main {
    margin: 0 0 3px 0; /* Tightened spacing above the secondary subtext */
    font-family: 'Arbutus Slab', serif; /* Sturdy, clean 19th-century billboard slab */
    font-size: 1.05rem; /* Scaled up for readability */
    color: #bfa38a;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
.subtext-mobile {
    display: none !important;
    margin: 0;
    font-family: 'Arbutus Slab', serif;
    font-size: 0.8rem; /* Scaled up for readability */
    color: rgba(191, 163, 138, 0.65); /* Slightly muted, transparent shade for visual hierarchy */
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* Dedicated Sidebar Controls on the Right Edge */
.right-controls {
    position: absolute;
    top: 50%;
    right: 25px;
    transform: translateY(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 15px;
    pointer-events: auto;
    align-items: flex-end; /* Grows leftward, preserving right-margin alignment */
}
.right-controls button {
    background: rgba(212, 120, 10, 0.12);
    border: 1px solid rgba(212, 120, 10, 0.3);
    color: #ffe0a3;
    padding: 10px; /* Symmetrical padding for circular default state */
    border-radius: 30px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    white-space: nowrap;
    max-width: 45px; /* Sized exactly to contain only the emoji */
    height: 45px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Bouncy pop-out transition */
}
.right-controls button .emoji {
    font-size: 1.15rem;
    display: inline-block;
    transition: transform 0.25s ease;
}
.right-controls button .btn-text {
    font-size: 0.85rem;
    opacity: 0;
    max-width: 0;
    display: inline-block;
    overflow: hidden;
    transition: opacity 0.2s ease, max-width 0.25s ease, margin-left 0.25s ease;
    margin-left: 0;
}

/* Desktop Hover Pop-out States */
.right-controls button:hover {
    background: rgba(212, 120, 10, 0.35);
    border-color: #ffca66;
    max-width: 160px; /* Expands to fit the sliding text */
    padding: 10px 18px; /* Restores wider landscape button padding */
    box-shadow: 0 8px 20px rgba(212, 120, 10, 0.25);
    transform: scale(1.05);
}
.right-controls button:hover .btn-text {
    opacity: 1;
    max-width: 100px;
    margin-left: 8px; /* Adds space once text is revealed */
}
.right-controls button:hover .emoji {
    transform: scale(1.1);
}
.right-controls button:active {
    transform: scale(0.95);
}

.mobile-controls {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 25px;
    z-index: 10;
    pointer-events: auto;
}
.tilt-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
}
.tilt-btn:active {
    background: rgba(255, 255, 255, 0.25);
}

/* Styled Bottom Navigation Elements */
.github-link {
    position: absolute;
    bottom: 25px;
    right: 25px;
    z-index: 10;
    pointer-events: auto;
}
.github-link a {
    color: #bfa38a;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.15s ease;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.github-link a:hover {
    color: #ffe0a3;
}
.performance-btn {
    position: absolute;
    bottom: 95px; /* Floats just above the 80px wooden table */
    right: 25px; /* Tucked in the bottom right corner */
    width: 36px;
    height: 36px;
    border-radius: 18px;
    z-index: 10;
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.03); /* Extremely semi-transparent */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(191, 163, 138, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(2px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 0.95rem;
    overflow: hidden;
    white-space: nowrap;
    width: 36px; /* Sized exactly to contain only the emoji */
    padding: 0;
}
.performance-btn .emoji {
    font-size: 0.85rem;
    display: inline-block;
    transition: transform 0.25s ease;
}
.performance-btn .btn-text {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.75rem;
    opacity: 0;
    max-width: 0;
    display: inline-block;
    overflow: hidden;
    transition: opacity 0.2s ease, max-width 0.25s ease, margin-left 0.25s ease;
    margin-left: 0;
}
.performance-btn:hover {
    background: rgba(212, 120, 10, 0.15); /* Sleek matching copper glow on hover */
    border-color: rgba(212, 120, 10, 0.35);
    color: #ffe0a3;
    width: 150px; /* Expands to fit the sliding text */
    padding: 0 12px; /* Restores wider landscape button padding */
}
.performance-btn:hover .btn-text {
    opacity: 1;
    max-width: 100px;
    margin-left: 6px;
}
.performance-btn:hover .emoji {
    transform: scale(1.1);
}
.performance-btn:active {
    transform: scale(0.95);
}
.gemini-credit {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    color: #bfa38a;
    opacity: 0.5; /* Half-transparent */
    font-size: 0.8rem;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    pointer-events: none;
    white-space: nowrap;
}

.mobile-header {
    display: none !important;
}

/* Mobile specific Sequential Footer Element */
.mobile-footer {
    display: none;
}

/* Responsive styling to ensure buttons don't block canvas on mobile */
@media (max-width: 768px) {
    body, html {
        overflow-y: auto !important;
        height: auto !important;
        min-height: 100vh !important;
        -webkit-overflow-scrolling: touch;
    }
    .canvas-container {
        height: 100vh !important; /* Adjust dynamically to the device's vertical screen size */
        touch-action: auto !important;
    }
    .ui-container {
        top: 175px !important; /* Move header text directly underneath the smaller logo */
        transform: translateX(-50%) !important;
        position: absolute !important;
    }
    .desktop-header {
        display: none !important;
    }
    .mobile-header {
        display: block !important;
    }
    h1 {
        font-size: 1.4rem !important;
    }
    .subtext-main {
        font-size: 0.95rem !important;
    }
    .subtext-mobile {
        display: block !important;
        font-size: 0.75rem !important;
    }
    .right-controls {
        position: fixed !important; /* Locked to the viewport bottom */
        top: auto !important;
        bottom: 20px !important; 
        right: 20px !important;
        transform: none !important;
        flex-direction: row !important; /* Horizontal layout parallel to tilt keys */
        gap: 10px !important;
        align-items: center !important;
        z-index: 100 !important; /* Forces overlays on top of the Canvas & Glass outlines */
    }
    .mobile-controls {
        position: fixed !important; /* Locked to the viewport bottom */
        bottom: 20px !important; 
        left: 50% !important;
        transform: translateX(-50%) !important;
        display: flex !important;
        gap: 15px !important;
        z-index: 100 !important;
    }
    .tilt-btn {
        width: 50px !important; 
        height: 50px !important;
        font-size: 1.1rem !important;
    }
    /* Damped hover on mobile since hover is triggered by tap */
    .right-controls button:hover {
        max-width: 45px; /* Retains circular profile on mobile */
        padding: 10px;
        transform: scale(1.1);
    }
    .right-controls button:hover .btn-text {
        opacity: 0;
        max-width: 0;
        margin-left: 0;
    }
    .mobile-controls {
        display: flex;
    }
    #spawnShotBtn {
        display: none !important;
    }
    /* Hide desktop absolute overlays */
    .github-link, .gemini-credit {
        display: none !important;
    }
    /* Sequential layout footer aligned to the left on mobile to prevent overlapping with floating buttons */
    .mobile-footer {
        display: flex;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center !important;
        gap: 8px !important; /* Clean vertical line-break gap */
        padding-left: 20px !important;
        background: #121212; /* Seamless integration with bottom gradient vignette */
        border-top: 1px solid rgba(212, 120, 10, 0.15); /* Ambient copper/amber divider line */
        color: #bfa38a;
        font-family: 'Arbutus Slab', serif;
        font-size: 0.85rem;
        font-weight: 500;
        width: 100%;
        height: 85px;
        position: relative;
        z-index: 10;
    }
    .mobile-footer a {
        color: #ff9f3b !important; /* Standout copper/amber color to show it is a link */
        text-decoration: underline !important;
        font-weight: bold;
        transition: color 0.15s ease;
    }
    .mobile-footer a:hover {
        color: #ffe0a3 !important;
    }
    .performance-btn {
        position: fixed !important;
        bottom: 110px !important; /* Floats above the mobile footer and controls */
        right: 20px !important;
        z-index: 101 !important;
        background: rgba(12, 12, 12, 0.45) !important;
        border-color: rgba(212, 120, 10, 0.2) !important;
        color: rgba(191, 163, 138, 0.75) !important;
        width: 36px !important;
        padding: 0 !important;
    }
    .performance-btn:hover {
        width: 36px !important;
        padding: 0 !important;
    }
    .performance-btn:hover .btn-text {
        opacity: 0 !important;
        max-width: 0 !important;
        margin-left: 0 !important;
    }
    .desktop-only {
        display: none !important;
    }
    .mobile-only {
        display: inline !important;
    }
    .ui-card {
        padding: 12px 25px 12px 25px !important;
    }
    .dropdown-toggle {
        position: static !important;
        align-self: flex-end !important;
        margin-top: 10px !important;
    }
}
@media (min-width: 768px) {
    .mobile-controls {
        display: none;
    }
}
