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

:root {
    --barn-red: #7B2D26;
    --barn-dark: #4A1A15;
    --wood-brown: #8B5E3C;
    --wood-light: #C49A6C;
    --hay-gold: #DAA520;
    --hay-light: #F5DEB3;
    --cream: #FFF8E7;
    --parchment: #F5E6C8;
    --forest-green: #2D5016;
}

body {
    background: 
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 40px,
            rgba(139,94,60,0.03) 40px,
            rgba(139,94,60,0.03) 41px
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 40px,
            rgba(139,94,60,0.03) 40px,
            rgba(139,94,60,0.03) 41px
        ),
        linear-gradient(135deg, #F5E6C8 0%, #E8D5A8 30%, #F0DFC0 60%, #E5CFA0 100%);
    font-family: 'Patrick Hand', cursive;
    min-height: 100vh;
    overflow-x: hidden;
}

#game-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
}

#top-bar {
    background: linear-gradient(180deg, var(--barn-red) 0%, var(--barn-dark) 100%);
    border-radius: 12px;
    padding: 12px 20px;
    margin-bottom: 10px;
    border: 4px solid var(--wood-brown);
    box-shadow: 
        inset 0 2px 0 rgba(255,255,255,0.15),
        0 4px 12px rgba(0,0,0,0.3);
}

#title {
    font-family: 'Lilita One', cursive;
    color: var(--hay-gold);
    font-size: 2.2em;
    text-align: center;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.5), 0 0 20px rgba(218,165,32,0.3);
    letter-spacing: 3px;
}

#stats-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 8px 0;
    flex-wrap: wrap;
}

.stat-box {
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 4px 16px;
    text-align: center;
    border: 2px solid var(--wood-brown);
}

.stat-label {
    display: block;
    color: var(--hay-light);
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-box span:last-child, #score-display, #horses-display, #highscore-display {
    color: var(--hay-gold);
    font-family: 'Lilita One', cursive;
    font-size: 1.4em;
}

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

#drop-btn {
    background: linear-gradient(180deg, #4CAF50 0%, #2E7D32 100%);
    color: white;
    border: 3px solid #1B5E20;
    border-radius: 10px;
    padding: 8px 28px;
    font-family: 'Lilita One', cursive;
    font-size: 1.3em;
    cursor: pointer;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
    box-shadow: 0 4px 0 #1B5E20, 0 6px 12px rgba(0,0,0,0.3);
    transition: all 0.1s;
    letter-spacing: 1px;
}

#drop-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #1B5E20, 0 8px 16px rgba(0,0,0,0.3);
}

#drop-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #1B5E20, 0 3px 8px rgba(0,0,0,0.3);
}

#drop-btn:disabled {
    background: linear-gradient(180deg, #888 0%, #666 100%);
    border-color: #444;
    box-shadow: 0 4px 0 #444;
    cursor: not-allowed;
    opacity: 0.7;
}

#reset-btn {
    background: linear-gradient(180deg, var(--wood-light) 0%, var(--wood-brown) 100%);
    color: var(--cream);
    border: 3px solid #5D3A1A;
    border-radius: 10px;
    padding: 8px 20px;
    font-family: 'Lilita One', cursive;
    font-size: 1.1em;
    cursor: pointer;
    box-shadow: 0 4px 0 #5D3A1A;
    transition: all 0.1s;
}

#reset-btn:hover {
    transform: translateY(-2px);
}

#reset-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #5D3A1A;
}

#main-area {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

#canvas-container {
    flex: 1;
    min-width: 0;
}

#canvas {
    display: block;
    width: 100%;
    border-radius: 12px;
    border: 4px solid var(--wood-brown);
    box-shadow: 
        inset 0 0 40px rgba(0,0,0,0.2),
        0 4px 12px rgba(0,0,0,0.3);
}

#grandma-panel {
    width: 280px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--parchment) 0%, #E8D5A8 100%);
    border-radius: 12px;
    border: 4px solid var(--wood-brown);
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

#grandma-avatar {
    text-align: center;
    margin-bottom: 12px;
}

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

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

#grandma-name {
    font-family: 'Lilita One', cursive;
    color: var(--barn-red);
    font-size: 1.1em;
    margin-top: 4px;
}

#speech-bubble {
    background: white;
    border-radius: 16px;
    padding: 14px;
    position: relative;
    border: 3px solid var(--wood-brown);
    min-height: 80px;
    margin-bottom: 12px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

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

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

#speech-text {
    font-size: 1.05em;
    color: #333;
    line-height: 1.4;
}

#happiness-meter {
    text-align: center;
    padding: 8px;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    margin-bottom: 8px;
}

#happiness-meter .stat-label {
    color: var(--wood-brown);
    display: inline;
}

#mood-display {
    font-size: 1.8em;
    display: block;
    margin-top: 4px;
}

#last-result {
    text-align: center;
    font-family: 'Lilita One', cursive;
    color: var(--barn-red);
    font-size: 1em;
    min-height: 1.5em;
}

#footer {
    text-align: center;
    padding: 12px;
    margin-top: 10px;
    color: var(--wood-brown);
    font-size: 0.85em;
}

#footer a {
    color: var(--barn-red);
    text-decoration: none;
    font-weight: bold;
    margin-left: 12px;
}

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

#summary-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#summary-box {
    background: linear-gradient(180deg, var(--cream) 0%, var(--parchment) 100%);
    border: 6px solid var(--wood-brown);
    border-radius: 20px;
    padding: 30px 40px;
    text-align: center;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    animation: pop-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop-in {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

#summary-title {
    font-family: 'Lilita One', cursive;
    color: var(--barn-red);
    font-size: 2em;
    margin-bottom: 12px;
}

#summary-score {
    font-family: 'Lilita One', cursive;
    color: var(--hay-gold);
    font-size: 2.5em;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
    margin-bottom: 8px;
}

#summary-grandma {
    font-size: 1.2em;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.4;
}

#summary-box button {
    background: linear-gradient(180deg, #4CAF50 0%, #2E7D32 100%);
    color: white;
    border: 3px solid #1B5E20;
    border-radius: 10px;
    padding: 10px 30px;
    font-family: 'Lilita One', cursive;
    font-size: 1.3em;
    cursor: pointer;
    box-shadow: 0 4px 0 #1B5E20;
    transition: all 0.1s;
}

#summary-box button:hover {
    transform: translateY(-2px);
}

@keyframes screen-shake {
    0%, 100% { transform: translate(0,0); }
    10% { transform: translate(-4px, 2px); }
    20% { transform: translate(4px, -2px); }
    30% { transform: translate(-3px, -3px); }
    40% { transform: translate(3px, 3px); }
    50% { transform: translate(-2px, 1px); }
    60% { transform: translate(2px, -1px); }
    70% { transform: translate(-1px, 2px); }
    80% { transform: translate(1px, -1px); }
    90% { transform: translate(-1px, -1px); }
}

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

@media (max-width: 768px) {
    #main-area {
        flex-direction: column;
    }
    #grandma-panel {
        width: 100%;
    }
    #title {
        font-size: 1.6em;
    }
    #drop-btn {
        font-size: 1.1em;
        padding: 8px 20px;
    }
}