/* ===== CSS Variables & Base Styles ===== */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252545;
    --accent-primary: #7c3aed;
    --accent-secondary: #a855f7;
    --accent-glow: rgba(124, 58, 237, 0.5);
    --text-primary: #ffffff;
    --text-secondary: #a0a0c0;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --gem-color: #06b6d4;
    --double-letter: #3b82f6;
    --triple-letter: #8b5cf6;
    --double-word: #f97316;
    --tile-bg: linear-gradient(145deg, #2a2a4a, #1f1f3a);
    --tile-selected: linear-gradient(145deg, #5b21b6, #4c1d95);
    --tile-hover: linear-gradient(145deg, #3a3a5a, #2f2f4a);
    --border-radius: 16px;
    --border-radius-sm: 10px;
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 15px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--accent-glow);
}

/* ===== Light Theme ===== */
[data-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8eaef;
    --accent-primary: #7c3aed;
    --accent-secondary: #a855f7;
    --accent-glow: rgba(124, 58, 237, 0.25);
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --success: #059669;
    --warning: #d97706;
    --error: #dc2626;
    --gem-color: #0891b2;
    --double-letter: #2563eb;
    --triple-letter: #7c3aed;
    --double-word: #ea580c;
    --tile-bg: linear-gradient(145deg, #ffffff, #eef0f4);
    --tile-selected: linear-gradient(145deg, #c4b5fd, #a78bfa);
    --tile-hover: linear-gradient(145deg, #f3f0ff, #ede9fe);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px var(--accent-glow);
}

[data-theme="light"] body {
    background-image:
        radial-gradient(ellipse at 20% 20%, rgba(124, 58, 237, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
}

[data-theme="light"] .game-panel-left,
[data-theme="light"] .game-panel-center,
[data-theme="light"] .panel-section,
[data-theme="light"] .game-header,
[data-theme="light"] .menu-section,
[data-theme="light"] .setting-row,
[data-theme="light"] .join-form,
[data-theme="light"] .available-lobbies,
[data-theme="light"] .room-code-display,
[data-theme="light"] .room-player-card,
[data-theme="light"] .word-display,
[data-theme="light"] .modal-content,
[data-theme="light"] .letter-picker-content,
[data-theme="light"] .toast,
[data-theme="light"] .legend {
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .menu-btn {
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .menu-input {
    border-color: rgba(0, 0, 0, 0.12);
    background: var(--bg-tertiary);
}

[data-theme="light"] .tile {
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
}

[data-theme="light"] .tile.selected {
    color: #ffffff;
    border-color: var(--accent-primary);
}

[data-theme="light"] .tile-points {
    color: rgba(0, 0, 0, 0.55);
    background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .icon-btn {
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .icon-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .clear-btn {
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .player-card {
    border-color: transparent;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .player-card.active {
    background: linear-gradient(145deg, rgba(124, 58, 237, 0.08), var(--bg-secondary));
}

[data-theme="light"] .stepper-btn {
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .lang-btn {
    border-color: rgba(0, 0, 0, 0.1);
    background: var(--bg-secondary);
}

[data-theme="light"] .modal {
    background: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .letter-picker-overlay {
    background: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .letter-grid button {
    color: var(--text-primary);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .swap-indicator {
    color: #ffffff;
}

[data-theme="light"] .lobby-list-card {
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .leave-game-btn:hover {
    background: rgba(220, 38, 38, 0.1) !important;
}

/* ===== Theme Toggle Button (Fixed Top-Right) ===== */
.theme-toggle-fixed {
    position: fixed;
    top: 14px;
    right: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    z-index: 999;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(12px);
    transition: all 0.2s ease;
}

[data-theme="light"] .theme-toggle-fixed {
    border-color: rgba(0, 0, 0, 0.08);
}

.theme-toggle-option {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.25s ease;
    padding: 0;
    line-height: 1;
    color: var(--text-secondary);
}

.theme-toggle-option:hover {
    background: rgba(124, 58, 237, 0.15);
}

.theme-toggle-option.active {
    background: var(--accent-primary);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
}

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

/* Prevent flex children overflow */
*,
*::before,
*::after {
    min-width: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 20%, rgba(124, 58, 237, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(6, 182, 212, 0.1) 0%, transparent 50%);
    height: 100vh;
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

/* ===== Game Screen Three-Panel Layout ===== */
.game-screen-wrapper {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 12px 24px;
    gap: 12px;
    overflow: hidden;
}

.game-panels {
    display: flex;
    gap: 0;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.game-panel-left {
    border: 1px solid rgba(255, 255, 255, 0.05); 
    border-radius: 10px;
    padding: 10px;
    background-color: var(--bg-secondary);
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    overflow: hidden;
    margin-right: 2rem;
}

.game-panel-center {
    /* Square container: size = available height */
    height: 100%;
    aspect-ratio: 1;
    flex-shrink: 0;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: var(--shadow-lg);
    padding: 16px;
    overflow: hidden;
    margin-right: 2rem;
}

.game-panel-center .game-board {
    width: 100%;
    height: 100%;
}

.game-panel-right {

    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
    margin-left: auto;
}

.panel-section {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.powerups-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.powerups-vertical .powerup-btn {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 12px 14px;
    width: 100%;
}

.powerups-vertical .powerup-icon { font-size: 18px; flex-shrink: 0; }
.powerups-vertical .powerup-name { font-size: 13px; flex: 1; text-align: left; }
.powerups-vertical .powerup-cost { font-size: 11px; flex-shrink: 0; }

.legend-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item-h {
    display: flex;
    align-items: center;
    gap: 12px;
}

.legend-item-h span {
    font-size: 12px;
    color: var(--text-secondary);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Header ===== */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;                 /* taşmayı engeller */
    padding: 15px 20px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}

.logo-icon {
    font-size: 28px;
    animation: sparkle 2s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(10deg); }
}

.logo h1 {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-secondary), var(--gem-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    display: flex;
    align-items: center;
}

/* Stats area */
.stats-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex: 1 1 auto;                  /* header içinde esnesin */
    flex-wrap: wrap;                 /* küçükte alt satıra geçsin */
}

.stat {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 14px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    white-space: nowrap;             /* içerik dağılmasın */
}

.stat-icon {
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.stat-value {
    line-height: 1;
}

.gems .stat-value { color: var(--gem-color); }
.score .stat-value { color: var(--warning); }

.high-score-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

#high-score {
    color: var(--text-primary);
    font-weight: 700;
}

.icon-btn {
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;                  /* sabit kalsın */
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.leave-game-btn:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: var(--error) !important;
}

/* ===== Word Display ===== */
.word-display {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    padding: 10px 16px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.current-word-container {
    width: 100%;
    display: flex;
    font-size: 1rem;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
    text-align:center;
}

.current-word {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    line-height: 1;
    max-width: 100%;
    white-space: nowrap;
}

.current-word.has-word {
    color: var(--text-primary);
    text-shadow: 0 0 25px var(--accent-glow);
}

/* Score sağda; küçük ekranda taşmayı engellemek için genişlik sınırı */
.word-score {
    margin: 3px;
    font-size: 20px;
    font-weight: 700;
    color: var(--warning);
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 40%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.word-score.visible { opacity: 1; }

.word-validation {
    font-size: 14px;
    font-weight: 500;
    display: flex; 
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
}

.word-validation.valid { color: var(--success); }
.word-validation.invalid { color: var(--error); }

/* ===== Game Board ===== */
.game-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 8px;
    width: 100%;
    height: 100%;
}

/* ===== Tiles ===== */
.tile {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--tile-bg);
    border-radius: var(--border-radius-sm);
    font-size: clamp(32px, 5vh, 64px);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    border: 2px solid transparent;
    position: relative;
    user-select: none;
    overflow: visible;
    width: 100%;
    height: 100%;
}

.tile:hover:not(.selected):not(.disabled) {
    background: var(--tile-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.tile.selected {
    background: var(--tile-selected);
    border-color: var(--accent-secondary);
    box-shadow: var(--shadow-glow);
    transform: scale(1.05);
    z-index: 1;
}

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

.tile.adjacent-hint {
    border-color: rgba(124, 58, 237, 0.5);
}

.tile.swap-selected, .tile.change-selected {
    background: linear-gradient(145deg, #0891b2, #0e7490);
    border-color: var(--gem-color);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.6);
    transform: scale(1.05);
    z-index: 1;
}

.tile.opponent-selected {
    border-color: #22d3ee;
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.5);
    animation: opponentPulse 1s ease-in-out infinite;
}

@keyframes opponentPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(34, 211, 238, 0.4); }
    50% { box-shadow: 0 0 18px rgba(34, 211, 238, 0.7); }
}

.turn-timer {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    font-size: 0.85em;
    font-weight: 600;
}

.turn-timer.urgent {
    background: rgba(239, 68, 68, 0.25);
    color: var(--error);
    animation: timerBlink 0.5s ease-in-out infinite;
}

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

.tile-letter {
    line-height: 1;
    z-index: 1;
}

.tile-points {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,0.7);
    position: absolute;
    bottom: 3px;
    right: 4px;
    line-height: 1;
    background: rgba(0,0,0,0.35);
    border-radius: 4px;
    padding: 1px 4px;
    z-index: 2;
}

/* Bonus Tiles */
.tile.double-letter {
    background: linear-gradient(145deg, rgba(59, 130, 246, 0.3), rgba(59, 130, 246, 0.1));
    border-color: var(--double-letter);
}

.tile.double-letter::before {
    content: '2x';
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 9px;
    font-weight: 700;
    color: var(--double-letter);
    line-height: 1;
}

.tile.triple-letter {
    background: linear-gradient(145deg, rgba(139, 92, 246, 0.3), rgba(139, 92, 246, 0.1));
    border-color: var(--triple-letter);
}

.tile.triple-letter::before {
    content: '3x';
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 9px;
    font-weight: 700;
    color: var(--triple-letter);
    line-height: 1;
}

.tile.double-word {
    background: linear-gradient(145deg, rgba(249, 115, 22, 0.3), rgba(249, 115, 22, 0.1));
    border-color: var(--double-word);
}

.tile.double-word::before {
    content: '2xW';
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 9px;
    font-weight: 700;
    color: var(--double-word);
    line-height: 1;
}

.tile.has-gem::after {
    content: '💎';
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 12px;
    animation: gemFloat 2s ease-in-out infinite;
    line-height: 1;
}

@keyframes gemFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Selection Order Indicator */
.tile .selection-order {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 22px;
    height: 22px;
    background: var(--accent-primary);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    animation: popIn 0.2s ease-out;
}

@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    gap: 12px;
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.submit-btn {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.submit-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.clear-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.clear-btn:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
}

.btn-icon { font-size: 18px; }

/* ===== Power-ups ===== */
.powerups {
    display: flex;
    gap: 10px;
}

.powerup-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 10px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Outfit', sans-serif;
    min-width: 0;
    text-align: center;
}

.powerup-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    border-color: var(--gem-color);
}

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

.powerup-icon { font-size: 24px; }

.powerup-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.1;
}

.powerup-cost {
    font-size: 11px;
    color: var(--gem-color);
    font-weight: 500;
    line-height: 1.1;
}

/* ===== Legend ===== */
.legend {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 15px 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.legend-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.legend-items {
    display: flex;
    justify-content: space-around;
    gap: 10px;
    flex-wrap: wrap;                  /* küçükte taşmasın */
}

.legend-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 90px;                  /* hizalama */
}

.legend-tile {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    background: var(--tile-bg);
    position: relative;
}

.legend-tile.double-letter {
    background: linear-gradient(145deg, rgba(59, 130, 246, 0.3), rgba(59, 130, 246, 0.1));
    border: 2px solid var(--double-letter);
}

.legend-tile.triple-letter {
    background: linear-gradient(145deg, rgba(139, 92, 246, 0.3), rgba(139, 92, 246, 0.1));
    border: 2px solid var(--triple-letter);
}

.legend-tile.double-word {
    background: linear-gradient(145deg, rgba(249, 115, 22, 0.3), rgba(249, 115, 22, 0.1));
    border: 2px solid var(--double-word);
}

.legend-tile.gem-tile { border: 2px solid var(--gem-color); }

.gem-indicator {
    position: absolute;
    top: 1px;
    right: -1px;
    font-size: 10px;
    line-height: 1;
}

.legend-item span {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}

.modal-content h2 {
    font-size: 28px;
    margin-bottom: 25px;
    background: linear-gradient(135deg, var(--accent-secondary), var(--gem-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.final-stats {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.final-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    gap: 12px;
}

.final-stat-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.final-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--warning);
}

.play-again-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: var(--border-radius-sm);
    color: white;
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.play-again-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* ===== Swap Indicator ===== */
.swap-indicator {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gem-color);
    color: var(--bg-primary);
    padding: 12px 24px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 600;
    transition: bottom 0.3s ease;
    z-index: 50;
    box-shadow: var(--shadow-md);
    max-width: calc(100% - 40px);    /* taşmayı engeller */
}

.swap-indicator.active { bottom: 30px; }

.cancel-swap {
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    border-radius: 15px;
    color: white;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.cancel-swap:hover { background: rgba(0, 0, 0, 0.5); }

/* ===== Change Indicator ===== */
.change-indicator {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-primary);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 600;
    transition: bottom 0.3s ease;
    z-index: 50;
    box-shadow: var(--shadow-md);
    max-width: calc(100% - 40px);
}

.change-indicator.active { bottom: 30px; }

.cancel-change {
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    border-radius: 15px;
    color: white;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.cancel-change:hover { background: rgba(0, 0, 0, 0.5); }

/* ===== Letter Picker ===== */
.letter-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.letter-picker-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 30px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.letter-picker-content h3 {
    margin-bottom: 20px;
    font-size: 20px;
    color: var(--text-primary);
}

.letter-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.letter-grid button {
    aspect-ratio: 1;
    background: var(--tile-bg);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.letter-grid button:hover {
    border-color: var(--accent-secondary);
    background: var(--tile-hover);
    transform: scale(1.05);
}

.letter-grid button .letter-pts {
    font-size: 9px;
    opacity: 0.6;
    font-weight: 500;
}

.letter-picker-cancel {
    padding: 10px 24px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.letter-picker-cancel:hover {
    background: var(--error);
    color: white;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    padding: 14px 28px;
    border-radius: 30px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: top 0.3s ease;
    z-index: 100;
    max-width: calc(100% - 40px);    /* taşmayı engeller */
    text-align: center;
}

.toast.active { top: 30px; }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--error);   color: var(--error); }
.toast.info    { border-color: var(--gem-color); color: var(--gem-color); }

/* ===== Animations ===== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake { animation: shake 0.3s ease; }

@keyframes celebrate {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.celebrate { animation: celebrate 0.4s ease; }

/* ===== Shared Screen Layout ===== */
.screen {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    animation: fadeInUp 0.5s ease-out;
}

.menu-container {
    width: 100%;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ===== Main Menu ===== */
.menu-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.menu-icon {
    font-size: 48px;
    animation: sparkle 2s ease-in-out infinite;
}

.menu-title {
    font-size: 36px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-secondary), var(--gem-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.menu-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.menu-section {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 500;
    outline: none;
    transition: border-color 0.2s ease;
}

.menu-input::placeholder { color: rgba(160, 160, 192, 0.5); }
.menu-input:focus { border-color: var(--accent-secondary); }

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.menu-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 22px;
    background: var(--bg-secondary);
    border: 2px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: left;
    font-family: 'Outfit', sans-serif;
}

.menu-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.menu-btn.create-btn:hover {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.08);
}

.menu-btn.join-btn:hover {
    border-color: var(--gem-color);
    background: rgba(6, 182, 212, 0.08);
}

.menu-btn-icon { font-size: 30px; }

.menu-btn-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.menu-btn-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.menu-btn-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Back Button ===== */
.back-btn {
    align-self: flex-start;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
    transition: color 0.2s ease;
}

.back-btn:hover { color: var(--text-primary); }

.screen-title {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-secondary), var(--gem-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

/* ===== Settings Form (Create Lobby) ===== */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.setting-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.setting-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stepper-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-family: 'Outfit', sans-serif;
    line-height: 1;
    padding: 0;
}

.stepper-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-secondary);
}

.stepper-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--warning);
    min-width: 28px;
    text-align: center;
}

.language-toggle {
    gap: 6px;
}

.lang-btn {
    padding: 6px 16px;
    border-radius: 8px;
    border: 2px solid var(--bg-tertiary);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.lang-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-secondary);
    color: var(--text-primary);
}

/* ===== Join Lobby ===== */
.join-form {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.join-input-row {
    display: flex;
    gap: 10px;
}

.code-input {
    flex: 1;
}

.join-code-btn {
    padding: 12px 24px !important;
    font-size: 15px !important;
}

.available-lobbies {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.lobby-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.empty-lobbies {
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
    padding: 16px 0;
}

.lobby-list-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: all 0.2s ease;
}

.lobby-list-card:hover {
    border-color: var(--gem-color);
    transform: translateY(-1px);
}

.lobby-list-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lobby-list-host {
    font-weight: 700;
    font-size: 14px;
}

.lobby-list-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.lobby-list-code {
    font-size: 16px;
    font-weight: 800;
    color: var(--gem-color);
    letter-spacing: 2px;
}

/* ===== Lobby Room (Waiting Room) ===== */
.room-code-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.room-code-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.room-code {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: 8px;
    color: var(--gem-color);
}

.copy-code-btn {
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    line-height: 1;
}

.copy-code-btn:hover {
    background: rgba(6, 182, 212, 0.15);
    border-color: var(--gem-color);
}

.room-settings-info {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.room-players {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.room-player-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
    animation: fadeInUp 0.3s ease-out;
}

.room-player-card.host {
    border-color: var(--warning);
}

.room-player-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.room-player-name {
    font-weight: 600;
    font-size: 15px;
    flex: 1;
}

.room-player-badge {
    font-size: 10px;
    color: var(--warning);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.room-player-count {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.lobby-start-btn {
    padding: 16px;
    background: linear-gradient(135deg, var(--success), #059669);
    border: none;
    border-radius: var(--border-radius-sm);
    color: white;
    font-family: 'Outfit', sans-serif;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: var(--shadow-md);
}

.lobby-start-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.lobby-start-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: not-allowed;
    box-shadow: none;
}

/* ===== Multiplayer Scoreboard ===== */
.scoreboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.player-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.player-card.active {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 15px var(--accent-glow);
    background: linear-gradient(145deg, rgba(124, 58, 237, 0.15), var(--bg-secondary));
}

.player-card .p-name {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-card.active .p-name { color: var(--accent-secondary); }

.player-card .p-score {
    font-size: 15px;
    font-weight: 800;
    color: var(--warning);
    line-height: 1;
}

.player-card .p-gems {
    font-size: 11px;
    color: var(--gem-color);
    font-weight: 600;
}

/* ===== Turn Indicator ===== */
.turn-indicator {
    text-align: center;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-secondary);
    background: rgba(124, 58, 237, 0.1);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(124, 58, 237, 0.2);
    letter-spacing: 0.5px;
}

/* ===== Ranking Table (Game Over) ===== */
.ranking-table {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.ranking-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
}

.ranking-row.winner {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(6, 182, 212, 0.2));
    border: 1px solid rgba(124, 58, 237, 0.3);
}

.ranking-position {
    font-size: 20px;
    font-weight: 800;
    width: 32px;
    text-align: center;
}

.ranking-row.winner .ranking-position { color: var(--warning); }

.ranking-name {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
    text-align: left;
}

.ranking-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.ranking-score {
    font-size: 18px;
    font-weight: 800;
    color: var(--warning);
}

.ranking-words {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ===== Mobile: Revert to original single-column layout ===== */
@media (max-width: 768px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow: auto;
        padding: 14px;
    }

    .screen {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    /* Game screen: single column, scrollable */
    .game-screen-wrapper {
        height: auto;
        min-height: 100vh;
        padding: 14px;
        overflow: auto;
    }

    .game-panels {
        flex-direction: column;
        gap: 16px;
        overflow: visible;
    }

    /* Left panel: full width, horizontal scoreboard */
    .game-panel-left {
        width: 100%;
        margin-right: 0;
        gap: 12px;
        overflow: visible;
    }

    .scoreboard {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        overflow: visible;
        flex: none;
    }

    .player-card {
        flex: 1;
        min-width: 70px;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 10px 8px;
    }

    .player-card .p-name { flex: none; }
    .player-card .p-score { font-size: 20px; }

    /* Center panel: full width, not square */
    .game-panel-center {
        height: auto;
        aspect-ratio: auto;
        flex-shrink: 1;
        margin: 0;
        padding: 14px;
        align-items: center;
        justify-content: center;
    }

    .game-panel-center .game-board {
        height: auto;
        width: 100%;
        max-width: 440px;
        aspect-ratio: 1;
    }

    .game-board {
        height: auto !important;
        aspect-ratio: 1;
    }

    .tile {
        font-size: 22px;
        height: auto;
        width: auto;
    }

    /* Right panel: full width, horizontal powerups */
    .game-panel-right {
        width: 100%;
        margin-left: 0;
        gap: 12px;
        overflow: visible;
    }

    .powerups-vertical {
        flex-direction: row;
        gap: 8px;
    }

    .powerups-vertical .powerup-btn {
        flex: 1;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 12px 8px;
    }

    .powerups-vertical .powerup-name { text-align: center; }

    .legend-vertical {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
        justify-content: space-around;
    }

    .legend-item-h {
        flex-direction: column;
        gap: 6px;
        min-width: 60px;
        align-items: center;
    }

    /* General mobile tweaks */
    .game-header { padding: 14px; justify-content: center; }
    .logo h1 { font-size: 22px; }
    .word-display { padding: 14px; }
    .current-word { font-size: 24px; letter-spacing: 3px; }
    .menu-title { font-size: 28px; }
    .menu-icon { font-size: 36px; }
    .room-code { font-size: 24px; letter-spacing: 6px; }
}
