/* Global Styles - Beer Clicker
   Shared styles across all universes */

:root {
    --beer-gold: #fbbf24;
    --beer-dark: #d97706;
    --foam: #ffffff;
    --glass: rgba(255, 255, 255, 0.1);
    --poison-green: #4ade80;
    --poison-dark: #14532d;
    --alert-red: #ef4444;
    --happy-purple: #a855f7;
}

body {
    font-family: 'Inter', sans-serif;
    background: #0f172a;
    color: white;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: manipulation;
    min-height: 100vh;
}

/* Pressed/active state for the beer glass to give tactile feedback on mobile */
.beer-glass-container {
    transition: transform 90ms ease, box-shadow 90ms ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.beer-glass-container.active {
    transform: translateY(4px) scale(0.985);
    box-shadow: 0 6px 18px rgba(0,0,0,0.35) inset;
}

/* Ensure the beer glass stays on top of adjacent panels so it's fully tappable */
.beer-glass-container {
    position: relative;
    z-index: 30;
    pointer-events: auto;
}

/* During normal play keep the beer above most UI layers so it's always tappable.
   When `sick-mode` is active we lower it so the overlay can block interactions as intended. */
body:not(.sick-mode) .beer-glass-container {
    z-index: 11000;
}
body.sick-mode .beer-glass-container {
    z-index: 30;
}

/* Ensure the entire left panel has higher stacking than the right column so child
   elements (like the beer) cannot be occluded by the right-side content. */
.left-panel {
    position: relative;
    z-index: 40; /* higher than right column's z-20 */
    pointer-events: auto;
}

/* Full-size invisible hit area overlay for .glass-btn cards */
.glass-btn {
    position: relative;
}
.glass-btn > .full-hit-area {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    display: block;
    touch-action: manipulation;
}
/* Ensure native inner buttons stay above the overlay */
.glass-btn button {
    position: relative;
    z-index: 2;
}

/* Ensure auto-toggle buttons sit above purchase buttons to avoid overlap on small screens */
.glass-btn .auto-btn {
    position: relative;
    z-index: 3;
}
.glass-btn .purchase-btn {
    position: relative;
    z-index: 2;
}

/* Auto-row sits below the main card and should be clearly separated and above overlays */
.autobuyer-item {
    position: relative;
    z-index: 12000; /* above overlays */
    width: 100%;
    box-shadow: none;
}
.autobuyer-item .auto-btn {
    pointer-events: auto;
}

/* Ensure research category tabs remain tappable on small screens even when overlays (sickness) are shown */
@media (max-width: 768px) {
    .research-tabs {
        position: relative;
        z-index: 10001; /* above .click-disabled-overlay (9999) */
        pointer-events: auto;
    }
}

/* Make all glass buttons fully clickable (not just the emoji/text) */
.glass-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    cursor: pointer;
}

/* Let the button capture clicks instead of inner spans/icons */
.glass-btn > * {
    pointer-events: none;
}

/* Allow nested buttons to be clickable */
.glass-btn button {
    pointer-events: auto;
}

/* --- 8-BIT MODE STYLES --- */
body.mode-8bit {
    font-family: 'Press Start 2P', cursive;
    image-rendering: pixelated;
    background: #000;
}

body.mode-8bit * {
    border-radius: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    transition: none !important;
    text-shadow: 2px 2px 0px #000 !important;
}

body.mode-8bit .glass-panel,
body.mode-8bit .glass-btn,
body.mode-8bit .beer-glass-container {
    border: 4px solid white !important;
    background: #222 !important;
}

body.mode-8bit .glass-btn:hover {
    background: #444 !important;
}

body.mode-8bit .liquid {
    background: var(--beer-gold) !important;
    border-top: 4px solid white;
}

body.mode-8bit .beer-bubble {
    background: white !important;
    width: 4px !important;
    height: 4px !important;
}

/* --- ACCESSIBILITY MODE --- */
body.mode-accessibility {
    background: #0a0a0a;
    font-size: 16px !important;
}

body.mode-accessibility * {
    transition: none !important;
    animation: none !important;
    text-shadow: none !important;
    letter-spacing: 0.02em !important;
    line-height: 1.6 !important;
}

/* Increase font sizes for better readability */
body.mode-accessibility h1, body.mode-accessibility h2, body.mode-accessibility h3 {
    font-size: 1.4em !important;
}

body.mode-accessibility button {
    font-size: 14px !important;
    padding: 12px !important;
    pointer-events: auto !important;
    cursor: pointer !important;
}

body.mode-accessibility .text-xs {
    font-size: 13px !important;
}

body.mode-accessibility .text-sm {
    font-size: 15px !important;
}

body.mode-accessibility .text-lg {
    font-size: 18px !important;
}

body.mode-accessibility .text-xl {
    font-size: 20px !important;
}

body.mode-accessibility .counter-text {
    font-size: 2rem !important;
    text-shadow: none !important;
}

/* Improve text contrast */
body.mode-accessibility {
    color: #ffffff !important;
}

body.mode-accessibility .text-gray-400,
body.mode-accessibility .text-gray-500,
body.mode-accessibility .text-gray-600 {
    color: #bbbbbb !important;
    opacity: 1 !important;
}

body.mode-accessibility .text-red-300,
body.mode-accessibility .text-red-400,
body.mode-accessibility .text-red-500 {
    color: #ff6b6b !important;
}

body.mode-accessibility .text-green-400 {
    color: #51cf66 !important;
}

body.mode-accessibility .text-blue-200,
body.mode-accessibility .text-blue-300,
body.mode-accessibility .text-blue-400 {
    color: #74c0fc !important;
}

body.mode-accessibility .text-yellow-200,
body.mode-accessibility .text-yellow-400 {
    color: #ffd43b !important;
}

body.mode-accessibility .text-pink-400 {
    color: #ff8cd6 !important;
}

body.mode-accessibility .text-purple-300 {
    color: #d8adff !important;
}

body.mode-accessibility .bg-gradient-animate {
    display: none !important;
}

body.mode-accessibility .glass-panel,
body.mode-accessibility .glass-btn {
    background: #1a1a1a !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: 1px solid #333 !important;
    box-shadow: none !important;
}

body.mode-accessibility .glass-btn:hover:not(:disabled) {
    background: #2a2a2a !important;
    transform: none !important;
}

body.mode-accessibility .glass-btn:active:not(:disabled) {
    transform: none !important;
}

body.mode-accessibility #btn-accessibility,
body.mode-accessibility #btn-8bit,
body.mode-accessibility #btn-smart-mode {
    pointer-events: auto !important;
    cursor: pointer !important;
    background: #2a2a2a !important;
    border: 1px solid #444 !important;
}

body.mode-accessibility .beer-glass-container {
    box-shadow: none !important;
}

body.mode-accessibility .beer-glass-container:active {
    transform: none !important;
}

body.mode-accessibility .liquid {
    background: #d97706 !important;
    box-shadow: none !important;
}

body.mode-accessibility .foam-head {
    box-shadow: none !important;
    filter: none !important;
}

body.mode-accessibility .beer-bubble {
    display: none !important;
}

body.mode-accessibility .click-particle {
    animation: none !important;
    display: none !important;
}

body.mode-accessibility .toast-msg {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
}

body.mode-accessibility #toast-container {
    top: auto;
    bottom: 20px;
}

body.mode-accessibility .buff-active {
    animation: none !important;
    border-color: #fbbf24 !important;
}

body.mode-accessibility.happy-hour-mode #game-content {
    box-shadow: none !important;
    animation: none !important;
}

body.mode-accessibility.happy-hour-mode #game-content * {
    animation: none !important;
}

body.mode-accessibility.sick-mode #game-content {
    filter: none !important;
    transform: none !important;
}

body.mode-accessibility.sick-mode.alcohol-mode #game-content {
    filter: none !important;
    transform: none !important;
}

body.mode-accessibility .click-disabled-overlay {
    animation: none !important;
}

body.mode-accessibility .modal-overlay {
    backdrop-filter: none !important;
}

/* --- STANDARD STYLES --- */

#game-content {
    transition: filter 0.5s ease, transform 0.5s ease;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

@media (min-width: 768px) {
    #game-content { flex-direction: row; }
}

/* Happy Hour Effect */
body.happy-hour-mode #game-content {
    box-shadow: inset 0 0 50px var(--happy-purple);
    animation: pulse-happy 2s infinite;
}

body.mode-8bit.happy-hour-mode #game-content {
    box-shadow: inset 0 0 0 10px var(--happy-purple) !important;
    animation: blink-happy 0.5s infinite steps(2) !important;
}

@keyframes pulse-happy {
    0% { box-shadow: inset 0 0 20px var(--happy-purple); }
    50% { box-shadow: inset 0 0 60px #d946ef; }
    100% { box-shadow: inset 0 0 20px var(--happy-purple); }
}

@keyframes blink-happy {
    0% { background-color: #0f172a; }
    50% { background-color: #2e1065; }
}

/* Sickness Effect */
body.sick-mode #game-content {
    filter: grayscale(0.5) sepia(0.8) hue-rotate(50deg);
    transform: scale(0.98);
}

body.sick-mode .liquid {
    background: linear-gradient(to top, #064e3b, #22c55e) !important;
    box-shadow: 0 0 30px #22c55e !important;
}

body.sick-mode.alcohol-mode #game-content {
    filter: grayscale(0.8) contrast(1.2) hue-rotate(-50deg) blur(6px);
    transform: scale(0.95);
}

body.sick-mode.alcohol-mode .liquid {
    background: linear-gradient(to top, #7f1d1d, #ef4444) !important;
    box-shadow: 0 0 30px #ef4444 !important;
}

/* OVERLAY */
.click-disabled-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(0px);
}

body.sick-mode .click-disabled-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* Heal box styling */
#heal-box {
    min-width: 220px;
    min-height: 72px;
    border-radius: 14px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

#heal-countdown {
    display: inline-block;
    min-width: 36px;
    text-align: center;
}

#sickness-bar { display: none; }
#sickness-bar.hidden { display: none !important; }
#sickness-bar:not(.hidden) { display: block; }
#sickness-bar-inner { width: 100%; }

/* Toast Container */
#toast-container {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.toast-msg {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideDownFade 4s forwards;
    backdrop-filter: blur(4px);
}

.achievement-toast {
    border-color: #fbbf24;
    background: rgba(40, 30, 10, 0.95);
}

@keyframes slideDownFade {
    0% { opacity: 0; transform: translateY(-20px); }
    10% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
}

/* Background Gradient */
.bg-gradient-animate {
    background: linear-gradient(-45deg, #0f172a, #1e1b4b, #31081f, #0f172a);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: -2;
    pointer-events: none;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Glassmorphism */
.glass-panel {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.glass-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}
.glass-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.02);
}
.glass-btn:active:not(:disabled) {
    transform: scale(0.98);
}
.glass-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

button {
    pointer-events: auto !important;
    cursor: pointer !important;
    touch-action: manipulation;
}

button:disabled {
    cursor: not-allowed !important;
}

/* Prevent periodic animations (pulse/border/etc.) from running while hovering
   to avoid perceived flashing when the cursor is over buttons or the click area. */
.glass-btn:hover,
#click-btn:hover,
.glass-btn:hover *,
#click-btn:hover * {
    animation: none !important;
}

.counter-text {
    font-family: 'Space Mono', monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.05em;
    text-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

/* BEER ICON */
.beer-glass-container {
    position: relative;
    margin: 0 auto;
    transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
    z-index: 10;
}

.beer-glass-container:active {
    transform: scale(0.92) rotate(-2deg);
}

.beer-glass-container:active .foam-head {
    opacity: 0 !important;
}

/* Transparent full-size hit area inside the beer container */
.beer-hit-area {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    appearance: none;
}

/* Make sure decorative elements don't steal pointer events */
.beer-glass-container * { pointer-events: auto; }

.glass-body {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 85%;
    background: rgba(255,255,255,0.08);
    border: 3px solid rgba(255,255,255,0.35);
    border-top: none;
    border-radius: 0 0 15px 15px;
    overflow: hidden;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3), inset -2px 0 6px rgba(255,255,255,0.05);
}

.liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(to top, var(--beer-dark), var(--beer-gold));
    transition: height 0.3s ease-out, background 0.5s;
    box-shadow: 0 0 30px var(--beer-gold);
}

.foam-head {
    position: absolute;
    top: -20px;
    left: -5%;
    width: 110%;
    height: 40px;
    background: white;
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.5s;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
    bottom: 50%;
    display: none;
}

/* Progressive 3D Effects for Beer Glass (HD Levels) */
html[data-hd-level="1"] .beer-glass-container {
    transform-style: preserve-3d;
    perspective: 1000px;
}

html[data-hd-level="1"] .glass-body {
    box-shadow: 
        inset 0 2px 12px rgba(0,0,0,0.4),
        inset -3px 0 8px rgba(255,255,255,0.1),
        inset 3px 0 8px rgba(0,0,0,0.2),
        0 10px 30px rgba(0,0,0,0.3);
    border-width: 4px;
}

html[data-hd-level="1"] .liquid {
    box-shadow: 
        0 0 40px var(--beer-gold),
        inset 0 -10px 20px rgba(0,0,0,0.2);
}

html[data-hd-level="2"] .beer-glass-container {
    transform-style: preserve-3d;
    perspective: 800px;
    filter: drop-shadow(0 15px 40px rgba(0,0,0,0.5));
}

html[data-hd-level="2"] .glass-body {
    box-shadow: 
        inset 0 2px 15px rgba(0,0,0,0.5),
        inset -4px 0 12px rgba(255,255,255,0.15),
        inset 4px 0 12px rgba(0,0,0,0.25),
        inset 0 0 30px rgba(255,255,255,0.05),
        0 15px 50px rgba(0,0,0,0.4),
        0 5px 15px rgba(0,0,0,0.3);
    border-width: 5px;
    border-color: rgba(255,255,255,0.45);
}

html[data-hd-level="2"] .liquid {
    box-shadow: 
        0 0 50px var(--beer-gold),
        0 -5px 30px rgba(251, 191, 36, 0.5),
        inset 0 -15px 25px rgba(0,0,0,0.3),
        inset 2px 0 10px rgba(255,255,255,0.1);
}

html[data-hd-level="2"] .glass-body::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 8%;
    width: 25%;
    height: 40%;
    background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, transparent 50%);
    border-radius: 50% 20% 50% 20%;
    pointer-events: none;
}

html[data-hd-level="3"] .beer-glass-container {
    transform-style: preserve-3d;
    perspective: 600px;
    filter: 
        drop-shadow(0 20px 60px rgba(0,0,0,0.6))
        drop-shadow(0 10px 30px rgba(251, 191, 36, 0.3));
}

html[data-hd-level="3"] .glass-body {
    box-shadow: 
        inset 0 2px 20px rgba(0,0,0,0.6),
        inset -5px 0 15px rgba(255,255,255,0.2),
        inset 5px 0 15px rgba(0,0,0,0.3),
        inset 0 0 40px rgba(255,255,255,0.08),
        inset 0 -5px 20px rgba(0,0,0,0.4),
        0 20px 70px rgba(0,0,0,0.5),
        0 10px 30px rgba(0,0,0,0.4),
        0 5px 15px rgba(251, 191, 36, 0.2);
    border-width: 6px;
    border-color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.12);
}

html[data-hd-level="3"] .liquid {
    box-shadow: 
        0 0 60px var(--beer-gold),
        0 -10px 40px rgba(251, 191, 36, 0.6),
        0 0 80px rgba(217, 119, 6, 0.4),
        inset 0 -20px 30px rgba(0,0,0,0.4),
        inset 3px 0 15px rgba(255,255,255,0.15),
        inset -3px 0 10px rgba(0,0,0,0.2);
    background: linear-gradient(to top, 
        #d97706 0%, 
        #f59e0b 30%, 
        #fbbf24 70%, 
        #fcd34d 100%);
}

html[data-hd-level="3"] .glass-body::before {
    content: '';
    position: absolute;
    top: 8%;
    left: 6%;
    width: 30%;
    height: 50%;
    background: linear-gradient(135deg, 
        rgba(255,255,255,0.6) 0%, 
        rgba(255,255,255,0.3) 30%,
        transparent 60%);
    border-radius: 50% 30% 50% 30%;
    pointer-events: none;
    filter: blur(1px);
}

html[data-hd-level="3"] .glass-body::after {
    content: '';
    position: absolute;
    top: 60%;
    right: 8%;
    width: 20%;
    height: 30%;
    background: linear-gradient(225deg, 
        rgba(255,255,255,0.2) 0%, 
        transparent 50%);
    border-radius: 30% 50%;
    pointer-events: none;
}


/* Bubbles */
.beer-bubble {
    position: absolute;
    background: rgba(255,255,255,0.4);
    border-radius: 50%;
    animation: rise linear infinite;
}
@keyframes rise { from { bottom: -10px; transform: translateX(0); } to { bottom: 100%; transform: translateX(20px); } }

/* Particles */
.click-particle {
    position: absolute;
    pointer-events: none;
    color: var(--beer-gold);
    font-weight: bold;
    font-size: 1.5rem;
    animation: floatUpFade 0.8s ease-out forwards;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
    z-index: 50;
}

@keyframes floatUpFade {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-80px) scale(1.5); opacity: 0; }
}

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

.danger-meter {
    height: 4px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
    width: 100%;
    margin-top: 2px;
}
.danger-fill {
    height: 100%;
    background: linear-gradient(to right, #22c55e, #ef4444);
}

.buff-active {
    animation: pulse-border 1s infinite;
    border-color: #fbbf24;
}
@keyframes pulse-border {
    0% { border-color: rgba(251, 191, 36, 0.3); }
    50% { border-color: rgba(251, 191, 36, 1); }
    100% { border-color: rgba(251, 191, 36, 0.3); }
}

@keyframes firework {
    0% { 
        transform: translateY(0) scale(0.5); 
        opacity: 1; 
    }
    50% { 
        transform: translateY(-100px) scale(1.5); 
        opacity: 0.8; 
    }
    100% { 
        transform: translateY(-200px) scale(0.3); 
        opacity: 0; 
    }
}

.modal-overlay {
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
}

.save-textarea {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #4ade80;
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    resize: none;
    width: 100%;
    height: 150px;
    padding: 10px;
    border-radius: 8px;
    outline: none;
}
.save-textarea:focus {
    border-color: rgba(74, 222, 128, 0.5);
}

@media (max-width: 768px) {
    body {
        padding-bottom: 60px;
    }
    #game-content {
        height: auto;
        min-height: 100vh;
    }
    #toast-container {
        top: 16px;
        width: calc(100% - 24px);
        padding: 0 12px;
    }
    .glass-btn {
        min-height: 48px;
    }
}
