/* TypeSniper Game - Style */

/* Game-specific variables */
:root {
    --typesniper-primary: #3498db;
    --typesniper-secondary: #e74c3c;
    --typesniper-accent: #2ecc71;
    --typesniper-bg: rgba(255, 255, 255, 0.5);
    --typesniper-shadow: rgba(0, 0, 0, 0.2);
}

/* Game container styles */
.typesniper-page .game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

.typesniper-page .game-header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.typesniper-page .game-header h1 {
    font-size: 2.5rem;
    color: var(--typesniper-primary);
    margin-bottom: var(--spacing-sm);
}

.typesniper-page .game-controls {
    margin-top: var(--spacing-md);
}

/* Game Layout - Sidebar Structure */
.game-layout {
    display: flex;
    gap: var(--spacing-lg);
    min-height: 600px;
}

/* Sidebar */
.game-sidebar {
    width: 28%;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* Main Game Area */
.game-main {
    flex: 1;
    width: 70%;
}

/* Canvas container */
.canvas-container {
    background-color: var(--background-alt);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: 500px;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: var(--background);
    display: block;
}

/* Controls */
#controls {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    background-color: var(--background-alt);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

/* Sliders container */
.sliders-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    background-color: var(--background-alt);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    flex: 1;
    max-width: 300px;
}

/* Slider controls */
.slider-control {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.slider-control label {
    font-weight: bold;
    margin-right: var(--spacing-xs);
    white-space: nowrap;
    width: 140px;
}

.slider-control input[type="range"] {
    flex: 1;
    accent-color: var(--typesniper-primary);
    height: 5px;
    border-radius: var(--border-radius);
}

#speed-display, #max-length-display {
    font-family: monospace;
    font-weight: bold;
    color: var(--typesniper-primary);
    min-width: 3em;
    text-align: center;
}

/* Timer and score display */
#timer, #score {
    font-family: monospace;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text);
    background-color: var(--background);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
    width: 100%;
    text-align: center;
}

/* Room Controls */
.room-controls {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    background-color: var(--background-alt);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.room-controls input {
    width: 100%;
    padding: var(--spacing-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    box-sizing: border-box;
}

.room-controls button {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
    font-size: 1rem;
}

/* Player List */
.player-list-container {
    background-color: var(--background-alt);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.player-list-container h3 {
    margin-top: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    color: var(--text);
    font-size: 1.2rem;
}

/* Room Code Bar */
.room-code-bar {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm);
    background-color: var(--background);
    border-radius: var(--border-radius);
}

.current-room-code {
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--typesniper-primary);
    text-align: center;
    padding: var(--spacing-sm) 0;
}

.room-code-label {
    color: var(--text-muted);
    font-size: 1rem;
    margin-right: var(--spacing-xs);
}

.room-code-text {
    color: var(--typesniper-primary);
    font-size: 1.3rem;
}

.room-code-bar .btn-sm {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.9rem;
    width: 100%;
}

.player-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
    max-height: 350px;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.player-item:last-child {
    border-bottom: none;
}

.player-item.current-player {
    background-color: rgba(52, 152, 219, 0.1);
    font-weight: bold;
}

.player-color {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: var(--spacing-sm);
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
}

.player-name {
    flex: 1;
}

.player-score {
    font-weight: bold;
    color: var(--typesniper-accent);
    margin-left: var(--spacing-sm);
}

.btn-danger {
    background-color: var(--typesniper-secondary);
    color: white;
    border-color: var(--typesniper-secondary);
}

.btn-danger:hover {
    background-color: #c0392b;
}

/* Score Animation */
.score-animation {
    position: absolute;
    color: var(--typesniper-accent);
    font-weight: bold;
    font-size: 1.5rem;
    pointer-events: none;
    animation: float-up 1s ease-out forwards;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

/* Steal Score Animation - more flashy for stealing words */
.steal-score-animation {
    position: absolute;
    color: var(--typesniper-accent);
    font-weight: bold;
    font-size: 1.5rem;
    pointer-events: none;
    animation: float-up-steal 1.2s ease-out forwards;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
    z-index: 10;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.6); /* Golden glow */
}

@keyframes float-up {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(-50px);
        opacity: 0;
    }
}

@keyframes float-up-steal {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    30% {
        transform: translateY(-15px) scale(1.3);
        opacity: 1;
    }
    100% {
        transform: translateY(-60px) scale(1);
        opacity: 0;
    }
}

/* Word typing and movement animations */
@keyframes word-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes typing-flash {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

@keyframes horizontal-motion {
    0% { text-shadow: -3px 0 3px rgba(0,0,0,0.1); }
    100% { text-shadow: 3px 0 3px rgba(0,0,0,0.1); }
}

@keyframes vertical-motion {
    0% { text-shadow: 0 -3px 3px rgba(0,0,0,0.1); }
    100% { text-shadow: 0 3px 3px rgba(0,0,0,0.1); }
}

@keyframes fast-motion {
    0% { text-shadow: -2px -2px 4px rgba(0,0,0,0.15); }
    25% { text-shadow: 2px -2px 4px rgba(0,0,0,0.15); }
    50% { text-shadow: 2px 2px 4px rgba(0,0,0,0.15); }
    75% { text-shadow: -2px 2px 4px rgba(0,0,0,0.15); }
    100% { text-shadow: -2px -2px 4px rgba(0,0,0,0.15); }
}

/* Word movement patterns */
.word-horizontal {
    animation: horizontal-motion 0.5s alternate infinite ease-in-out;
}

.word-vertical {
    animation: vertical-motion 0.5s alternate infinite ease-in-out;
}

.word-fast {
    animation: fast-motion 0.8s infinite linear;
}

.word-edge {
    filter: drop-shadow(0 0 2px rgba(255,255,255,0.5));
}

/* Word container - for nested borders */
.word-container {
    position: relative;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.word-outline {
    position: absolute;
    border-radius: 4px;
    box-sizing: border-box;
    pointer-events: none;
}

.word-text {
    position: relative;
    padding: 2px 5px;
    white-space: nowrap;
}

.typed-char {
    position: relative;
    z-index: 5;
}

/* Trail effect for fast-moving words */
.word-trail {
    position: absolute;
    pointer-events: none;
    z-index: -1;
    border-radius: 50%;
    background: radial-gradient(
        circle, 
        rgba(255,255,255,0.3) 0%, 
        rgba(255,255,255,0) 70%
    );
}

/* Popup */
.popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.popup-content {
    background-color: var(--background);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    position: relative;
    width: 90%;
    max-width: 500px;
    text-align: center;
}

.close-popup {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.close-popup:hover {
    color: var(--text);
}

.popup h2 {
    color: var(--typesniper-primary);
    margin-bottom: var(--spacing-md);
}

.popup p {
    margin-bottom: var(--spacing-sm);
    font-size: 1.1rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    overflow-y: auto;
}

.modal-content {
    background-color: var(--background);
    margin: 5% auto;
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    position: relative;
    width: 90%;
    max-width: 800px;
}

.close-modal {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.close-modal:hover {
    color: var(--text);
}

/* Responsive styles */
@media (max-width: 768px) {
    .game-layout {
        flex-direction: column;
        min-height: auto;
    }
    
    .game-sidebar {
        width: 100%;
        order: 2; /* Move sidebar below canvas on mobile */
    }
    
    .game-main {
        width: 100%;
        order: 1;
    }
    
    #controls {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
    }
    
    #start-game {
        width: auto;
        flex: 1;
        min-width: 150px;
    }
    
    #timer-container {
        width: auto;
        flex: 1;
    }
    
    .player-list {
        max-height: 200px;
    }
    
    .room-code-bar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: var(--spacing-sm);
    }
    
    .room-code-bar .btn-sm {
        width: auto;
        flex: 0 0 auto;
    }
    
    .canvas-container {
        min-height: 400px;
        height: 400px;
    }
}

@media (max-width: 480px) {
    .typesniper-page .game-header h1 {
        font-size: 2rem;
    }
    
    .canvas-container {
        min-height: 350px;
        height: 350px;
    }
    
    #start-game {
        width: 100%;
    }
    
    #timer-container {
        width: 100%;
    }
    
    #controls {
        flex-direction: column;
    }
    
    .room-code-bar {
        flex-direction: column;
    }
    
    .room-code-bar .btn-sm {
        width: 100%;
    }
}

/* Game Length Buttons */
.game-length-buttons {
    display: flex;
    gap: var(--spacing-xs);
}

.game-length-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius);
    background-color: var(--background);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: bold;
    min-width: 50px;
}

.game-length-btn:hover:not(:disabled) {
    background-color: var(--background-dark);
}

.game-length-btn.active {
    background-color: var(--typesniper-primary);
    color: white;
    border-color: var(--typesniper-primary);
}

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

/* Leader Crown */
.leader-crown {
    font-size: 1rem;
    margin-left: var(--spacing-xs);
    display: inline-block;
    vertical-align: middle;
}

/* Podium Popup */
#podium-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#podium-popup .popup-content {
    background-color: var(--background);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: popup-slide-in 0.3s ease-out;
}

#podium-popup h2 {
    text-align: center;
    margin-bottom: var(--spacing-md);
    color: var(--typesniper-primary);
}

/* Podium Display */
.podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    margin: var(--spacing-lg) 0;
    height: 250px;
    position: relative;
    gap: var(--spacing-sm);
}

.podium-place {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-md);
    background-color: var(--background-alt);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    min-width: 100px;
    border: 1px solid var(--border-color);
    border-bottom: none;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.podium-place.current-player {
    background-color: rgba(52, 152, 219, 0.1);
}

.podium-place::before {
    content: "";
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    font-weight: bold;
}

.place-1 {
    height: 200px;
    z-index: 3;
    border-color: gold;
    order: 2; /* Place in the middle */
}

.place-1::before {
    content: "🥇";
}

.place-2 {
    height: 170px;
    z-index: 2;
    border-color: silver;
    order: 1; /* Place on the left */
}

.place-2::before {
    content: "🥈";
}

.place-3 {
    height: 140px;
    z-index: 1;
    border-color: #cd7f32; /* bronze */
    order: 3; /* Place on the right */
}

.place-3::before {
    content: "🥉";
}

.podium-place .player-name {
    font-weight: bold;
    text-align: center;
    margin-top: var(--spacing-xs);
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 var(--spacing-xs);
}

.podium-place .player-score {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--typesniper-accent);
    margin-top: auto;
}

.color-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-top: var(--spacing-sm);
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
}

/* All Players List */
.all-players-list {
    margin-top: var(--spacing-lg);
    background-color: var(--background-alt);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
}

.all-players-list h3 {
    text-align: center;
    margin-bottom: var(--spacing-md);
}

.players-table {
    width: 100%;
    border-collapse: collapse;
}

.players-table th,
.players-table td {
    padding: var(--spacing-sm);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.players-table th {
    font-weight: bold;
    color: var(--text);
    background-color: var(--background);
}

.players-table tr.current-player {
    background-color: rgba(52, 152, 219, 0.1);
}

.player-name-cell {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: var(--spacing-xs);
}

/* Popup Buttons */
.popup-buttons {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.popup-buttons button {
    padding: var(--spacing-sm) var(--spacing-md);
    min-width: 120px;
}

#start-game {
    width: 100%;
    height: auto;
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1.2rem;
}

#timer-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 40px;
}

/* Play Again Quick Button */
#play-again-quick {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: 1rem;
    font-weight: bold;
    background-color: var(--typesniper-accent);
    border-color: var(--typesniper-accent);
    color: white;
    transition: all 0.3s ease;
}

#play-again-quick:hover {
    background-color: #27ae60;
    border-color: #27ae60;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

@keyframes popup-slide-in {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Settings Modal */
#settingsModal .modal-content {
    max-width: 500px;
}
