/* ============================================
   PIXEL LAND - Complete CSS
   ============================================ */

/* === RESET & BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #00f5ff;
    --primary-dark: #00b8c4;
    --secondary: #ff00ff;
    --accent: #ffd700;
    --danger: #ff4444;
    --success: #00ff88;
    --bg-dark: #0a0a2a;
    --bg-darker: #050515;
    --bg-card: rgba(20, 20, 60, 0.85);
    --text-primary: #ffffff;
    --text-secondary: #a0a0ff;
    --border-glow: rgba(0, 245, 255, 0.3);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    font-family: 'Courier New', monospace;
    background: var(--bg-dark);
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    background: linear-gradient(135deg, var(--bg-darker) 0%, #0d1033 50%, var(--bg-dark) 100%);
    min-height: 100vh;
    position: relative;
}

/* === STARS BACKGROUND === */
.stars-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        radial-gradient(2px 2px at 20px 30px, var(--primary), transparent),
        radial-gradient(2px 2px at 40px 70px, var(--secondary), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(1px 1px at 130px 80px, var(--accent), transparent),
        radial-gradient(2px 2px at 160px 30px, var(--primary), transparent),
        radial-gradient(1px 1px at 200px 60px, #fff, transparent);
    background-size: 250px 250px;
    animation: starsMove 20s linear infinite;
    opacity: 0.5;
}

@keyframes starsMove {
    from { transform: translateY(0); }
    to { transform: translateY(-250px); }
}

/* === CONTAINER === */
.container {
    position: relative;
    z-index: 1;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* === TYPOGRAPHY === */
.game-title {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 10px;
    text-shadow: 0 0 20px var(--primary), 0 0 40px var(--primary);
    animation: titlePulse 2s ease-in-out infinite;
}

.pixel-text {
    letter-spacing: 3px;
}

@keyframes titlePulse {
    0%, 100% { text-shadow: 0 0 20px var(--primary), 0 0 40px var(--primary); }
    50% { text-shadow: 0 0 30px var(--secondary), 0 0 60px var(--secondary); }
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 30px;
    opacity: 0.8;
}

/* === HEADER === */
.game-header {
    text-align: center;
    margin-bottom: 30px;
    width: 100%;
}

/* === BUTTONS === */
.btn {
    display: inline-block;
    padding: 12px 24px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: bold;
    text-decoration: none;
    text-align: center;
    border: 2px solid var(--glass-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--glass-bg);
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 150px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    border-color: var(--primary);
    color: var(--bg-dark);
    box-shadow: 0 0 20px rgba(0, 245, 255, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 0 40px rgba(0, 245, 255, 0.5);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 0, 255, 0.1);
    border-color: var(--secondary);
    color: var(--secondary);
}

.btn-secondary:hover {
    background: rgba(255, 0, 255, 0.2);
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.3);
}

.btn-danger {
    background: rgba(255, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(255, 68, 68, 0.2);
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.3);
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.2rem;
    min-width: 200px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    min-width: auto;
}

.btn-icon {
    min-width: 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 1.2rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* === FORM === */
.login-form {
    width: 100%;
    max-width: 400px;
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    opacity: 0.7;
}

.game-input {
    width: 100%;
    padding: 14px 18px;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.3s ease;
}

.game-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--border-glow);
}

.game-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* === MENU BUTTONS === */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 300px;
    margin-top: 20px;
}

.menu-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* === GAME PAGE === */
.game-page {
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
}

#gameCanvas {
    display: block;
    background: linear-gradient(180deg, #1a0533 0%, #2d1b69 40%, #1a1a2e 100%);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    max-width: 100%;
    max-height: 100%;
    touch-action: none;
}

/* === HUD === */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 10px;
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, transparent 100%);
    pointer-events: none;
}

.hud-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hud-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--accent);
    text-shadow: 0 0 5px var(--accent);
}

/* === MOBILE CONTROLS === */
.mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 20px;
    pointer-events: none;
}

.controls-left {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.controls-right {
    pointer-events: auto;
}

.control-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    background: rgba(0, 245, 255, 0.15);
    color: var(--primary);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.1s ease;
    backdrop-filter: blur(5px);
}

.control-btn:active, .control-btn.active {
    background: rgba(0, 245, 255, 0.4);
    transform: scale(0.9);
    box-shadow: 0 0 20px var(--primary);
}

.btn-jump {
    width: 75px;
    height: 75px;
    border-color: var(--secondary);
    background: rgba(255, 0, 255, 0.15);
    color: var(--secondary);
    font-size: 2rem;
}

.btn-jump:active, .btn-jump.active {
    background: rgba(255, 0, 255, 0.4);
    box-shadow: 0 0 20px var(--secondary);
}

/* === GAME BUTTONS === */
.game-buttons {
    position: absolute;
    top: 60px;
    right: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* === OVERLAYS === */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

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

.overlay-content {
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 0 40px var(--border-glow);
    animation: slideUp 0.3s ease;
}

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

.overlay-content h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
}

.stats-display {
    margin-bottom: 20px;
    text-align: left;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.95rem;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row.highlight {
    font-size: 1.2rem;
    color: var(--accent);
    font-weight: bold;
    border-top: 2px solid var(--accent);
    margin-top: 5px;
    padding-top: 12px;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* === HIGHSCORE PAGE === */
.highscore-page .container {
    justify-content: flex-start;
    padding-top: 40px;
}

.highscore-section {
    width: 100%;
    max-width: 500px;
}

.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.leaderboard-item:hover {
    border-color: var(--primary);
    transform: translateX(5px);
}

.rank-gold { border-color: #ffd700; background: rgba(255, 215, 0, 0.1); }
.rank-silver { border-color: #c0c0c0; background: rgba(192, 192, 192, 0.1); }
.rank-bronze { border-color: #cd7f32; background: rgba(205, 127, 50, 0.1); }

.rank {
    font-size: 1.5rem;
    min-width: 40px;
    text-align: center;
    font-weight: bold;
}

.player-info {
    flex: 1;
    margin-left: 12px;
    text-align: left;
}

.player-name {
    font-weight: bold;
    font-size: 1rem;
    color: var(--text-primary);
}

.player-stats {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

.player-score {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent);
    text-shadow: 0 0 5px var(--accent);
}

.no-scores {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
    font-size: 1.1rem;
}

/* === INFO PAGE === */
.info-page .container {
    justify-content: flex-start;
    padding-top: 30px;
}

.content-section {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tutorial-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 20px;
}

.tutorial-card h2 {
    font-size: 1.2rem;
    margin-bottom: 12px;
    color: var(--primary);
}

.tutorial-card p {
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.tutorial-card ul {
    list-style: none;
    padding: 0;
}

.tutorial-card ul li {
    padding: 6px 0;
    padding-left: 20px;
    position: relative;
    color: var(--text-secondary);
    line-height: 1.5;
}

.tutorial-card ul li::before {
    content: '▶';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-size: 0.7rem;
}

.controls-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

kbd {
    background: var(--bg-card);
    border: 1px solid var(--primary);
    border-radius: 6px;
    padding: 6px 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--primary);
    min-width: 50px;
    text-align: center;
    box-shadow: 0 2px 0 rgba(0, 245, 255, 0.3);
}

.points-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.point-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.point-icon {
    font-size: 1.3rem;
    min-width: 30px;
    text-align: center;
}

.point-desc {
    flex: 1;
    color: var(--text-secondary);
}

.point-value {
    color: var(--accent);
    font-weight: bold;
}

.tip {
    margin-top: 10px;
    padding: 10px;
    background: rgba(0, 245, 255, 0.1);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
    font-size: 0.85rem;
    color: var(--primary);
}

/* === ADMIN === */
.admin-page .container {
    justify-content: flex-start;
    padding-top: 30px;
    max-width: 900px;
}

.admin-login-box {
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    margin: 0 auto;
}

.admin-login-box h2 {
    margin-bottom: 20px;
    color: var(--primary);
}

.admin-login-box .game-input {
    margin-bottom: 15px;
}

.admin-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.admin-table-container {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 20px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.admin-table th,
.admin-table td {
    padding: 10px;
    border: 1px solid var(--glass-border);
    text-align: left;
}

.admin-table th {
    background: var(--bg-card);
    color: var(--primary);
    font-weight: bold;
}

.admin-table tr:hover {
    background: rgba(0, 245, 255, 0.05);
}

.error-msg {
    color: var(--danger);
    margin-bottom: 15px;
    font-weight: bold;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    width: 100%;
}

.alert-success {
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.alert-error {
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
}

/* === LOADING SCREEN === */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
}

.loading-content h2 {
    color: var(--primary);
    margin-bottom: 20px;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-bar {
    width: 200px;
    height: 10px;
    background: var(--glass-bg);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid var(--primary);
}

.loading-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 5px;
    animation: loadProgress 1.5s ease forwards;
}

@keyframes loadProgress {
    to { width: 100%; }
}

/* === FOOTER === */
.game-footer {
    margin-top: 30px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    opacity: 0.6;
}

.version {
    margin-top: 5px;
    font-size: 0.7rem;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .game-title {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .btn-lg {
        padding: 14px 28px;
        font-size: 1rem;
    }

    .hud {
        padding: 8px;
    }

    .hud-value {
        font-size: 0.9rem;
    }

    .hud-label {
        font-size: 0.5rem;
    }

    .control-btn {
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
    }

    .btn-jump {
        width: 65px;
        height: 65px;
    }

    .mobile-controls {
        bottom: 15px;
        padding: 0 15px;
    }

    .overlay-content {
        padding: 20px;
    }

    .overlay-content h2 {
        font-size: 1.4rem;
    }

    .container {
        padding: 15px;
    }

    .leaderboard-item {
        padding: 10px 12px;
    }

    .player-name {
        font-size: 0.9rem;
    }

    .player-score {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 1.5rem;
    }

    .hud-row {
        gap: 5px;
    }

    .hud-item {
        min-width: 50px;
    }

    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .btn-jump {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .game-buttons {
        top: 50px;
        right: 5px;
    }

    .btn-icon {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
}

/* Landscape mode optimization */
@media (max-height: 500px) and (orientation: landscape) {
    .hud {
        padding: 5px;
    }

    .hud-value {
        font-size: 0.85rem;
    }

    .mobile-controls {
        bottom: 10px;
    }

    .control-btn {
        width: 50px;
        height: 50px;
    }

    .btn-jump {
        width: 60px;
        height: 60px;
    }
}

/* Prevent text selection on game */
.game-page * {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Hide scrollbars */
.game-page::-webkit-scrollbar {
    display: none;
}

.game-page {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Landscape recommendation banner (shown via JS) */
.landscape-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 245, 255, 0.1);
    border-top: 1px solid var(--primary);
    color: var(--primary);
    text-align: center;
    padding: 8px;
    font-size: 0.8rem;
    z-index: 50;
    display: none;
}

@media (max-width: 768px) and (orientation: portrait) {
    .game-page .landscape-banner {
        display: block;
    }
}