/* Scout's 3D Backyard - Styles */
:root {
    --scout-teal: #35A79E;
    --scout-light: #A7E8E2;
    --rusty-orange: #E8723D;
    --background-yellow: #FFF3B0;
    --grass-green: #7CB518;
    --sky-blue: #87CEEB;
    --white: #FFFFFF;
    --dark-text: #2D3436;
}

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

body {
    font-family: 'Segoe UI', 'Comic Sans MS', Arial, sans-serif;
    overflow: hidden;
    background: #000;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

canvas {
    display: block;
}

/* Screens */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--sky-blue) 0%, var(--scout-light) 50%, var(--grass-green) 100%);
    z-index: 100;
}

.screen-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 50px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
}

.screen h1 {
    font-size: 3.5rem;
    color: var(--scout-teal);
    text-shadow: 3px 3px 0 var(--rusty-orange);
    margin-bottom: 10px;
}

.screen h2 {
    font-size: 1.8rem;
    color: var(--rusty-orange);
    margin-bottom: 30px;
}

.instructions {
    margin-bottom: 30px;
}

.instructions > p {
    font-size: 1.2rem;
    color: var(--dark-text);
    margin-bottom: 20px;
}

.controls-info {
    background: var(--background-yellow);
    padding: 20px;
    border-radius: 15px;
    margin-top: 15px;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 10px 0;
    font-size: 1rem;
    color: var(--dark-text);
}

.key {
    background: var(--white);
    border: 2px solid var(--scout-teal);
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9rem;
    color: var(--scout-teal);
    box-shadow: 0 3px 0 var(--scout-teal);
}

.screen button {
    padding: 18px 60px;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--white);
    background: linear-gradient(135deg, var(--rusty-orange) 0%, #FF8C42 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 6px 20px rgba(232, 114, 61, 0.4);
}

.screen button:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(232, 114, 61, 0.5);
}

.screen button:active {
    transform: translateY(0);
}

/* HUD */
#hud {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 50;
    display: flex;
    gap: 20px;
}

.hud-item {
    background: rgba(255, 255, 255, 0.9);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--dark-text);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-icon {
    font-size: 1.4rem;
}

/* Instructions overlay */
#instructions-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 30px 50px;
    border-radius: 15px;
    font-size: 1.5rem;
    z-index: 60;
    text-align: center;
}

/* Loading screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--scout-teal) 0%, var(--scout-light) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    color: white;
    font-size: 1.5rem;
}

.loader {
    width: 80px;
    height: 80px;
    border: 8px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Utility */
.hidden {
    display: none !important;
}

/* ─── Character chips (start / win screens) ───────────────────────────────── */
.character-preview,
.char-chips-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.char-chip {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: bold;
    font-size: 0.82rem;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.scout-chip  { background: var(--scout-teal); }
.rusty-chip  { background: var(--rusty-orange); }
.barley-chip { background: #2C5F8A; }
.maple-chip  { background: #B06A3C; }

/* ─── Speech bubble ───────────────────────────────────────────────────────── */
#speech-bubble {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.97);
    border-radius: 22px;
    padding: 12px 22px;
    font-size: 1.05rem;
    font-weight: bold;
    color: var(--dark-text);
    max-width: 420px;
    width: 88%;
    text-align: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    border: 3px solid var(--scout-teal);
    z-index: 55;
    pointer-events: none;
    animation: speechPop 0.25s ease;
}

@keyframes speechPop {
    from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.95); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0)    scale(1); }
}

/* Character name in speech bubble */
#speech-bubble strong {
    color: var(--rusty-orange);
}

/* ─── Mute button in HUD ──────────────────────────────────────────────────── */
.mute-btn {
    cursor: pointer;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    font-size: 1.2rem;
    line-height: 1;
    transition: transform 0.15s;
}

.mute-btn:hover  { transform: scale(1.1); }
.mute-btn:active { transform: scale(0.95); }

/* ─── Link to the story game ─────────────────────────────────────────────── */
.other-game-link {
    display: inline-block;
    margin-top: 18px;
    padding: 15px 28px;
    font-size: 1.05rem;
    font-weight: bold;
    color: var(--white);
    text-decoration: none;
    background: linear-gradient(135deg, #B565D8 0%, #FF7BAC 100%);
    border-radius: 50px;
    box-shadow: 0 5px 16px rgba(181, 101, 216, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.other-game-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(181, 101, 216, 0.5);
}

/* ─── Win screen extras ───────────────────────────────────────────────────── */
.family-cheer {
    color: var(--rusty-orange);
    font-size: 1rem;
    margin-bottom: 12px;
}

.time-result {
    font-size: 1.15rem;
    color: var(--dark-text);
    margin-bottom: 22px;
}

/* ─── Mobile controls (D-pad + jump) ─────────────────────────────────────── */
#mobile-controls {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 18px;
    z-index: 65;
    pointer-events: none;
}

#dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    pointer-events: all;
}

.dpad-row {
    display: flex;
    align-items: center;
    gap: 3px;
}

.dpad-center {
    width: 46px;
    height: 46px;
}

.dpad-btn {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.85);
    border: 2px solid var(--scout-teal);
    border-radius: 12px;
    font-size: 1.15rem;
    color: var(--dark-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    pointer-events: all;
    transition: background 0.1s, transform 0.1s;
    font-family: inherit;
}

.dpad-btn:active {
    background: rgba(91, 164, 212, 0.55);
    transform: scale(0.9);
}

.jump-btn {
    width: 76px;
    height: 76px;
    background: linear-gradient(135deg, var(--rusty-orange), #d4622c);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 0.82rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 5px 0 rgba(0,0,0,0.25);
    pointer-events: all;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: transform 0.1s, box-shadow 0.1s;
    font-family: inherit;
    letter-spacing: 0.05em;
}

.jump-btn:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.25);
}

/* Mobile hint only shown on small screens */
.mobile-hint {
    display: none;
}

@media (max-width: 768px) {
    .mobile-hint { display: flex; }

    #speech-bubble {
        font-size: 0.9rem;
        bottom: 110px;
    }
}

/* Collected toy animation */
@keyframes collectPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.collected-pulse {
    animation: collectPulse 0.3s ease-out;
}

/* Responsive */
@media (max-width: 600px) {
    .screen-content {
        padding: 30px 20px;
    }

    .screen h1 {
        font-size: 2.5rem;
    }

    .screen h2 {
        font-size: 1.3rem;
    }

    .controls-info {
        padding: 15px;
    }

    .control-row {
        flex-wrap: wrap;
        font-size: 0.9rem;
    }

    .key {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    #hud {
        flex-direction: column;
        gap: 10px;
    }

    .hud-item {
        padding: 8px 16px;
        font-size: 1rem;
    }
}
