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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 10px;
    margin: 0;
    min-height: 100vh;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

@media (max-width: 768px) {
    body {
        padding: 5px;
        font-size: 14px;
    }
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), 0 10px 20px rgba(0, 0, 0, 0.05);
    min-height: calc(100vh - 20px);
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
        border-radius: 5px;
        min-height: calc(100vh - 10px);
    }
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #2c3e50;
    font-size: 28px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: -0.5px;
}

@media (max-width: 768px) {
    h1 {
        font-size: 20px;
        margin-bottom: 15px;
    }
}

.main-menu {
    text-align: center;
    margin-bottom: 30px;
}

.player-name-section {
    margin-bottom: 20px;
}

.menu-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .menu-buttons {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
}

.join-game {
    text-align: center;
    margin-bottom: 30px;
}

.join-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

@media (max-width: 768px) {
    .join-form {
        gap: 10px;
    }
}

.game-lobby {
    text-align: center;
    margin-bottom: 30px;
}

.lobby-info {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}

@media (max-width: 768px) {
    .lobby-info {
        padding: 15px;
    }
}

.lobby-info p {
    margin: 10px 0;
    font-size: 16px;
}

#playersList {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

#playersList li {
    padding: 5px;
    background-color: #e8f5e8;
    margin: 5px 0;
    border-radius: 4px;
}

.waiting-message {
    background: linear-gradient(135deg, #fef7cd 0%, #fff3cd 100%);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 12px;
    padding: 18px 20px;
    margin: 18px 0;
    color: #8a6914;
    box-shadow: 0 4px 8px rgba(255, 193, 7, 0.1);
    backdrop-filter: blur(5px);
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.word-setup {
    text-align: center;
    margin-bottom: 30px;
}

.setup-form {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}

@media (max-width: 768px) {
    .setup-form {
        padding: 15px;
    }
}

.setup-form p {
    margin-bottom: 15px;
    color: #555;
}

.game-info {
    margin-bottom: 20px;
}

.players-info {
    display: flex;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    padding: 16px 24px;
    border-radius: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
}

@media (max-width: 768px) {
    .players-info {
        flex-direction: column;
        text-align: center;
        padding: 10px;
    }
    
    .players-info span {
        margin: 2px 0;
    }
}

.connection-status {
    position: fixed;
    top: 15px;
    right: 15px;
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(244, 67, 54, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 150px;
    text-align: center;
}

@media (max-width: 768px) {
    .connection-status {
        top: 5px;
        right: 5px;
        font-size: 10px;
        padding: 4px 8px;
    }
}

.connection-status.connected {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
}

/* Additional mobile-specific styles */
@media (max-width: 480px) {
    .container {
        padding: 10px;
        margin: 5px;
    }
    
    h1 {
        font-size: 18px;
    }
    
    .game-board {
        gap: 10px;
    }
    
    .guess-section {
        margin-bottom: 20px;
    }
    
    .guess-section input {
        margin-bottom: 10px;
    }
}

/* Improve touch targets */
.guess-row {
    min-height: 44px;
}

/* Game code styling */
#gameCodeDisplay {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
    letter-spacing: 3px;
    background: rgba(102, 126, 234, 0.1);
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid rgba(102, 126, 234, 0.2);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@media (max-width: 768px) {
    #gameCodeDisplay {
        font-size: 18px;
        letter-spacing: 1px;
    }
}

/* Status messages */
.status {
    display: block;
    margin-top: 5px;
    font-size: 14px;
}

@media (max-width: 768px) {
    .status {
        font-size: 12px;
    }
}

/* Prevent zoom on input focus for iOS */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    select:focus,
    textarea:focus,
    input:focus {
        font-size: 16px;
    }
}

/* Improve game status visibility on mobile */
.game-status p {
    font-size: 18px;
    font-weight: bold;
}

@media (max-width: 768px) {
    .game-status p {
        font-size: 16px;
    }
}

/* Better spacing for waiting messages */
.waiting-message {
    margin: 10px 0;
    padding: 12px;
}

@media (max-width: 768px) {
    .waiting-message {
        padding: 10px;
        font-size: 14px;
    }
}

input[type="text"] {
    padding: 16px 20px;
    font-size: 18px;
    text-align: center;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    width: 200px;
    margin: 8px;
    box-sizing: border-box;
    min-height: 44px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    font-weight: 600;
    letter-spacing: 1px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
    word-wrap: break-word;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 768px) {
    input[type="text"] {
        width: 100%;
        max-width: 200px;
        font-size: 16px;
        padding: 15px;
        margin: 5px 0;
    }
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1), 0 8px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

button {
    padding: 16px 28px;
    font-size: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    margin: 10px;
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

@media (max-width: 768px) {
    button {
        padding: 15px 25px;
        font-size: 16px;
        margin: 8px 5px;
        width: 100%;
        max-width: 200px;
    }
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

button:disabled {
    background: linear-gradient(135deg, #bdc3c7 0%, #95a5a6 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.status {
    margin-left: 10px;
    font-weight: bold;
}

.status.valid {
    color: #4CAF50;
}

.status.invalid {
    color: #f44336;
}

.current-player {
    text-align: center;
    margin-bottom: 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    padding: 16px;
    border-radius: 12px;
    border: 2px solid rgba(102, 126, 234, 0.2);
}

.guess-section {
    text-align: center;
    margin-bottom: 30px;
}

.game-board {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .game-board {
        flex-direction: column;
        gap: 15px;
    }
}

.player-board {
    flex: 1;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .player-board {
        padding: 10px;
    }
}

.player-board h3 {
    text-align: center;
    margin-bottom: 15px;
    color: #555;
}

.guesses-container {
    min-height: 200px;
    overflow-y: auto;
    max-height: 300px;
}

@media (max-width: 768px) {
    .guesses-container {
        min-height: 150px;
        max-height: 200px;
    }
}

.guess-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(5px);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

@media (max-width: 768px) {
    .guess-row {
        padding: 6px;
        margin-bottom: 6px;
    }
}

.guess-word {
    font-weight: 700;
    font-size: 18px;
    margin-right: 16px;
    width: 70px;
    flex-shrink: 0;
    color: #2c3e50;
    letter-spacing: 1px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: center;
}

@media (max-width: 768px) {
    .guess-word {
        font-size: 16px;
        width: 50px;
        margin-right: 10px;
    }
}

.feedback {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .feedback {
        gap: 2px;
    }
}

.letter {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 16px;
    margin: 2px;
    transition: all 0.2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    .letter {
        width: 22px;
        height: 22px;
        font-size: 12px;
    }
}

.correct {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

.present {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    box-shadow: 0 2px 4px rgba(255, 152, 0, 0.3);
}

.absent {
    background: linear-gradient(135deg, #666 0%, #555 100%);
    box-shadow: 0 2px 4px rgba(102, 102, 102, 0.3);
}

.game-status {
    text-align: center;
    margin: 20px 0;
}

.game-status p {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    padding: 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin: 0;
}

.winner {
    color: #4CAF50;
    font-size: 24px;
}

/* Enhanced text handling and modern improvements */
.setup-form p,
.lobby-info p,
.waiting-message p {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    line-height: 1.5;
}

/* Add hover effects for interactive elements */
.player-board:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.guess-row:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

/* Add subtle animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.main-menu,
.join-game,
.game-lobby,
.word-setup,
.game-play {
    animation: fadeIn 0.5s ease-out;
}

/* Improve status messages */
.status {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 14px;
    margin-left: 8px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.status.valid {
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.status.invalid {
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
}

/* Better text inputs for long content */
input[type="text"] {
    resize: none;
}

input[type="text"]::placeholder {
    color: rgba(0, 0, 0, 0.4);
    font-weight: 400;
}

/* Improve game status text */
.game-status p {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
}

/* Enhanced mobile keyboard support */
@media (max-width: 768px) {
    input[type="text"] {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }
}

/* Race indicator styling */
.race-indicator {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    display: inline-block;
    margin: 8px 0;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

/* Guess counter styling */
.guess-counter {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    color: #2c3e50;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.player-board {
    position: relative;
}