* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --barn-dark: #2C1810;
    --barn-mid: #5C3A21;
    --barn-light: #8B5E3C;
    --barn-cream: #F5E6D0;
    --gold: #D4A847;
    --gold-bright: #FFD700;
    --red-deep: #8B1A1A;
    --red-bright: #CC3333;
    --green-felt: #2D5A27;
    --cream-white: #FFF8F0;
}

body {
    background: var(--barn-dark);
    color: var(--barn-cream);
    font-family: 'Caveat', cursive;
    overflow-x: hidden;
    min-height: 100vh;
}

#game-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
}

#header {
    text-align: center;
    padding: 12px 16px 8px;
    background: linear-gradient(180deg, #1a0e08 0%, var(--barn-dark) 100%);
    border-bottom: 3px solid var(--gold);
    position: relative;
}

#header::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gold-bright);
    opacity: 0.4;
}

#title {
    font-family: 'Rye', serif;
    font-size: clamp(1.8rem, 5vw, 3rem);
    color: var(--gold-bright);
    text-shadow: 2px 2px 0 var(--barn-dark), 4px 4px 8px rgba(0,0,0,0.5);
    letter-spacing: 2px;
}

#subtitle {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.9rem, 2.5vw, 1.3rem);
    color: var(--barn-cream);
    opacity: 0.8;
    margin-top: 2px;
    font-style: italic;
}

#controls-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 8px;
}

#drop-btn {
    font-family: 'Dela Gothic One', sans-serif;
    font-size: clamp(0.85rem, 2vw, 1.1rem);
    padding: 8px 28px;
    background: linear-gradient(180deg, #ee4444 0%, #aa2222 50%, #881111 100%);
    color: white;
    border: 3px solid #ff6666;
    border-bottom-color: #661111;
    border-right-color: #661111;
    border-radius: 50px;
    cursor: pointer;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
    transition: all 0.1s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#drop-btn:hover {
    background: linear-gradient(180deg, #ff5555 0%, #cc3333 50%, #992222 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.3);
}

#drop-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4), inset 0 2px 4px rgba(0,0,0,0.3);
    border-top-color: #661111;
    border-left-color: #661111;
    border-bottom-color: #ff6666;
    border-right-color: #ff6666;
}

#chaos-btn {
    font-family: 'Dela Gothic One', sans-serif;
    font-size: clamp(0.75rem, 1.8vw, 0.95rem);
    padding: 8px 18px;
    background: linear-gradient(180deg, #dd8800 0%, #aa5500 50%, #883300 100%);
    color: white;
    border: 3px solid #ffaa33;
    border-bottom-color: #663300;
    border-right-color: #663300;
    border-radius: 50px;
    cursor: pointer;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
    transition: all 0.1s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#chaos-btn:hover {
    transform: translateY(-1px);
}

#chaos-btn:active {
    transform: translateY(2px);
}

#chaos-btn.active {
    background: linear-gradient(180deg, #ff4400 0%, #cc2200 50%, #991100 100%);
    border-color: #ff6633;
    animation: chaosGlow 0.5s ease-in-out infinite alternate;
}

@keyframes chaosGlow {
    from { box-shadow: 0 0 8px rgba(255,68,0,0.5); }
    to { box-shadow: 0 0 20px rgba(255,68,0,0.8); }
}

#main-area {
    display: flex;
    flex: 1;
    gap: 0;
    padding: 8px;
    min-height: 0;
}

#canvas-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#canvas {
    border: 3px solid var(--gold);
    border-radius: 8px;
    cursor: crosshair;
    max-width: 100%;
    touch-action: none;
}

#click-hint {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Caveat', cursive;
    font-size: 1rem;
    color: var(--gold-bright);
    opacity: 0.7;
    pointer-events: none;
    animation: hintPulse 2s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.9; }
}

#sidebar {
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 8px;
    flex-shrink: 0;
}

#grandma-panel {
    background: linear-gradient(135deg, #3a2215 0%, #2a1810 100%);
    border: 2px solid var(--gold);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
}

#grandma-face {
    font-size: 3.5rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    animation: grandmaBob 3s ease-in-out infinite;
}

@keyframes grandmaBob {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-2px) rotate(-2deg); }
    75% { transform: translateY(-2px) rotate(2deg); }
}

#grandma-name {
    font-family: 'Rye', serif;
    font-size: 0.9rem;
    color: var(--gold);
    margin: 4px 0;
}

#speech-bubble {
    background: var(--cream-white);
    color: var(--barn-dark);
    border-radius: 16px;
    padding: 10px 14px;
    margin-top: 8px;
    position: relative;
    min-height: 60px;
    font-size: 1.05rem;
    line-height: 1.3;
    text-align: left;
}

#speech-bubble::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid var(--cream-white);
}

#speech-text {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    display: block;
}

#scoreboard {
    background: linear-gradient(135deg, #3a2215 0%, #2a1810 100%);
    border: 2px solid var(--gold);
    border-radius: 12px;
    padding: 12px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(212,168,71,0.2);
}

.score-item:last-of-type {
    border-bottom: none;
}

.score-label {
    font-family: 'Rye', serif;
    font-size: 0.65rem;
    color: var(--gold);
    letter-spacing: 1px;
}

.score-value {
    font-family: 'Dela Gothic One', sans-serif;
    font-size: 1.2rem;
    color: var(--cream-white);
}

#approval-container {
    padding: 8px 0 2px;
}

#approval-container .score-label {
    display: block;
    margin-bottom: 6px;
}

#approval-bar-bg {
    width: 100%;
    height: 14px;
    background: #1a0e08;
    border-radius: 7px;
    border: 1px solid var(--gold);
    overflow: hidden;
}

#approval-bar {
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, var(--red-bright), var(--gold-bright), #44cc44);
    border-radius: 7px;
    transition: width 0.5s ease;
}

#approval-text {
    font-family: 'Caveat', cursive;
    font-size: 0.95rem;
    color: var(--barn-cream);
    display: block;
    text-align: center;
    margin-top: 4px;
}

#footer {
    text-align: center;
    padding: 12px;
    border-top: 2px solid rgba(212,168,71,0.3);
    font-size: 0.85rem;
    opacity: 0.7;
}

#footer a {
    color: var(--gold-bright);
    text-decoration: none;
    margin-left: 12px;
}

#footer a:hover {
    text-decoration: underline;
}

/* Confetti container */
.confetti-piece {
    position: fixed;
    width: 10px;
    height: 10px;
    pointer-events: none;
    z-index: 1000;
    animation: confettiFall 2s ease-in forwards;
}

@keyframes confettiFall {
    0% { opacity: 1; transform: translateY(0) rotate(0deg); }
    100% { opacity: 0; transform: translateY(100vh) rotate(720deg); }
}

.screen-shake {
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px) translateY(2px); }
    40% { transform: translateX(6px) translateY(-2px); }
    60% { transform: translateX(-4px) translateY(1px); }
    80% { transform: translateX(4px) translateY(-1px); }
}

/* Mobile layout */
@media (max-width: 768px) {
    #main-area {
        flex-direction: column;
        padding: 4px;
    }
    
    #sidebar {
        width: 100%;
        flex-direction: row;
        padding-left: 0;
        padding-top: 8px;
        gap: 8px;
    }
    
    #grandma-panel {
        flex: 1;
    }
    
    #scoreboard {
        flex: 1;
    }

    #grandma-face {
        font-size: 2.5rem;
    }

    #speech-bubble {
        min-height: 40px;
        font-size: 0.9rem;
        padding: 8px 10px;
    }
    
    .score-value {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    #sidebar {
        flex-direction: column;
    }
    
    #header {
        padding: 8px 12px 6px;
    }
}