@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800&family=Press+Start+2P&display=swap');

:root {
    --bg-dark: #070a12;
    --panel-bg: rgba(15, 23, 42, 0.85);
    --border-color: rgba(56, 189, 248, 0.3);
    --accent-gold: #f59e0b;
    --accent-cyan: #38bdf8;
    --accent-red: #ef4444;
    --text-light: #f8fafc;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 50% 20%, rgba(56, 189, 248, 0.08) 0%, transparent 60%),
        radial-gradient(circle at 80% 80%, rgba(245, 158, 11, 0.05) 0%, transparent 50%);
    color: var(--text-light);
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* App Container */
#app-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px;
    max-width: 100vw;
}

/* Header HUD */
#hud-header {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px 16px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 12px 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    font-weight: 600;
    font-size: 1.05rem;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.score-text {
    color: var(--accent-cyan);
    font-weight: 800;
}

.high-score-text {
    color: var(--accent-gold);
}

/* Game Canvas Wrapper */
#game-wrapper {
    position: relative;
    width: 800px;
    height: 608px;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    box-shadow: 0 0 40px rgba(56, 189, 248, 0.15), 0 20px 50px rgba(0, 0, 0, 0.8);
}

canvas#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #000;
}

/* Overlays (Start, Pause, Game Over, Victory) */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 10, 18, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 16px 20px;
    text-align: center;
    transition: opacity 0.3s ease;
    overflow-y: auto;
}

.hidden {
    display: none !important;
}

#leaderboardOverlay {
    z-index: 100 !important;
}

.game-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 1.8rem;
    color: var(--accent-gold);
    text-shadow: 0 0 20px rgba(245, 158, 11, 0.6), 0 4px 0 #92400e;
    margin-bottom: 12px;
    line-height: 1.3;
}

.subtitle {
    font-size: 1rem;
    color: #94a3b8;
    max-width: 480px;
    margin-bottom: 14px;
}

/* Philosopher Quote Box */
.quote-box {
    background: rgba(15, 23, 42, 0.85);
    border: 2px solid #fbbf24;
    border-radius: 12px;
    padding: 24px 32px;
    max-width: 520px;
    margin-bottom: 28px;
    box-shadow: 0 0 25px rgba(251, 191, 36, 0.3);
    text-align: center;
}

.quote-text {
    font-size: 1.25rem;
    font-style: italic;
    color: #fef08a;
    line-height: 1.6;
    margin-bottom: 12px;
}

.quote-author {
    font-size: 1.05rem;
    font-weight: 700;
    color: #38bdf8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Buttons */
.btn {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    padding: 14px 36px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--accent-gold), #d97706);
    color: #000;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    z-index: 50;
    pointer-events: auto;
    user-select: auto;
    -webkit-user-select: auto;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.6);
}

.btn:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: linear-gradient(135deg, #38bdf8, #0284c7);
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.4);
}

.btn-secondary:hover {
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.6);
}

/* User Login Card on Start Menu */
.user-login-card {
    background: rgba(15, 23, 42, 0.9);
    border: 2px solid rgba(168, 85, 247, 0.4);
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.2);
    padding: 12px 18px;
    border-radius: 12px;
    margin-bottom: 12px;
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* Controls Info */
.controls-info {
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.key-badge {
    background: rgba(255, 255, 255, 0.15);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    color: #38bdf8;
}

/* Mobile Virtual Controls */
#touch-controls {
    display: none;
    width: 100%;
    max-width: 800px;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
}

@media (max-width: 850px) {
    #touch-controls {
        display: flex;
    }
}

.dpad {
    display: grid;
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 50px);
    gap: 4px;
}

.dpad-btn, .action-btn {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border-color);
    color: #fff;
    border-radius: 8px;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.dpad-btn:active, .action-btn:active {
    background: var(--accent-cyan);
    color: #000;
}

.action-buttons {
    display: flex;
    gap: 12px;
}

.action-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 1.5rem;
}

/* Level Up Toast Banner */
.level-up-toast {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.95), rgba(217, 119, 6, 0.95));
    color: #000;
    padding: 16px 28px;
    border-radius: 12px;
    border: 2px solid #fef08a;
    box-shadow: 0 0 30px rgba(250, 204, 21, 0.6), 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 100;
    text-align: center;
    pointer-events: none;
    animation: toastPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-title {
    font-size: 1.3rem;
    font-weight: 900;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
    margin-bottom: 4px;
}

.toast-desc {
    font-size: 1.05rem;
    font-weight: 700;
}

@keyframes toastPop {
    0% { transform: translate(-50%, -40px) scale(0.8); opacity: 0; }
    100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

/* Story Lore Box */
.story-box {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(251, 191, 36, 0.4);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
    padding: 20px 24px;
    border-radius: 12px;
    max-width: 620px;
    color: #e2e8f0;
    font-size: 1.02rem;
    line-height: 1.6;
    text-align: left;
}

.story-paragraph {
    margin-bottom: 12px;
}

.story-paragraph:last-child {
    margin-bottom: 0;
}

/* Info / Guide Box */
.info-box {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(56, 189, 248, 0.4);
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.7);
    padding: 18px 22px;
    border-radius: 12px;
    max-width: 680px;
    max-height: 380px;
    overflow-y: auto;
    color: #e2e8f0;
    font-size: 0.95rem;
    line-height: 1.55;
    text-align: left;
}

.info-box::-webkit-scrollbar {
    width: 8px;
}

.info-box::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 4px;
}

.info-box::-webkit-scrollbar-thumb {
    background: #38bdf8;
    border-radius: 4px;
}

.info-section {
    margin-bottom: 16px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
}

.info-section:last-child {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.info-section h3 {
    margin: 0 0 8px 0;
    color: #fbbf24;
    font-size: 1.1rem;
}

.info-section ul, .info-section ol {
    margin: 0;
    padding-left: 20px;
}

.info-section li {
    margin-bottom: 6px;
}

/* Player Display & Timer in HUD */
.player-name-text {
    color: #c084fc;
    font-weight: 800;
}

.timer-text {
    color: #38bdf8;
    font-family: monospace, monospace;
    font-size: 1.1rem;
    letter-spacing: 1px;
}

/* User Login Card on Start Menu */
.user-login-card {
    background: rgba(15, 23, 42, 0.9);
    border: 2px solid rgba(168, 85, 247, 0.4);
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.2);
    padding: 16px 22px;
    border-radius: 12px;
    margin-bottom: 20px;
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.user-label {
    font-weight: 800;
    font-size: 0.95rem;
    color: #c084fc;
    letter-spacing: 0.5px;
}

.login-inputs-row {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

.nickname-input {
    flex: 1.2;
    background: rgba(7, 10, 18, 0.9);
    border: 1.5px solid #a855f7;
    border-radius: 8px;
    padding: 10px 14px;
    color: #f8fafc;
    font-weight: 700;
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.nickname-input:focus {
    border-color: #fbbf24;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.4);
}

.nickname-select {
    flex: 1;
    background: rgba(15, 23, 42, 0.95);
    border: 1.5px solid rgba(168, 85, 247, 0.5);
    border-radius: 8px;
    padding: 10px 10px;
    color: #f8fafc;
    font-weight: 600;
    font-size: 0.9rem;
    font-family: 'Outfit', sans-serif;
    outline: none;
    cursor: pointer;
}

.player-status-badge {
    font-size: 0.88rem;
    color: #fef08a;
    font-weight: 600;
    line-height: 1.3;
}

/* Leaderboard Table Container & Styles */
.leaderboard-table-container {
    width: 100%;
    max-width: 580px;
    max-height: 320px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.85);
    border: 2px solid #a855f7;
    border-radius: 12px;
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.25);
    padding: 4px;
}

.leaderboard-table-container::-webkit-scrollbar {
    width: 8px;
}
.leaderboard-table-container::-webkit-scrollbar-thumb {
    background: #a855f7;
    border-radius: 4px;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    font-size: 0.95rem;
}

.leaderboard-table th {
    background: rgba(168, 85, 247, 0.25);
    color: #fbbf24;
    padding: 10px 12px;
    font-weight: 800;
    border-bottom: 2px solid rgba(168, 85, 247, 0.4);
}

.leaderboard-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

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

.current-user-row {
    background: rgba(168, 85, 247, 0.2) !important;
    font-weight: 800;
    color: #fef08a !important;
}
