* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #fff;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box, .register-box {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #e94560;
    font-size: 2rem;
    text-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
}

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

input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 15px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: all 0.3s;
}

input:focus {
    border-color: #e94560;
    background: rgba(255, 255, 255, 0.15);
}

input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

button[type="submit"], button[type="button"] {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #e94560 0%, #ff6b6b 100%);
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(233, 69, 96, 0.4);
}

.error {
    color: #ff6b6b;
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
}

.register-link {
    text-align: center;
    margin-top: 20px;
    color: rgba(255, 255, 255, 0.7);
}

.register-link a {
    color: #e94560;
    text-decoration: none;
    font-weight: bold;
}

.register-link a:hover {
    text-decoration: underline;
}

/* Profile styles */
.profile-box {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.profile-header {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.avatar-section {
    flex: 0 0 auto;
}

.avatar-large {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin-bottom: 10px;
}

.avatar-select {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    max-width: 80px;
}

.avatar-btn {
    width: 35px;
    height: 35px;
    padding: 0;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.avatar-btn:hover, .avatar-btn.active {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.2);
}

.username-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
}

#usernameDisplay {
    font-size: 24px;
    font-weight: bold;
    color: #e94560;
}

#usernameInput {
    flex: 1;
}

.stats-section {
    margin-bottom: 30px;
}

.stats-section h2 {
    margin-bottom: 15px;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.8);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #e94560;
}

.stat-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 5px;
}

.score-card {
    background: linear-gradient(135deg, #e94560 0%, #ff6b6b 100%);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    margin-top: 15px;
}

.score-card .stat-value {
    color: #fff;
    font-size: 32px;
}

.play-btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #e94560 0%, #ff6b6b 100%);
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
    margin-bottom: 15px;
}

.play-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(233, 69, 96, 0.4);
}

.logout-link {
    display: block;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
}

.logout-link:hover {
    color: #fff;
}

/* Lobby styles */
.lobby-box {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.back-link {
    color: #e94560;
    text-decoration: none;
    padding: 10px 20px;
    border: 2px solid #e94560;
    border-radius: 10px;
    transition: all 0.3s;
}

.back-link:hover {
    background: #e94560;
    color: #fff;
}

.players-section h2 {
    margin-bottom: 15px;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.8);
}

.players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
}

.player-slot {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.player-slot:hover {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.2);
    transform: scale(1.05);
}

.player-slot .avatar {
    font-size: 40px;
    margin-bottom: 10px;
}

.player-slot .name {
    font-size: 14px;
    word-break: break-word;
}

.player-slot.me {
    border-color: #00ff88;
    background: rgba(0, 255, 136, 0.15);
}

.no-players {
    grid-column: 1 / -1;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    padding: 40px;
}

/* Game styles */
.game-box {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    width: 100%;
    max-width: 800px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.timer-display {
    font-size: 24px;
    color: #00d9ff;
    font-weight: bold;
}

.timer-display.warning {
    color: #ff6b6b;
    animation: pulse 0.5s infinite;
}

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

.exit-btn {
    color: #ff6b6b;
    text-decoration: none;
    padding: 8px 16px;
    border: 2px solid #ff6b6b;
    border-radius: 8px;
    transition: all 0.3s;
}

.exit-btn:hover {
    background: #ff6b6b;
    color: #fff;
}

.letters-display {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}

.letters-bar {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.letter {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
}

.game-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.player-panel {
    flex: 1;
}

.player-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
}

.player-card .player-avatar {
    font-size: 50px;
    margin-bottom: 10px;
}

.player-card .player-name {
    font-size: 16px;
    margin-bottom: 10px;
}

.current-word {
    font-size: 24px;
    font-weight: bold;
    color: #00d9ff;
    min-height: 35px;
    margin-bottom: 10px;
    letter-spacing: 3px;
}

.words-list {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    max-height: 60px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.words-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 10px 0;
    width: 80px;
}

#player1 .words-grid {
    margin-right: 10px;
    align-items: flex-start;
}

#player2 .words-grid {
    margin-left: 10px;
    align-items: flex-end;
}

.word-cell {
    width: 70px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #fff;
    text-transform: uppercase;
}

.word-cell.green {
    background: rgba(46, 204, 113, 0.4);
    border-color: #2ecc71;
}

.word-cell.red {
    background: rgba(231, 76, 60, 0.4);
    border-color: #e74c3c;
}

.score {
    font-size: 18px;
    color: #e94560;
    font-weight: bold;
}

.vs {
    font-size: 24px;
    font-weight: bold;
    color: #e94560;
}

.keyboard-area {
    margin-bottom: 20px;
}

.letter-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.letter-btn {
    width: 45px;
    height: 45px;
    font-size: 20px;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.letter-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.letter-btn.used {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.4);
    cursor: not-allowed;
}

.letter-btn.used:hover {
    transform: none;
    box-shadow: none;
}

.actions-area {
    display: flex;
    gap: 10px;
}

.action-btn {
    flex: 1;
    padding: 15px;
    font-size: 16px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.action-btn.submit {
    background: linear-gradient(135deg, #00d9ff 0%, #00ff88 100%);
}

.action-btn.clear {
    background: rgba(255, 255, 255, 0.2);
}

.action-btn.next {
    background: linear-gradient(135deg, #e94560 0%, #ff6b6b 100%);
}

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

.action-btn:hover:not(:disabled) {
    transform: translateY(-2px);
}

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

.modal.show {
    display: flex;
}

.modal-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #e94560;
}

.modal-content button {
    margin: 10px;
    width: auto;
    padding: 15px 30px;
}

.timer {
    font-size: 48px;
    font-weight: bold;
    color: #00d9ff;
    margin-top: 20px;
}

.result {
    font-size: 24px;
    margin-bottom: 20px;
    color: #00ff88;
}

.final-scores {
    margin-bottom: 20px;
}

.final-scores p {
    font-size: 18px;
    margin: 10px 0;
}

@media (max-width: 600px) {
    .login-box, .profile-box, .lobby-box, .game-box {
        padding: 20px;
    }
    
    .profile-header {
        flex-direction: column;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .game-area {
        flex-direction: column;
    }
    
    .letter-btn {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .actions-area {
        flex-wrap: wrap;
    }
}