:root {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --primary-color: #0f3460;
    --accent-color: #e94560;
    --text-color: #ffffff;
}

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

/* Controls */
.controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 15px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    color: var(--text-color);
    z-index: 100;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: #4CAF50; /* Green when turned on */
}
input:checked + .slider:before {
    transform: translateX(26px);
}

/* Bobblehead Layout */
.bobblehead-container {
    position: relative;
    width: 320px;
    height: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

/* Caricature Body */
.body-caricature {
    position: absolute;
    bottom: 0;
    width: 140px;
    height: 180px;
    background: #2a2a2a; /* simple dark suit */
    border-radius: 70px 70px 20px 20px;
    box-shadow: inset -10px -10px 20px rgba(0,0,0,0.5), 0 10px 25px rgba(0,0,0,0.5);
    z-index: 1;
}

.collar {
    position: absolute;
    top: -5px;
    left: 40px;
    width: 60px;
    height: 40px;
    background: #ffffff;
    border-radius: 10px;
    z-index: 2;
}

.tie {
    position: absolute;
    top: 25px;
    left: 60px;
    width: 20px;
    height: 100px;
    background: var(--accent-color);
    clip-path: polygon(50% 100%, 100% 20%, 80% 0, 20% 0, 0 20%);
    z-index: 3;
}

.suit-lapels {
    position: absolute;
    top: 0;
    left: 35px;
    width: 70px;
    height: 140px;
    border-left: 2px solid #1a1a1a;
    border-right: 2px solid #1a1a1a;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    z-index: 4;
    background: rgba(0,0,0,0.2);
}

/* Head image */
.head {
    position: absolute;
    top: 20px;
    width: 240px;
    height: auto;
    border-radius: 30px; /* Slight rounding for standard images */
    object-fit: cover;
    transform-origin: bottom center;
    z-index: 10;
    cursor: pointer;
    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
    transition: transform 0.1s;
}

/* Bobble Animation Keyframes */
.bobble-anim {
    animation: bobbleEffect 1.8s ease-in-out forwards;
}

@keyframes bobbleEffect {
    0% { transform: rotate(0deg) translate(0, 0); }
    15% { transform: rotate(-25deg) translate(-20px, 10px); }
    30% { transform: rotate(18deg) translate(15px, -5px); }
    45% { transform: rotate(-10deg) translate(-10px, 5px); }
    60% { transform: rotate(7deg) translate(5px, -2px); }
    75% { transform: rotate(-3deg) translate(-2px, 1px); }
    90% { transform: rotate(1deg) translate(1px, 0); }
    100% { transform: rotate(0deg) translate(0, 0); }
}

/* Dialog Bubble */
.dialog-bubble {
    position: absolute;
    top: -20px;
    right: -140px;
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a2e;
    padding: 15px 20px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1.1em;
    width: 200px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    z-index: 20;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: scale(1);
    opacity: 1;
}

.dialog-bubble::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 20px;
    border-width: 15px 15px 0 0;
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.95) transparent transparent transparent;
    display: block;
    width: 0;
}

.dialog-bubble.hidden {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    pointer-events: none;
}

/* Flick Hand */
.flick-hand {
    position: absolute;
    font-size: 5rem;
    bottom: 30%;
    left: 20%;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 50;
    text-shadow: 2px 2px 10px rgba(0,0,0,0.5);
    transform: rotate(45deg); /* Pointing towards the head slightly */
}

.flick-hand:hover {
    transform: scale(1.1) rotate(40deg);
}

.flick-anim {
    animation: handFlick 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes handFlick {
    0% { transform: translateX(0) translateY(0) rotate(45deg); }
    40% { transform: translateX(80px) translateY(-50px) rotate(20deg) scale(0.9); }
    100% { transform: translateX(0) translateY(0) rotate(45deg); }
}

/* Responsive constraints */
@media (max-width: 600px) {
    .dialog-bubble {
        right: -50px;
        top: -60px;
        width: 150px;
        font-size: 0.9em;
    }
    
    .flick-hand {
        left: 10%;
        font-size: 4rem;
    }
}
