* {
    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%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== LANDING PAGE ===== */
.landing-container {
    width: 100%;
    max-width: 900px;
    padding: 20px;
}

.landing-content {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    padding: 50px 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.logo-container {
    text-align: center;
    margin-bottom: 10px;
}

.game-title {
    font-size: 3rem;
    text-align: center;
    color: #FF6B7A;
    margin-bottom: 5px;
    font-weight: 900;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-title-korean {
    font-size: 1.5rem;
    text-align: center;
    color: #FF6B7A;
    margin: 0;
    font-weight: 700;
    letter-spacing: 3px;
}

.game-subtitle {
    text-align: center;
    color: #666;
    font-size: 1.2rem;
    margin-bottom: 20px;
}

/* Players Online Counter */
.players-online {
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 25px;
    border-radius: 25px;
    display: inline-block;
    margin: 0 auto 30px;
    font-size: 1.1rem;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    animation: pulse-glow 2s infinite;
}

.online-indicator {
    display: inline-block;
    margin-right: 8px;
    animation: pulse 2s infinite;
}

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

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3); }
    50% { box-shadow: 0 4px 25px rgba(102, 126, 234, 0.5); }
}

/* ===== GAME SCREEN ===== */
.game-container {
    width: 100%;
    max-width: 1000px;
    min-height: 100vh;
    padding: 20px;
}

.game-screen {
    background: #5a7cc2;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.game-header h1 {
    color: white;
    text-align: center;
    margin-bottom: 30px;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-logo {
    text-align: center;
}

.game-logo h1 {
    color: #FF6B7A;
    font-size: 2.5rem;
    margin-bottom: 5px;
    font-weight: 900;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.logo-korean {
    color: #FF6B7A;
    font-size: 1.2rem;
    margin: 0;
    font-weight: 700;
    letter-spacing: 2px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.game-progress {
    margin: 15px 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.turn-counter {
    display: flex;
    justify-content: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.turn-numbers {
    font-size: 20px;
    color: #FFD700;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    transition: width 0.5s ease;
}

/* Opponent Section */
.opponent-section {
    background: linear-gradient(135deg, #4a9fd8 0%, #5bb4e5 100%);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.brain-icon {
    font-size: 1.8rem;
}

.player-name {
    color: white;
    font-size: 1.4rem;
    font-weight: bold;
}

.opponent-word-display .label {
    color: white;
    font-size: 1.2rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.word-tiles {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* --- Tile visual feedback --- */

.tile {
    transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}

/* slight lift on hover (desktop only) */
@media (hover: hover) {
  .tile:hover {
      transform: translateY(-2px);
  }
}

/* when selected in rack */
.tile.selected {
    transform: translateY(-3px) scale(1.08);
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.7),
        0 6px 12px rgba(0, 0, 0, 0.4);
}

/* tiles inside the word-builder pop in */
.word-tile {
    animation: wordTilePop 0.18s ease-out;
}

@keyframes wordTilePop {
    0% {
        transform: scale(0.7);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- Swap animation: quick shuffle of all tiles --- */

.letter-tiles.swap-anim .tile {
    animation: swapShuffle 0.25s ease-in-out;
}

@keyframes swapShuffle {
    0%   { transform: translateY(0); }
    25%  { transform: translateY(-3px) rotate(-1deg); }
    50%  { transform: translateY(3px) rotate(1deg); }
    100% { transform: translateY(0); }
}

/* --- Power-up floating effect (e.g. +1 tile) --- */

.powerup-fx {
    position: fixed;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 22px;
    font-weight: 700;
    color: #ffe082;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
}

.powerup-fx.show {
    animation: powerupRise 0.6s ease-out;
}

@keyframes powerupRise {
    0% {
        transform: translate(-50%, 8px);
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -22px);
        opacity: 0;
    }
}

/* --- AI thinking glow on the turn indicator --- */

.turn-indicator.ai-thinking {
    box-shadow: 0 0 0 0 rgba(144, 202, 249, 0.8);
    animation: aiPulse 1.4s ease-in-out infinite;
}

@keyframes aiPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(144, 202, 249, 0.9);
    }
    70% {
        box-shadow: 0 0 0 14px rgba(144, 202, 249, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(144, 202, 249, 0);
    }
}


.tile {
    background: #ffa726;
    color: #1a237e;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border: 3px solid #ff9800;
}

/* Turn Indicator */
.turn-indicator {
    background: linear-gradient(135deg, #2e7d32 0%, #43a047 100%);
    color: #fff200;
    text-align: center;
    padding: 20px;
    border-radius: 15px;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    animation: pulse 2s infinite;
}

.turn-indicator.opponent-turn {
    background: linear-gradient(135deg, #d32f2f 0%, #f44336 100%);
    color: white;
    animation: none;
}

.turn-indicator.your-turn {
    background: linear-gradient(135deg, #2e7d32 0%, #43a047 100%);
    color: #fff200;
}

/* Player Section */
.player-section {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 25px;
}

.letter-tiles {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.letter-tile {
    background: #ffa726;
    color: #1a237e;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    border: 4px solid #ff9800;
    user-select: none;
}

.letter-tile:hover:not(.locked):not(.selected) {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.letter-tile.selected {
    background: #fff59d;
    border-color: #ffd700;
    transform: scale(0.95);
}

.letter-tile.locked {
    background: #bdbdbd;
    color: #757575;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Word Builder */
.word-builder {
    min-height: 80px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    padding: 15px;
    margin-bottom: 15px;
    border: 3px dashed rgba(255, 255, 255, 0.5);
}

.word-builder.empty::before {
    content: "Click letters to build your word";
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.1rem;
}

.word-builder .tile {
    cursor: pointer;
}

.word-builder .tile:hover {
    opacity: 0.8;
}

.empty-message {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.1rem;
}

/* Current Word Display */
.current-word-display {
    background: rgba(255, 255, 255, 0.95);
    color: #1a237e;
    text-align: center;
    padding: 20px;
    border-radius: 10px;
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 20px;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.current-word-display.empty {
    color: #999;
    font-size: 1.2rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.action-btn {
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

#clearBtn {
    background: #757575;
    color: white;
}

#clearBtn:hover {
    background: #616161;
}

.action-btn.secondary {
    background: #ff9800;
    color: white;
}

.action-btn.secondary:hover {
    background: #f57c00;
}

.action-btn.primary {
    background: linear-gradient(135deg, #2e7d32 0%, #43a047 100%);
    color: white;
    font-size: 1.3rem;
}

.action-btn.primary:hover {
    background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 100%);
}

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

/* Power-ups */
.power-ups {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.power-up-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.power-up-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.power-up-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.power-icon {
    font-size: 1.3rem;
}

.power-count {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.9rem;
}

.practice-badge {
    margin-top: 4px;
    font-size: 0.9rem;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.15);
    color: #fdfdfd;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.practice-badge-label {
    opacity: 0.8;
    font-weight: 500;
}

.practice-badge-value {
    font-weight: 600;
}


/* Scoreboard */
.scoreboard {
    background: #2d5016;
    border-radius: 15px;
    padding: 20px;
    margin-top: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.score-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    font-size: 1.2rem;
    padding: 10px 0;
    font-weight: 600;
}

.score-item:first-child {
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 15px;
    margin-bottom: 10px;
}

.dots {
    flex-grow: 1;
    margin: 0 15px;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.3);
}

.score {
    color: #fff;
    font-weight: bold;
}

.round-score {
    color: #76ff03;
    margin-left: 10px;
    font-size: 1rem;
}

/* Waiting Screen */
.waiting-screen {
    text-align: center;
    padding: 100px 50px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.waiting-screen h1 {
    color: #4c5fd7;
    margin-bottom: 30px;
    font-size: 2.5rem;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(102, 126, 234, 0.3);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 30px;
}

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

.waiting-screen p {
    color: #666;
    font-size: 1.2rem;
}

/* Game Over Screen */
.game-over-screen {
    text-align: center;
    padding: 100px 50px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.game-over-content h1 {
    font-size: 3rem;
    margin-bottom: 20px;
}

#gameOverMessage {
    font-size: 1.3rem;
    color: #666;
    margin-bottom: 40px;
}

.final-scores {
    display: flex;
    justify-content: center;
    gap: 50px;
    margin-bottom: 40px;
}

.final-score {
    text-align: center;
}

.final-score span:first-child {
    display: block;
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 10px;
}

.final-score-value {
    display: block;
    font-size: 3rem;
    font-weight: bold;
    color: #4c5fd7;
}

.play-again-btn, .home-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin: 0 10px;
    transition: all 0.3s;
}

.play-again-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.play-again-btn:hover {
    transform: scale(1.05);
}

.home-btn {
    background: #e0e0e0;
    color: #333;
}

.home-btn:hover {
    background: #d0d0d0;
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    background: #d32f2f;
}

.toast.success {
    background: #2e7d32;
}


/* Exit button (top-left) */
.exit-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.35);
    padding: 8px 16px;
    border-radius: 10px;
    backdrop-filter: blur(6px);
    font-size: 1rem;
    cursor: pointer;
    transition: 0.25s;
    z-index: 1100;
}

.exit-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Exit modal buttons layout */
.exit-modal-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

/* Red "Exit game" button */
.close-modal-btn.danger {
    background: #d32f2f;
}

.close-modal-btn.danger:hover {
    background: #b71c1c;
}

/* Optional: smaller exit button on mobile */
@media (max-width: 600px) {
    .exit-btn {
        padding: 6px 12px;
        font-size: 0.9rem;
        top: 12px;
        left: 12px;
    }
}


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

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 500px;
    text-align: center;
}

.modal-content h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

#hintWords {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.hint-word {
    background: #f0f0f0;
    padding: 15px;
    border-radius: 10px;
    font-size: 1.3rem;
    font-weight: bold;
    color: #4c5fd7;
}

.close-modal-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 10px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.close-modal-btn:hover {
    background: #764ba2;
}

/* Quick Reactions */
.quick-reactions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 15px 0;
}

.reaction-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.reaction-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.reaction-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.reaction-notification {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1.5rem;
    z-index: 2000;
    animation: slideDown 0.3s ease, slideUp 0.3s ease 2.7s;
    pointer-events: none;
}

@keyframes slideDown {
    from {
        top: 50px;
        opacity: 0;
    }
    to {
        top: 100px;
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        top: 100px;
        opacity: 1;
    }
    to {
        top: 50px;
        opacity: 0;
    }
}

/* Stats Display */
.stats-display {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px;
    margin: 15px 0;
    text-align: center;
}

.stats-title {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    ccolor: #5a6c7d; /* Darker gray for labels */
}

.win-rate {
    color: #76ff03;
}

/* Bilingual Text Styles */
.bilingual-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.primary-text {
    font-size: inherit;
    font-weight: 600;
    line-height: 1.2;
}

.secondary-text {
    font-size: 0.75em;
    opacity: 0.7;
    font-weight: 400;
    line-height: 1.2;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-container {
        padding: 10px;
    }
    
    .game-screen {
        padding: 15px;
    }

    .game-title {
        font-size: 2rem;
    }

    .letter-tile {
        width: 50px;
        height: 50px;
        font-size: 1.8rem;
    }

    .tile {
        width: 50px;
        height: 50px;
        font-size: 1.6rem;
    }

    .action-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .action-btn {
        flex: 1;
        min-width: calc(33.333% - 6px);
        padding: 12px 15px;
        font-size: 0.95rem;
    }
    
    .action-btn.primary {
        font-size: 1.1rem;
    }

    .power-ups {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .power-up-btn {
        flex: 1;
        min-width: calc(33.333% - 6px);
        padding: 10px 8px;
        font-size: 0.85rem;
        justify-content: center;
    }
    
    .power-icon {
        font-size: 1.1rem;
    }
    
    .power-count {
        font-size: 0.8rem;
        padding: 2px 6px;
    }

    .final-scores {
        flex-direction: column;
        gap: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .stat-value {
        font-size: 1.4rem;
    }
    
    .current-word-display {
        font-size: 1.6rem;
        padding: 15px;
        min-height: 60px;
    }
    
    .word-builder {
        min-height: 70px;
        padding: 10px;
    }
    
    .opponent-section {
        padding: 15px;
    }
    
    .turn-indicator {
        font-size: 1.2rem;
        padding: 15px;
    }
}