/* ==========================================
   WOW BALL - Bilard 3D Styles
   ========================================== */

/* CSS Variables - Billiard Club Theme */
:root {
    --bg-dark: #1a0e08;
    --bg-dark-alpha: rgba(26, 14, 8, 0.95);
    --accent-orange: #FF9500;
    --accent-orange-dark: #CC7700;
    --accent-orange-light: #FFB347;
    --text-primary: #FFFFFF;
    --text-secondary: #B0B8C8;
    --success: #00FF88;
    --danger: #FF3B30;
    --panel-bg: rgba(30, 20, 15, 0.9);
    --panel-border: rgba(255, 149, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(255, 149, 0, 0.3);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    user-select: none;
    -webkit-user-select: none;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a0e08 0%, #2a1810 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    animation: fadeInUp 0.8s ease;
}

.loading-content h1 {
    font-size: 4rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-orange) 0%, var(--accent-orange-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2rem;
    letter-spacing: 0.2em;
    text-shadow: 0 0 30px rgba(255, 149, 0, 0.5);
}

.loading-content p {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.loader {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 149, 0, 0.1);
    border-top-color: var(--accent-orange);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 2rem;
}

.progress-bar {
    width: 300px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-orange) 0%, var(--accent-orange-light) 100%);
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--accent-orange);
}

#loading-percentage {
    color: var(--accent-orange);
    font-weight: 700;
    font-size: 1.1rem;
}

/* Game Container */
#game-container {
    width: 100%;
    height: 100%;
    position: relative;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: var(--bg-dark-alpha);
    border-bottom: 2px solid var(--panel-border);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.hud-left, .hud-center, .hud-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.logo {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--accent-orange);
    text-shadow: 0 0 10px rgba(255, 149, 0, 0.5);
    letter-spacing: 0.1em;
}

.score-container, .balls-remaining {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.score-value, .count-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-orange);
    text-shadow: 0 0 10px rgba(255, 149, 0, 0.5);
    min-width: 60px;
    text-align: center;
}

/* Player Score Display (2P mode) */
.player-score {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 8px;
    transition: var(--transition-smooth);
    font-size: 1.5rem;
}

.player-score.active-player {
    background: rgba(255, 149, 0, 0.2);
    border: 2px solid var(--accent-orange);
    box-shadow: 0 0 15px rgba(255, 149, 0, 0.4);
}

.player-divider {
    margin: 0 0.5rem;
    color: var(--text-secondary);
}

.game-status {
    padding: 0.5rem 1.5rem;
    background: rgba(255, 149, 0, 0.1);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    backdrop-filter: blur(5px);
}

.status-text {
    color: var(--accent-orange);
    font-weight: 600;
    font-size: 1rem;
}

/* Controls Panel */
#controls-panel {
    position: absolute;
    right: 0;
    top: 80px;
    bottom: 0;
    width: 320px;
    background: var(--panel-bg);
    border-left: 2px solid var(--panel-border);
    backdrop-filter: blur(10px);
    overflow-y: auto;
    padding: 1.5rem;
    z-index: 90;
    transition: transform 0.3s ease;
}

#controls-panel.hidden {
    transform: translateX(100%);
}

.control-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.control-section:last-child {
    border-bottom: none;
}

.control-section h3 {
    color: var(--accent-orange);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    font-size: 0.85rem;
}

.control-key {
    background: rgba(255, 149, 0, 0.2);
    color: var(--accent-orange);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    border: 1px solid var(--panel-border);
}

.control-desc {
    color: var(--text-secondary);
    flex: 1;
    margin-left: 1rem;
    text-align: right;
}

/* Power Meter */
.power-meter-section {
    background: rgba(255, 149, 0, 0.05);
    padding: 1rem;
    border-radius: 8px;
}

.power-meter {
    width: 100%;
    height: 30px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    overflow: hidden;
    border: 2px solid rgba(255, 149, 0, 0.3);
    margin-bottom: 0.5rem;
}

.power-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success) 0%, var(--accent-orange) 50%, var(--danger) 100%);
    width: 0%;
    transition: width 0.1s ease;
    box-shadow: 0 0 15px currentColor;
}

.power-value {
    text-align: center;
    color: var(--accent-orange);
    font-weight: 700;
    font-size: 1.2rem;
}

/* Buttons */
.buttons-section {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.btn {
    width: 100%;
    padding: 0.8rem 1.2rem;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-primary {
    background: var(--accent-orange);
    border-color: var(--accent-orange);
    color: #000;
    box-shadow: 0 4px 15px rgba(255, 149, 0, 0.4);
}

.btn-primary:hover {
    background: var(--accent-orange-light);
    border-color: var(--accent-orange-light);
    box-shadow: 0 6px 20px rgba(255, 149, 0, 0.6);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(255, 149, 0, 0.3);
}

.btn-secondary {
    background: transparent;
    border-color: var(--panel-border);
    color: var(--text-primary);
}

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

.btn-large {
    padding: 1.2rem 2rem;
    font-size: 1.2rem;
}

.btn-icon {
    font-size: 1.2rem;
}

/* Stats Section */
.stats-section {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.stat-item:last-child {
    margin-bottom: 0;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stat-value {
    color: var(--accent-orange);
    font-weight: 700;
    font-size: 1.1rem;
}

/* Shot Info Overlay */
.shot-info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-dark-alpha);
    padding: 2rem 3rem;
    border-radius: 16px;
    border: 2px solid var(--accent-orange);
    box-shadow: var(--shadow-glow);
    z-index: 200;
    animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    backdrop-filter: blur(10px);
}

.shot-info.hidden {
    display: none;
}

.shot-message {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    color: var(--accent-orange);
    text-shadow: 0 0 20px rgba(255, 149, 0, 0.5);
}

/* Touch Controls (Mobile) */
.touch-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    padding: 0 20px;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 150;
}

.touch-joystick {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.joystick-base {
    width: 120px;
    height: 120px;
    background: rgba(255, 149, 0, 0.2);
    border: 3px solid var(--accent-orange);
    border-radius: 50%;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.joystick-stick {
    width: 50px;
    height: 50px;
    background: var(--accent-orange);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 15px rgba(255, 149, 0, 0.6);
    transition: transform 0.1s ease;
}

.touch-button {
    width: 100px;
    height: 100px;
    background: var(--accent-orange);
    border: 3px solid var(--accent-orange-light);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 149, 0, 0.6);
    transition: var(--transition-smooth);
}

.touch-button:active {
    transform: scale(0.9);
    box-shadow: 0 3px 10px rgba(255, 149, 0, 0.4);
}

.touch-button span {
    font-size: 2.5rem;
}

.joystick-label, .button-label {
    color: var(--accent-orange);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}

/* FPS Counter */
.fps-counter {
    position: absolute;
    top: 90px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--success);
    font-weight: 700;
    border: 1px solid rgba(0, 255, 136, 0.3);
    z-index: 110;
}

#fps-value {
    font-size: 1.2rem;
}

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

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--panel-bg);
    border: 2px solid var(--accent-orange);
    border-radius: 16px;
    padding: 3rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), var(--shadow-glow);
    animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.modal-content h2 {
    color: var(--accent-orange);
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-align: center;
    text-shadow: 0 0 20px rgba(255, 149, 0, 0.5);
}

.instructions {
    color: var(--text-secondary);
    line-height: 1.8;
}

.instructions h3 {
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.instructions li::before {
    content: "▸";
    position: absolute;
    left: 0;
    color: var(--accent-orange);
}

.instructions strong {
    color: var(--text-primary);
}

.points-good {
    color: var(--success);
    font-weight: 700;
}

.points-bad {
    color: var(--danger);
    font-weight: 700;
}

.modal-buttons {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: center;
}

.menu-description {
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.6;
}

/* Final Stats */
.final-stats {
    background: rgba(0, 0, 0, 0.3);
    padding: 2rem;
    border-radius: 12px;
    margin: 2rem 0;
}

.final-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.final-stat:last-child {
    margin-bottom: 0;
}

.final-label {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.final-value {
    color: var(--accent-orange);
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(255, 149, 0, 0.5);
}

/* Animations */
@keyframes spin {
    to { transform: rotate(360deg); }
}

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

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

@keyframes popIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-orange);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-orange-light);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #hud {
        height: 60px;
        padding: 0 1rem;
    }

    .logo {
        font-size: 1.2rem;
    }

    .score-value, .count-value {
        font-size: 1.5rem;
        min-width: 40px;
    }

    .label {
        font-size: 0.75rem;
    }

    .hud-center {
        display: none;
    }

    #controls-panel {
        width: 100%;
        top: 60px;
        max-height: 50vh;
    }

    .touch-controls {
        display: flex;
    }

    .mobile-only {
        display: flex !important;
    }

    .fps-counter {
        top: 70px;
        left: 10px;
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    .modal-content {
        padding: 2rem;
    }

    .modal-content h2 {
        font-size: 2rem;
    }

    .loading-content h1 {
        font-size: 2.5rem;
    }
}

@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #game-canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
