/* Turf Master - Roblox-style UI */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #4CAF50;
    --primary-dark: #388E3C;
    --secondary: #8BC34A;
    --accent: #FFC107;
    --danger: #F44336;
    --bg-dark: #1a2e1a;
    --bg-card: rgba(30, 50, 30, 0.95);
    --text-primary: #ffffff;
    --text-secondary: #b0c0b0;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    user-select: none;
    touch-action: none;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a2e1a 0%, #2d4a2d 50%, #1a3a1a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
    padding: 40px;
}

.loading-icon {
    font-size: 80px;
    animation: bounce 1s infinite;
    margin-bottom: 20px;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.loading-content h1 {
    font-size: 2.5rem;
    margin-bottom: 30px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loading-bar {
    width: 300px;
    max-width: 80vw;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    margin: 0 auto 20px;
}

.loading-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.3s ease;
    border-radius: 6px;
}

#loading-text {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Title Screen */
#title-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a2e1a 0%, #2d4a2d 50%, #1a3a1a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 900;
}

.btn-other-games {
    position: absolute;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-other-games:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.btn-other-games:active {
    transform: translateY(0);
}

.title-content {
    text-align: center;
    padding: 40px;
}

.title-icon {
    font-size: 100px;
    margin-bottom: 20px;
    animation: sway 2s ease-in-out infinite;
}

@keyframes sway {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.title-content h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
    line-height: 1.1;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.best-score-display {
    background: var(--bg-card);
    padding: 15px 30px;
    border-radius: var(--radius);
    margin-bottom: 30px;
    display: inline-block;
}

.best-score-display span {
    margin: 0 5px;
}

.best-score-display span:nth-child(2) {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent);
}

/* Buttons */
.btn-primary, .btn-secondary {
    display: block;
    width: 250px;
    max-width: 80vw;
    padding: 18px 30px;
    margin: 10px auto;
    border: none;
    border-radius: var(--radius);
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 0 #2E7D32, var(--shadow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #2E7D32, var(--shadow);
}

.btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #2E7D32;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-share {
    display: block;
    width: 250px;
    max-width: 80vw;
    padding: 18px 30px;
    margin: 10px auto;
    border: none;
    border-radius: var(--radius);
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: linear-gradient(180deg, #2196F3 0%, #1565C0 100%);
    color: white;
    box-shadow: 0 4px 0 #0D47A1, var(--shadow);
}

.btn-share:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #0D47A1, var(--shadow);
}

.btn-share:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #0D47A1;
}

.btn-share-small {
    display: inline-block;
    padding: 8px 16px;
    margin-top: 10px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    background: linear-gradient(180deg, #2196F3 0%, #1565C0 100%);
    color: white;
    box-shadow: 0 2px 0 #0D47A1;
}

.btn-share-small:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 0 #0D47A1;
}

.btn-share-small:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #0D47A1;
}

.btn-icon {
    background: var(--bg-card);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: var(--radius-sm);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* How to Play Screen */
#howto-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a2e1a 0%, #2d4a2d 50%, #1a3a1a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 900;
}

.howto-content {
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.howto-content h2 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 2rem;
}

.howto-content h3 {
    margin: 20px 0 10px;
    color: var(--secondary);
}

.howto-content p {
    color: var(--text-secondary);
    line-height: 1.6;
}

.controls-list {
    margin: 20px 0;
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.key {
    background: var(--primary);
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9rem;
}

/* Game Container */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* HUD */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

#hud > * {
    pointer-events: auto;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-box {
    background: var(--bg-card);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 1.3rem;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: bold;
}

.stat-box.coins .stat-value {
    color: var(--accent);
}

.stat-box.best .stat-value {
    color: #FFD700;
}

/* Progress Bar */
.progress-container {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    padding: 12px 25px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow);
}

.progress-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.progress-bar {
    width: 200px;
    height: 16px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.3s ease;
    border-radius: 8px;
}

.progress-value {
    font-weight: bold;
    font-size: 1.1rem;
    min-width: 50px;
}

/* Stage Complete */
#stage-complete {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    animation: stagePopIn 0.5s ease;
}

@keyframes stagePopIn {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.stage-complete-content {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 30px 60px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: 0 0 40px rgba(76, 175, 80, 0.5);
}

.stage-complete-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 10px;
}

.stage-complete-text {
    font-size: 2rem;
    font-weight: bold;
    display: block;
    margin-bottom: 10px;
}

.stage-complete-bonus {
    font-size: 1.5rem;
    color: var(--accent);
}

/* Collect Popup */
#collect-popup {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 150;
    pointer-events: none;
}

.collect-text {
    background: var(--accent);
    color: #333;
    padding: 10px 25px;
    border-radius: var(--radius);
    font-weight: bold;
    font-size: 1.3rem;
    animation: collectPop 1s ease forwards;
}

@keyframes collectPop {
    0% { transform: scale(0) translateY(0); opacity: 0; }
    20% { transform: scale(1.2) translateY(0); opacity: 1; }
    100% { transform: scale(1) translateY(-50px); opacity: 0; }
}

/* Mobile Controls - D-Pad */
#mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    z-index: 100;
    pointer-events: none;
}

.dpad-container {
    position: absolute;
    bottom: 30px;
    left: 30px;
    pointer-events: auto;
}

.dpad {
    display: grid;
    grid-template-columns: repeat(3, 60px);
    grid-template-rows: repeat(3, 60px);
    gap: 5px;
}

.dpad-btn {
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.dpad-btn:active,
.dpad-btn.pressed {
    background: var(--primary);
    transform: scale(0.95);
}

.dpad-center {
    background: rgba(0, 0, 0, 0.3);
    border: none;
    cursor: default;
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-center { grid-column: 2; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

/* Pause Menu */
#pause-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 500;
}

.pause-content {
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.pause-content h2 {
    margin-bottom: 25px;
    font-size: 2rem;
}

.settings-list {
    margin-bottom: 25px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

/* Toggle Switch */
.toggle {
    position: relative;
    width: 50px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.pause-stats {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 25px;
}

.pause-stat {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

.pause-stat span:last-child {
    font-weight: bold;
    color: var(--accent);
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pause-buttons .btn-primary,
.pause-buttons .btn-secondary {
    width: 100%;
}

/* Game Over Screen */
#gameover-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 600;
}

.gameover-content {
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius);
    max-width: 450px;
    width: 90%;
    text-align: center;
}

.gameover-content h2 {
    font-size: 2.5rem;
    margin-bottom: 25px;
    color: var(--primary);
}

.gameover-stats {
    margin-bottom: 30px;
}

.gameover-stat {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.gameover-stat.highlight {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 193, 7, 0.1));
    border: 2px solid var(--accent);
}

.gameover-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.gameover-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent);
}

.gameover-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gameover-buttons .btn-primary,
.gameover-buttons .btn-secondary {
    width: 100%;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .title-content h1 {
        font-size: 2.2rem;
    }

    .title-icon {
        font-size: 70px;
    }

    .progress-container {
        bottom: 200px;
        flex-direction: column;
        gap: 8px;
        padding: 15px 20px;
    }

    .progress-bar {
        width: 180px;
    }

    .hud-top {
        padding: 10px;
    }

    .stat-box {
        padding: 8px 12px;
    }

    .stat-value {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .dpad-container {
        left: 15px;
        bottom: 15px;
    }

    .dpad {
        grid-template-columns: repeat(3, 50px);
        grid-template-rows: repeat(3, 50px);
    }

    .dpad-btn {
        font-size: 1.2rem;
    }
}
