/* ============================================
   BURROW DIG BLAST! — Styles
   ============================================ */

:root {
    --earth-dark: #3d2817;
    --earth-mid: #5c3d2e;
    --earth-light: #8b6b4a;
    --earth-surface: #7cb342;
    --earth-grass: #558b2f;
    --sky-top: #4fc3f7;
    --sky-bottom: #81d4fa;
    --gold: #ffd54f;
    --gold-dark: #ffb300;
    --accent: #ff7043;
    --accent-glow: #ff5722;
    --text-light: #fff8e1;
    --text-dark: #3e2723;
    --block-red: #f06292;
    --block-blue: #64b5f6;
    --block-green: #81c784;
    --block-yellow: #ffd54f;
    --block-purple: #ce93d8;
    --block-orange: #ffb74d;
    --combo-color: #ffd600;
    --font-main: 'Fredoka', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

html, body {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    font-family: var(--font-main);
    background: var(--earth-dark);
}

/* ============================================
   GAME CONTAINER
   ============================================ */
#game-container {
    width: 100%;
    height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

.screen.active {
    display: flex;
}

/* ============================================
   TITLE SCREEN
   ============================================ */
#title-screen {
    background: linear-gradient(180deg,
        var(--sky-top) 0%,
        var(--sky-bottom) 40%,
        var(--earth-surface) 40%,
        var(--earth-grass) 42%,
        var(--earth-mid) 42%,
        var(--earth-dark) 100%
    );
}

.title-content {
    text-align: center;
    z-index: 2;
    padding: 2rem;
}

.title-prairie-dog {
    font-size: 5rem;
    animation: bounce 2s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.game-title {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--text-light);
    text-shadow:
        3px 3px 0 var(--earth-dark),
        -1px -1px 0 var(--earth-dark),
        1px -1px 0 var(--earth-dark),
        -1px 1px 0 var(--earth-dark);
    line-height: 1.1;
    margin: 0.5rem 0;
}

.game-title .blast {
    color: var(--gold);
    font-size: 3.5rem;
    text-shadow:
        3px 3px 0 var(--accent-glow),
        -1px -1px 0 var(--accent-glow),
        1px -1px 0 var(--accent-glow),
        -1px 1px 0 var(--accent-glow),
        0 0 20px rgba(255, 183, 77, 0.5);
}

.subtitle {
    color: var(--text-light);
    font-size: 1.1rem;
    margin: 0.5rem 0 1.5rem;
    opacity: 0.9;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

/* Buttons */
.btn {
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 1.3rem;
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.95);
}

.btn-play {
    background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%);
    color: var(--text-dark);
    padding: 16px 48px;
    box-shadow:
        0 6px 0 #e69100,
        0 8px 16px rgba(0,0,0,0.3);
    text-shadow: 1px 1px 0 rgba(255,255,255,0.3);
}

.btn-play:active {
    box-shadow:
        0 2px 0 #e69100,
        0 4px 8px rgba(0,0,0,0.3);
    transform: translateY(4px) scale(0.98);
}

.btn-secondary {
    background: linear-gradient(180deg, var(--earth-light) 0%, var(--earth-mid) 100%);
    color: var(--text-light);
    padding: 12px 36px;
    box-shadow:
        0 4px 0 var(--earth-dark),
        0 6px 12px rgba(0,0,0,0.3);
    margin-top: 12px;
    font-size: 1.1rem;
}

.title-stats {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-top: 2rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    background: rgba(0,0,0,0.25);
    padding: 10px 18px;
    border-radius: 12px;
    backdrop-filter: blur(4px);
}

.stat-label {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold);
}

.ground-decoration {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30%;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 40px,
        rgba(255,255,255,0.03) 40px,
        rgba(255,255,255,0.03) 80px
    );
    pointer-events: none;
}

/* ============================================
   GAME SCREEN
   ============================================ */
#game-screen {
    background: linear-gradient(180deg,
        var(--earth-mid) 0%,
        var(--earth-dark) 100%
    );
    justify-content: flex-start;
}

/* HUD */
#game-hud {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    z-index: 10;
}

.hud-left, .hud-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

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

.depth-display {
    background: rgba(121, 85, 72, 0.6);
    color: var(--text-light);
}

.level-display {
    background: rgba(255, 213, 79, 0.2);
    color: var(--gold);
    font-weight: 700;
}

.score-display {
    background: rgba(255, 213, 79, 0.2);
    color: var(--gold);
}

.moves-display {
    background: rgba(255, 112, 67, 0.3);
    color: #ffab91;
}

/* Prairie Dog Container */
#prairie-dog-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 16px;
    z-index: 5;
}

#prairie-dog {
    font-size: 2.2rem;
    transition: transform 0.3s ease;
}

.prairie-dog-idle {
    animation: pd-idle 3s ease-in-out infinite;
}

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

.prairie-dog-happy {
    animation: pd-happy 0.5s ease-in-out;
}

@keyframes pd-happy {
    0% { transform: scale(1); }
    25% { transform: scale(1.3) rotate(-10deg); }
    50% { transform: scale(1.3) rotate(10deg); }
    75% { transform: scale(1.2) rotate(-5deg); }
    100% { transform: scale(1); }
}

.prairie-dog-dig {
    animation: pd-dig 0.3s ease-in-out infinite;
}

@keyframes pd-dig {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}

/* Dig Progress Bar */
#dig-progress-bar {
    width: 80%;
    max-width: 280px;
    height: 10px;
    background: rgba(0,0,0,0.4);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 4px;
    border: 1px solid rgba(255,255,255,0.1);
}

#dig-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--block-green), var(--gold));
    border-radius: 5px;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(102, 187, 106, 0.5);
}

/* Game Canvas */
#game-canvas {
    display: block;
    margin: 0 auto;
    border-radius: 8px;
    touch-action: none;
}

/* Combo Display */
#combo-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 700;
    color: var(--combo-color);
    text-shadow:
        3px 3px 0 var(--accent-glow),
        0 0 20px rgba(255, 214, 0, 0.5);
    pointer-events: none;
    z-index: 20;
    transition: opacity 0.3s ease;
}

#combo-display.hidden {
    opacity: 0;
}

#combo-display.show {
    opacity: 1;
    animation: combo-pop 0.6s ease-out;
}

@keyframes combo-pop {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    40% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* ============================================
   LEVEL COMPLETE SCREEN
   ============================================ */
#level-complete-screen {
    background: radial-gradient(circle at 50% 30%,
        rgba(255, 213, 79, 0.15) 0%,
        rgba(61, 40, 23, 0.95) 100%
    );
    backdrop-filter: blur(8px);
}

.level-complete-content, .game-over-content {
    text-align: center;
    padding: 2rem;
}

.celebration {
    font-size: 4rem;
    animation: celebrate 1s ease-in-out infinite;
}

@keyframes celebrate {
    0%, 100% { transform: rotate(-10deg) scale(1); }
    50% { transform: rotate(10deg) scale(1.1); }
}

.level-complete-content h2, .game-over-content h2 {
    color: var(--text-light);
    font-size: 2.2rem;
    margin: 0.5rem 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.level-stars {
    font-size: 2.5rem;
    margin: 1rem 0;
    display: flex;
    gap: 8px;
    justify-content: center;
}

.level-stars .star {
    animation: star-pop 0.4s ease-out backwards;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.level-stars .star:nth-child(1) { animation-delay: 0.2s; }
.level-stars .star:nth-child(2) { animation-delay: 0.4s; }
.level-stars .star:nth-child(3) { animation-delay: 0.6s; }

.level-stars .star.empty {
    opacity: 0.3;
    filter: grayscale(1);
}

@keyframes star-pop {
    0% { transform: scale(0) rotate(-180deg); opacity: 0; }
    60% { transform: scale(1.3) rotate(10deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.level-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 1.5rem 0;
}

.level-stat {
    display: flex;
    justify-content: space-between;
    background: rgba(255,255,255,0.08);
    padding: 10px 20px;
    border-radius: 10px;
}

.level-stat-label {
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
}

.level-stat-value {
    color: var(--gold);
    font-weight: 700;
    font-size: 1rem;
}

/* ============================================
   GAME OVER SCREEN
   ============================================ */
#game-over-screen {
    background: radial-gradient(circle at 50% 30%,
        rgba(239, 83, 80, 0.15) 0%,
        rgba(61, 40, 23, 0.95) 100%
    );
    backdrop-filter: blur(8px);
}

.game-over-dog {
    font-size: 4rem;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.game-over-content p {
    color: rgba(255,255,255,0.7);
    font-size: 1rem;
    margin-bottom: 1rem;
}

/* ============================================
   PARTICLES & EFFECTS
   ============================================ */
.particle {
    position: absolute;
    pointer-events: none;
    z-index: 15;
    border-radius: 50%;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-height: 600px) {
    .title-prairie-dog { font-size: 3rem; }
    .game-title { font-size: 2rem; }
    .game-title .blast { font-size: 2.5rem; }
    .subtitle { font-size: 0.9rem; margin: 0.3rem 0 1rem; }
    .title-stats { margin-top: 1rem; }
    .btn-play { padding: 12px 36px; font-size: 1.1rem; }
}

@media (min-width: 481px) {
    #game-container {
        border-left: 2px solid rgba(255,255,255,0.05);
        border-right: 2px solid rgba(255,255,255,0.05);
        box-shadow: 0 0 40px rgba(0,0,0,0.5);
    }
}

/* ============================================
   CRAWLABLE CONTENT (SEO / About the game)
   Sits below the 100vh game container; readable,
   selectable, server-rendered text for search engines.
   ============================================ */
.game-info {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
    background: var(--text-light);
    color: var(--text-dark);
    -webkit-user-select: text;
    user-select: text;
    line-height: 1.6;
}

.game-info h1 {
    font-size: 1.9rem;
    line-height: 1.2;
    color: var(--earth-dark);
    margin: 0 0 0.75rem;
    font-weight: 700;
}

.game-info .lead {
    font-size: 1.1rem;
    color: var(--earth-mid);
    margin: 0 0 1.5rem;
}

.game-info h2 {
    font-size: 1.4rem;
    color: var(--earth-dark);
    margin: 1.75rem 0 0.6rem;
    font-weight: 600;
}

.game-info p,
.game-info li {
    color: #4e342e;
}

.game-info ul {
    margin: 0.5rem 0 1rem 1.25rem;
    list-style: disc;
}

.game-info li {
    margin-bottom: 0.4rem;
}

.game-info details {
    background: #fff;
    border: 1px solid #d7ccc8;
    border-radius: 12px;
    margin-bottom: 0.6rem;
    padding: 0.75rem 1rem;
}

.game-info summary {
    font-weight: 600;
    color: var(--earth-dark);
    cursor: pointer;
}

.game-info details[open] summary {
    margin-bottom: 0.5rem;
}

.game-info details p {
    margin: 0;
}

@media (max-width: 480px) {
    .game-info h1 { font-size: 1.6rem; }
    .game-info h2 { font-size: 1.25rem; }
}
