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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.game-container {
    background: rgba(26, 26, 46, 0.95);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 1200px;
    width: 100%;
    position: relative;
    padding-top: 120px; /* Space for fixed header */
}

.back-home-link {
    display: inline-block;
    margin-bottom: 15px;
    color: #4a9eff;
    text-decoration: none;
    padding: 8px 16px;
    background: rgba(74, 158, 255, 0.1);
    border-radius: 10px;
    font-size: 0.9em;
    transition: background 0.3s ease, transform 0.2s ease;
}

.back-home-link:hover {
    background: rgba(74, 158, 255, 0.2);
    transform: translateX(-3px);
}

.game-notice {
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.15) 0%, rgba(103, 232, 249, 0.15) 100%);
    border: 2px solid rgba(20, 184, 166, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.1);
}

.notice-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.notice-icon {
    font-size: 1.5rem;
}

.notice-text {
    flex: 1;
    color: #ffffff;
    font-size: 0.9rem;
    line-height: 1.4;
}

.header {
    text-align: center;
    margin-bottom: 10px;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1200px;
    z-index: 1002;
    background: rgba(26, 26, 46, 0.98);
    padding: 5px 15px;
    margin-bottom: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.header * {
    pointer-events: auto;
}

.header h1 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, #4a9eff 0%, #00d4ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 5px;
    margin-top: 5px;
}

.stats {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 5px;
    position: relative;
    z-index: 1002;
}

.stat {
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 6px;
    padding: 4px 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 90px;
    font-size: 0.85rem;
}

.hydration-stat {
    min-width: 160px;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    display: flex !important;
    visibility: visible !important;
    padding: 4px 10px !important;
    position: relative;
    z-index: 1003 !important;
    background: rgba(26, 26, 46, 0.95) !important;
    font-size: 0.85rem;
}

.hydration-bar {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    overflow: hidden;
    display: block !important;
    visibility: visible !important;
    border: 1px solid rgba(74, 158, 255, 0.5);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.hydration-fill {
    height: 100%;
    width: 100%;
    min-height: 10px;
    background: #4a9eff;
    transition: width 0.3s ease, background-color 0.3s ease;
    display: block !important;
    visibility: visible !important;
    border-radius: 5px;
}

.stat .label {
    color: #b9f2ff;
    font-weight: 600;
    font-size: 0.8rem;
}

.stat span:last-child {
    color: #fff;
    font-weight: bold;
    font-size: 0.9rem;
}

.game-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.game-area {
    flex: 1;
    min-width: 0;
}

#gameCanvas {
    display: block;
    margin: 0 auto;
    border: 3px solid rgba(74, 158, 255, 0.5);
    border-radius: 10px;
    background: #0f0f1e;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 100%;
}

.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: rgba(74, 158, 255, 0.1);
    border: 2px solid rgba(74, 158, 255, 0.3);
    border-radius: 10px;
    padding: 15px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    position: sticky;
    top: 140px;
}

.sidebar-content {
    color: #b9f2ff;
    font-size: 0.9rem;
}

.sidebar-content h3 {
    margin-top: 0;
    font-size: 1.2rem;
    border-bottom: 2px solid rgba(74, 158, 255, 0.3);
    padding-bottom: 10px;
}

.how-to-play-section {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(74, 158, 255, 0.2);
}

.how-to-play-section:last-child {
    border-bottom: none;
}

.how-to-play-section p {
    margin: 8px 0 5px 0;
    color: #b9f2ff;
    font-size: 0.95rem;
}

.how-to-play-section ul {
    margin: 5px 0;
    padding-left: 18px;
    font-size: 0.85rem;
    line-height: 1.4;
}

.how-to-play-section li {
    margin: 4px 0;
    color: #ffffff;
}

.controls {
    margin-top: 15px;
    text-align: center;
    width: 100%;
}

.control-info {
    margin-bottom: 15px;
    color: #b9f2ff;
}

.control-info p {
    margin: 5px 0;
}

.button-group {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, #4a9eff 0%, #00d4ff 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 15px rgba(74, 158, 255, 0.4);
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 158, 255, 0.6);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.splash-overlay {
    position: fixed;
    top: 120px; /* Start below header */
    left: 0;
    width: 100%;
    height: calc(100% - 120px); /* Height minus header */
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95) 0%, rgba(15, 15, 30, 0.98) 100%);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    padding: 20px 0;
    z-index: 1001;
    pointer-events: auto;
    animation: fadeIn 0.5s ease-in;
}

.splash-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.splash-content {
    text-align: center;
    max-width: 600px;
    padding: 30px 40px;
    margin: auto;
    animation: slideUp 0.6s ease-out;
    min-height: auto;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.splash-title h1 {
    font-size: 3rem;
    background: linear-gradient(135deg, #4a9eff 0%, #00d4ff 50%, #ffd700 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    text-shadow: 0 0 30px rgba(74, 158, 255, 0.5);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        filter: drop-shadow(0 0 10px rgba(74, 158, 255, 0.5));
    }
    to {
        filter: drop-shadow(0 0 20px rgba(74, 158, 255, 0.8));
    }
}

.splash-subtitle {
    font-size: 1.3rem;
    color: #b9f2ff;
    margin-bottom: 20px;
    font-weight: 300;
    letter-spacing: 2px;
}

.splash-character {
    font-size: 6rem;
    margin: 20px 0;
    animation: bounce 2s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(74, 158, 255, 0.6));
}

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

.splash-description {
    color: #b9f2ff;
    font-size: 1rem;
    line-height: 1.6;
    margin: 20px 0;
}

.splash-description p {
    margin: 10px 0;
}

.splash-features {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 20px 0;
}

.splash-feature {
    background: rgba(74, 158, 255, 0.15);
    border: 2px solid rgba(74, 158, 255, 0.4);
    border-radius: 25px;
    padding: 12px 20px;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    animation: fadeInScale 0.8s ease-out;
    animation-fill-mode: both;
}

.splash-feature:nth-child(1) { animation-delay: 0.1s; }
.splash-feature:nth-child(2) { animation-delay: 0.2s; }
.splash-feature:nth-child(3) { animation-delay: 0.3s; }
.splash-feature:nth-child(4) { animation-delay: 0.4s; }

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.splash-btn {
    margin-top: 20px;
    margin-bottom: 20px;
    padding: 15px 40px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #4a9eff 0%, #00d4ff 100%);
    box-shadow: 0 6px 25px rgba(74, 158, 255, 0.5);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 6px 25px rgba(74, 158, 255, 0.5);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 8px 30px rgba(74, 158, 255, 0.7);
    }
}

.splash-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 35px rgba(74, 158, 255, 0.8);
}

.overlay {
    position: fixed;
    top: 120px; /* Start below header */
    left: 0;
    width: 100%;
    height: calc(100% - 120px); /* Height minus header */
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    pointer-events: auto;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    border: 3px solid rgba(74, 158, 255, 0.5);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.overlay-content h2 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, #4a9eff 0%, #00d4ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
}

.overlay-content p {
    color: #b9f2ff;
    margin-bottom: 15px;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.2rem;
        margin-bottom: 3px;
        margin-top: 3px;
    }
    
    .header {
        padding: 3px 10px;
    }
    
    .stats {
        gap: 5px;
        margin-bottom: 3px;
    }
    
    .stat {
        min-width: 70px;
        padding: 3px 8px;
        font-size: 0.75rem;
    }
    
    .hydration-stat {
        min-width: 100%;
        display: flex !important;
        visibility: visible !important;
        padding: 3px 8px !important;
        gap: 3px !important;
    }
    
    .hydration-bar {
        height: 10px !important;
        display: block !important;
        visibility: visible !important;
    }
    
    .hydration-fill {
        min-height: 8px !important;
        display: block !important;
        visibility: visible !important;
    }
    
    .game-container {
        padding-top: 100px; /* Less space needed on mobile */
    }
    
    .splash-overlay {
        top: 100px;
        height: calc(100% - 100px);
        overflow-y: auto;
        align-items: flex-start;
        padding: 10px 0;
    }
    
    .splash-content {
        padding: 15px;
        max-width: 95%;
        margin: auto;
        min-height: auto;
    }
    
    .splash-title h1 {
        font-size: 2rem;
        margin-bottom: 5px;
    }
    
    .splash-subtitle {
        font-size: 1rem;
        margin-bottom: 15px;
    }
    
    .splash-character {
        font-size: 4rem;
        margin: 10px 0;
    }
    
    .splash-description {
        font-size: 0.9rem;
        margin: 15px 0;
        line-height: 1.5;
    }
    
    .splash-description p {
        margin: 5px 0;
    }
    
    .splash-features {
        gap: 8px;
        margin: 15px 0;
    }
    
    .splash-feature {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .splash-btn {
        padding: 12px 25px;
        font-size: 0.95rem;
        margin-top: 20px;
        margin-bottom: 20px;
    }
    
    .game-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: relative;
        top: 0;
        max-height: none;
        margin-top: 15px;
        order: -1; /* Show sidebar before game on mobile */
    }
    
    .sidebar-content {
        font-size: 0.85rem;
    }
    
    .sidebar-content h3 {
        font-size: 1.1rem;
    }
    
    .how-to-play-section {
        margin-bottom: 12px;
        padding-bottom: 12px;
    }
    
    .how-to-play-section p {
        font-size: 0.9rem;
    }
    
    .how-to-play-section ul {
        font-size: 0.8rem;
    }
    
    #gameCanvas {
        width: 100%;
        height: auto;
    }
    
    .button-group {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 300px;
    }
}

/* Touch Controls */
.touch-controls {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    padding: 15px;
    z-index: 1000;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.touch-row {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.touch-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(74, 158, 255, 0.85);
    border: 3px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease, background 0.1s ease;
}

.touch-btn:active, .touch-btn.active {
    transform: scale(0.9);
    background: rgba(74, 158, 255, 1);
}

.touch-jump {
    background: rgba(0, 212, 255, 0.85);
}

.touch-mine {
    background: rgba(255, 165, 0, 0.85);
}

.touch-tnt {
    background: rgba(255, 80, 80, 0.85);
}

@media (max-width: 768px) {
    .touch-controls {
        display: flex;
    }
    
    .desktop-controls {
        display: none;
    }
    
    .mobile-controls {
        display: block;
    }
}

@media (max-width: 480px) {
    .touch-btn {
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
    }
}
