/* --- 1. PAGE CONFIGURATION --- */
body {
    margin: 0; padding: 0;
    width: 100vw; height: 100vh;
    background-color: #121212;
    overflow: hidden;
    display: flex; justify-content: center; align-items: center;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* Disable default mobile behavior for smooth dragging */
    touch-action: none; 
    -webkit-user-select: none; user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* --- 2. AUTO-ROTATE CONTAINER (FIXED) --- */
#game-container {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    display: flex; justify-content: center; align-items: center;
    background: #1a1a1a;
    border-radius: 15px;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    padding: 40px; /* Margin on all 4 sides of table */
}

/* Rotation logic: Portrait rotates 90 degrees */
@media screen and (orientation: portrait) {
    #game-container {
        width: calc(100vh - 80px); height: calc(100vw - 80px);
        transform: translate(-50%, -50%) rotate(90deg);
    }
}
/* Landscape stays normal */
@media screen and (orientation: landscape) {
    #game-container {
        width: calc(100vw - 80px); height: calc(100vh - 80px);
        transform: translate(-50%, -50%) rotate(0deg);
    }
}

svg { width: 100%; height: 100%; display: block; }

/* --- 3. UI ELEMENTS --- */
.score-text {
    font-size: 80px; fill: rgba(255, 255, 255, 0.9);
    font-weight: bold; pointer-events: none;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}
.msg-text {
    font-size: 35px; fill: rgba(255, 255, 255, 0.8);
    pointer-events: none;
}

/* Aiming and Power Assist */
#aim-line { 
    stroke: rgba(255, 255, 255, 0.8); 
    stroke-width: 4; 
    stroke-dasharray: 15, 10; 
    visibility: hidden; 
    pointer-events: none; 
}
#power-indicator { 
    fill: none; 
    stroke: #ff9800; 
    stroke-width: 4; 
    visibility: hidden; 
    opacity: 0.7; 
    pointer-events: none; 
    transition: stroke-width 0.1s;
}

/* Power Bar */
#power-bar-container {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    width: 60%; max-width: 500px; height: 15px;
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px; overflow: hidden; visibility: hidden; z-index: 100; pointer-events: none;
}
#power-bar-fill {
    width: 0%; height: 100%;
    /* Gradient from Green -> Yellow -> Red */
    background: linear-gradient(90deg, #4CAF50, #FFEB3B, #F44336); 
    transition: width 0.05s linear;
}

/* --- 4. CUE POSITIONING OVERLAY (First-person view) --- */
#cue-positioning-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    visibility: hidden;
    pointer-events: auto;
}

#cue-ball-large-container {
    position: relative;
    width: 300px;
    height: 300px;
}

#cue-ball-large {
    width: 100%;
    height: 100%;
}

#cue-dot {
    transition: transform 0.1s ease-out;
}

#cue-dot:active {
    transform: scale(1.2);
}

.cue-done-btn {
    margin-top: 30px;
    padding: 15px 40px;
    font-size: 24px;
    font-weight: bold;
    color: white;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
    transition: all 0.3s ease;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.cue-done-btn:hover {
    background: linear-gradient(135deg, #45a049, #4CAF50);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.6);
    transform: translateY(-2px);
}

.cue-done-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(76, 175, 80, 0.4);
}

/* --- 5. GAME OVER OVERLAY --- */
#game-over-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    visibility: hidden;
}

#game-over-content {
    text-align: center;
    color: white;
    padding: 40px;
    background: linear-gradient(135deg, #1a1a1a, #2d2d2d);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    min-width: 300px;
}

#game-over-title {
    font-size: 48px;
    margin: 0 0 20px 0;
    color: #ff5252;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

#game-over-message {
    font-size: 24px;
    margin: 0 0 15px 0;
    color: rgba(255, 255, 255, 0.8);
}

.final-score {
    font-size: 72px;
    font-weight: bold;
    color: #69f0ae;
    margin: 20px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.restart-btn {
    margin-top: 30px;
    padding: 15px 40px;
    font-size: 24px;
    font-weight: bold;
    color: white;
    background: linear-gradient(135deg, #2196F3, #1976D2);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.4);
    transition: all 0.3s ease;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.restart-btn:hover {
    background: linear-gradient(135deg, #1976D2, #2196F3);
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.6);
    transform: translateY(-2px);
}

.restart-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(33, 150, 243, 0.4);
}
