/* World Obstacles - Vibrant Roblox-style UI */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #FF6B6B;
    --primary-dark: #EE5A5A;
    --secondary: #4ECDC4;
    --accent: #FFE66D;
    --purple: #A66CFF;
    --blue: #6BCBFF;
    --green: #7BF1A8;
    --orange: #FF9F43;
    --bg-dark: #1a1a2e;
    --bg-card: rgba(30, 30, 50, 0.95);
    --text-primary: #ffffff;
    --text-secondary: #b0b0c0;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --glow: 0 0 20px rgba(255, 107, 107, 0.5);
    --radius: 16px;
    --radius-sm: 10px;
}

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, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
    padding: 40px;
}

.loading-icon {
    font-size: 100px;
    animation: run 0.5s infinite alternate;
    margin-bottom: 20px;
}

@keyframes run {
    0% { transform: translateX(-10px) scaleX(1); }
    100% { transform: translateX(10px) scaleX(-1); }
}

.loading-content h1 {
    font-size: 3rem;
    margin-bottom: 30px;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
}

.loading-bar {
    width: 300px;
    max-width: 80vw;
    height: 14px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 7px;
    overflow: hidden;
    margin: 0 auto 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.loading-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.3s ease;
    border-radius: 5px;
}

#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, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 900;
}

.title-content {
    text-align: center;
    padding: 30px;
}

.title-icon {
    font-size: 80px;
    margin-bottom: 10px;
    animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.title-content h1 {
    font-size: 4rem;
    margin-bottom: 10px;
    text-shadow: 4px 4px 0 var(--primary-dark), 6px 6px 20px rgba(255, 107, 107, 0.5);
    line-height: 1;
    letter-spacing: 2px;
}

.subtitle {
    color: var(--accent);
    font-size: 1.2rem;
    margin-bottom: 20px;
    font-weight: bold;
}

.select-stage-label {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 20px;
    margin-bottom: 10px;
}

.btn-stage {
    display: block;
    width: 280px;
    max-width: 85vw;
    padding: 14px 25px;
    margin: 8px auto;
    border: none;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(180deg, #5a5a7a 0%, #4a4a6a 100%);
    color: white;
    box-shadow: 0 4px 0 #3a3a5a, var(--shadow);
}

.btn-stage:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #3a3a5a, var(--glow);
}

.btn-stage:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #3a3a5a;
}

.best-progress {
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 1rem;
}

.best-progress span:last-child {
    color: var(--accent);
    font-weight: bold;
    font-size: 1.2rem;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger {
    display: block;
    width: 280px;
    max-width: 85vw;
    padding: 18px 30px;
    margin: 12px auto;
    border: none;
    border-radius: var(--radius);
    font-size: 1.3rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn-primary {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 6px 0 #cc4444, var(--shadow);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 9px 0 #cc4444, var(--glow);
}

.btn-primary:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 #cc4444;
}

.btn-secondary {
    background: linear-gradient(180deg, var(--secondary) 0%, #3dbdb5 100%);
    color: white;
    box-shadow: 0 6px 0 #2a9d8f, var(--shadow);
}

.btn-secondary:hover {
    transform: translateY(-3px);
}

.btn-secondary:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 #2a9d8f;
}

.btn-danger {
    background: linear-gradient(180deg, #666 0%, #555 100%);
    color: white;
    box-shadow: 0 6px 0 #444, var(--shadow);
}

.btn-danger:hover {
    transform: translateY(-3px);
}

.button-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 12px auto;
}

.button-row .btn-primary {
    margin: 0;
    width: auto;
    min-width: 180px;
}

.btn-share {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 25px;
    border: none;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(180deg, #9b59b6 0%, #8e44ad 100%);
    color: white;
    box-shadow: 0 6px 0 #6c3483, var(--shadow);
}

.btn-share:hover {
    transform: translateY(-3px);
    box-shadow: 0 9px 0 #6c3483, var(--glow);
}

.btn-share:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 #6c3483;
}

.btn-other-games {
    position: absolute;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(180deg, #e67e22 0%, #d35400 100%);
    color: white;
    box-shadow: 0 4px 0 #a04000, var(--shadow);
}

.btn-other-games:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #a04000, var(--glow);
}

.btn-other-games:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #a04000;
}

.btn-icon {
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.2);
    width: 55px;
    height: 55px;
    border-radius: var(--radius-sm);
    font-size: 1.6rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* How to Play Screen */
#howto-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 900;
}

.howto-content {
    background: var(--bg-card);
    padding: 35px;
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.howto-content h2 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 2.2rem;
    color: var(--primary);
}

.howto-content h3 {
    margin: 25px 0 15px;
    color: var(--accent);
    font-size: 1.2rem;
}

.controls-list {
    margin: 20px 0;
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.key {
    background: linear-gradient(180deg, var(--purple) 0%, #8855dd 100%);
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.85rem;
    box-shadow: 0 3px 0 #6644aa;
}

.tips-list {
    list-style: none;
    padding: 0;
}

.tips-list li {
    padding: 10px 0;
    padding-left: 25px;
    position: relative;
    color: var(--text-secondary);
}

.tips-list li::before {
    content: "⭐";
    position: absolute;
    left: 0;
}

/* 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: 12px;
    flex-wrap: wrap;
}

.stat-box {
    background: var(--bg-card);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.stage-box {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.stage-box .stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stage-box .stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
    line-height: 1;
}

.stage-name {
    font-size: 0.85rem;
    color: var(--accent);
}

.stat-icon {
    font-size: 1.4rem;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: bold;
}

.deaths-box .stat-value {
    color: var(--primary);
}

.time-box .stat-value {
    color: var(--blue);
}

/* Progress Bar */
.progress-container {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    padding: 14px 28px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--shadow);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.progress-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.progress-bar {
    width: 220px;
    height: 18px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 9px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--green), var(--secondary));
    transition: width 0.4s ease;
    border-radius: 7px;
}

.progress-value {
    font-weight: bold;
    font-size: 1.2rem;
    min-width: 55px;
    color: var(--green);
}

/* Notifications */
#checkpoint-notify, #stage-complete, #death-notify {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    animation: notifyPop 0.5s ease;
}

@keyframes notifyPop {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.15); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.checkpoint-content {
    background: linear-gradient(135deg, var(--green) 0%, #5ed98c 100%);
    padding: 25px 50px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: 0 0 40px rgba(123, 241, 168, 0.6);
}

.checkpoint-icon {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 8px;
}

.checkpoint-text {
    font-size: 1.8rem;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.stage-complete-content {
    background: linear-gradient(135deg, var(--accent) 0%, #f0d850 100%);
    padding: 35px 65px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: 0 0 50px rgba(255, 230, 109, 0.6);
}

.stage-complete-icon {
    font-size: 5rem;
    display: block;
    margin-bottom: 10px;
}

.stage-complete-text {
    font-size: 2.5rem;
    font-weight: bold;
    display: block;
    margin-bottom: 12px;
    color: #333;
}

.stage-complete-next {
    font-size: 1.3rem;
    color: #555;
}

.death-content {
    background: linear-gradient(135deg, var(--primary) 0%, #dd5555 100%);
    padding: 22px 45px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: 0 0 35px rgba(255, 107, 107, 0.5);
}

.death-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 8px;
}

.death-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
}

/* Mobile Controls */
#mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    z-index: 100;
    pointer-events: none;
}

.joystick-container {
    position: absolute;
    bottom: 30px;
    left: 30px;
    pointer-events: auto;
}

.joystick-base {
    width: 130px;
    height: 130px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
}

.joystick-stick {
    width: 55px;
    height: 55px;
    background: linear-gradient(180deg, rgba(255,255,255,0.9) 0%, rgba(200,200,200,0.9) 100%);
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
    transition: transform 0.1s ease;
}

.mobile-buttons {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: flex;
    gap: 15px;
    pointer-events: auto;
}

.mobile-btn {
    border: none;
    border-radius: var(--radius);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.1s ease;
    text-transform: uppercase;
}

.jump-btn {
    width: 100px;
    height: 100px;
    background: linear-gradient(180deg, var(--green) 0%, #5ed98c 100%);
    color: white;
    font-size: 1.1rem;
    box-shadow: 0 6px 0 #4ab577;
    border-radius: 50%;
}

.jump-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #4ab577;
}

.restart-btn {
    width: 60px;
    height: 60px;
    background: var(--bg-card);
    color: white;
    font-size: 1.8rem;
    border: 3px solid rgba(255,255,255,0.3);
}

.restart-btn:active {
    background: var(--primary);
}

/* Pause Menu */
#pause-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    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: 420px;
    width: 90%;
    text-align: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.pause-content h2 {
    margin-bottom: 25px;
    font-size: 2.5rem;
    color: var(--primary);
}

.pause-stats {
    background: rgba(0, 0, 0, 0.3);
    padding: 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 25px;
}

.pause-stat {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.pause-stat:last-child {
    border-bottom: none;
}

.pause-stat span:last-child {
    font-weight: bold;
    color: var(--accent);
}

.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: 55px;
    height: 28px;
}

.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.4);
    border-radius: 28px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: var(--green);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(27px);
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pause-buttons .btn-primary,
.pause-buttons .btn-secondary,
.pause-buttons .btn-danger {
    width: 100%;
}

/* Game Complete Screen */
#complete-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #2d1b4e 50%, #1a2e3a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 600;
}

.complete-content {
    text-align: center;
    padding: 40px;
}

.complete-trophy {
    font-size: 120px;
    animation: trophySpin 2s ease-in-out infinite;
}

@keyframes trophySpin {
    0%, 100% { transform: rotateY(0deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.1); }
}

.complete-content h1 {
    font-size: 3rem;
    margin: 20px 0;
    background: linear-gradient(90deg, var(--accent), var(--orange), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.complete-subtitle {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.complete-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 40px;
}

.complete-stat {
    background: var(--bg-card);
    padding: 25px 40px;
    border-radius: var(--radius);
    border: 2px solid rgba(255,255,255,0.1);
}

.complete-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.complete-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent);
}

.complete-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .title-content h1 {
        font-size: 2.8rem;
    }

    .title-icon {
        font-size: 60px;
    }

    .progress-container {
        bottom: 180px;
        flex-direction: column;
        gap: 10px;
        padding: 15px 22px;
    }

    .progress-bar {
        width: 200px;
    }

    .hud-top {
        padding: 10px;
        gap: 8px;
    }

    .stat-box {
        padding: 10px 14px;
    }

    .stage-box .stat-value {
        font-size: 1.6rem;
    }

    .complete-stats {
        flex-direction: column;
        gap: 15px;
    }

    .complete-stat {
        padding: 20px 30px;
    }
}

@media (max-width: 480px) {
    .joystick-container {
        left: 15px;
        bottom: 15px;
    }

    .joystick-base {
        width: 110px;
        height: 110px;
    }

    .joystick-stick {
        width: 45px;
        height: 45px;
    }

    .mobile-buttons {
        right: 15px;
        bottom: 15px;
    }

    .jump-btn {
        width: 85px;
        height: 85px;
        font-size: 1rem;
    }

    .restart-btn {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
}
