/* ===== BASE RESET ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a1a2e;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #e0e0e0;
    user-select: none;
    -webkit-user-select: none;
}

/* ===== SCREENS ===== */
.screen {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1;
}
.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== LOADING SCREEN ===== */
.loading-content {
    text-align: center;
}
.loading-logo {
    font-size: 64px;
    margin-bottom: 16px;
    animation: pulse 2s ease-in-out infinite;
}
.loading-content h1 {
    font-size: 32px;
    color: #FFA726;
    margin-bottom: 24px;
}
.loading-bar {
    width: 240px;
    height: 6px;
    background: #2a2a4a;
    border-radius: 3px;
    margin: 0 auto 12px;
    overflow: hidden;
}
.loading-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #FFA726, #FF7043);
    border-radius: 3px;
    transition: width 0.3s ease;
}
#loadingStatus {
    color: #888;
    font-size: 13px;
}

/* ===== TITLE SCREEN ===== */
.title-content {
    text-align: center;
}
.title-logo {
    font-size: 80px;
    margin-bottom: 8px;
}
.title-content h1 {
    font-size: 42px;
    color: #FFA726;
    margin-bottom: 4px;
}
.title-sub {
    font-size: 18px;
    color: #888;
    margin-bottom: 32px;
}
.title-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
}
.player-stats {
    color: #666;
    font-size: 13px;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn:active { transform: translateY(0); }
.btn-primary { background: #FFA726; color: #1a1a2e; }
.btn-secondary { background: #2a2a4a; color: #e0e0e0; border: 1px solid #444; }
.btn-large { padding: 14px 40px; font-size: 18px; }
.btn-icon {
    background: none; border: none; color: #888; font-size: 24px; cursor: pointer;
    padding: 4px 8px;
}
.btn-icon:hover { color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ===== PANELS ===== */
.panel {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: #16213e;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 10;
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.panel-header h2 { font-size: 20px; color: #FFA726; }
.hidden { display: none !important; }

/* ===== WORD INPUT ===== */
.word-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.word-input-row input {
    flex: 1;
    padding: 10px 14px;
    background: #0f3460;
    border: 1px solid #444;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    outline: none;
}
.word-input-row input:focus { border-color: #FFA726; }
.word-hint { font-size: 12px; color: #666; margin-bottom: 12px; }
.word-feedback {
    margin-bottom: 12px;
    font-size: 13px;
}
.word-feedback.success { color: #4CAF50; }
.word-feedback.error { color: #f44336; }
.recent-words-list {
    max-height: 200px;
    overflow-y: auto;
}
.recent-word-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #0f3460;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 14px;
}
.recent-word-item .word-text { flex: 1; }
.recent-word-item .difficulty-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: 600;
}
.difficulty-badge.easy { background: #4CAF50; color: #fff; }
.difficulty-badge.medium { background: #FFA726; color: #1a1a2e; }
.difficulty-badge.hard { background: #f44336; color: #fff; }
.recent-word-item .btn-delete {
    background: none; border: none; color: #666; cursor: pointer; font-size: 16px;
    padding: 2px 6px;
}
.recent-word-item .btn-delete:hover { color: #f44336; }

/* ===== PROFILE EDITOR ===== */
#profilePanel {
    max-width: 520px;
    max-height: 85vh;
}
.avatar-preview-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 16px;
}
#avatarPreview {
    border-radius: 12px;
    background: #0f3460;
    border: 2px solid #444;
}
.profile-save-status {
    font-size: 12px;
    margin-top: 6px;
    height: 16px;
    transition: color 0.2s;
}
.profile-save-status.saving { color: #FFA726; }
.profile-save-status.saved  { color: #4CAF50; }
.profile-save-status.error  { color: #f44336; }

.cosmetic-section {
    margin-bottom: 14px;
}
.cosmetic-section h3 {
    font-size: 13px;
    color: #aaa;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Item grid (hat, face, accessory) */
.cosmetic-grid {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.cosmetic-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: #0f3460;
    border: 2px solid #333;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
    width: 64px;
}
.cosmetic-item:hover {
    border-color: #666;
    transform: translateY(-1px);
}
.cosmetic-item.active {
    border-color: #FFA726;
    background: rgba(255, 167, 38, 0.12);
}
.cosmetic-mini {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    image-rendering: auto;
}
.cosmetic-label {
    font-size: 9px;
    color: #aaa;
    text-align: center;
    line-height: 1.1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 58px;
}

/* Color swatch grid */
.cosmetic-color-grid {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.cosmetic-color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid #333;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
}
.cosmetic-color-swatch:hover {
    border-color: #888;
    transform: scale(1.12);
}
.cosmetic-color-swatch.active {
    border-color: #FFA726;
    box-shadow: 0 0 0 2px rgba(255, 167, 38, 0.4);
    transform: scale(1.12);
}

/* ===== LOBBY ===== */
.lobby-layout {
    display: flex;
    gap: 32px;
    width: 90%;
    max-width: 800px;
    height: 100%;
    max-height: 100vh;
    padding: 24px 0;
    margin: auto;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
}
.lobby-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
/* Button + chat pinned below the scrolling player list */
.lobby-left-bottom {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}
.lobby-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.lobby-header h2 { color: #FFA726; margin: 0; }
.btn-back {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #555;
    color: #ccc;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
}
.btn-back:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}
.btn-lobby-profile {
    margin-left: auto;
    background: rgba(255, 167, 38, 0.15);
    border: 1px solid #FFA726;
    color: #FFA726;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.15s, color 0.15s;
}
.btn-lobby-profile:hover {
    background: rgba(255, 167, 38, 0.35);
    color: #fff;
}
.lobby-left h2 { color: #FFA726; margin-bottom: 16px; }
.lobby-right {
    width: 280px;
    min-width: 200px;
    flex-shrink: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}
.lobby-right h3 { color: #FFA726; margin-bottom: 12px; flex-shrink: 0; }
.lobby-waiting { color: #888; font-size: 14px; margin-top: 8px; margin-bottom: 0; }

/* ── Lobby Chat ── */
.lobby-chat {
    display: flex;
    flex-direction: column;
    margin-top: 12px;
}
.lobby-chat h3 { color: #FFA726; margin-bottom: 8px; }
.lc-messages {
    height: 120px;
    overflow-y: auto;
    background: #14142a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}
.lc-msg { line-height: 1.4; word-break: break-word; }
.lc-msg .lc-author { font-weight: 600; margin-right: 4px; color: #FFA726; }
.lc-msg.lc-self .lc-author { color: #64B5F6; }
.lc-msg.lc-system { color: #888; font-style: italic; }
.lc-input-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-shrink: 0;
}
.lc-input {
    flex: 1;
    background: #1e1e3a;
    border: 1px solid #555;
    border-radius: 6px;
    color: #fff;
    padding: 6px 10px;
    font-size: 13px;
    outline: none;
    min-width: 0;
}
.lc-input:focus { border-color: #FFA726; }
.lc-send-btn {
    background: #FFA726 !important;
    color: #1a1a2e !important;
    border: none !important;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}
.lc-send-btn:hover { background: #ffb84d !important; }

.player-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 12px;
}
.player-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #16213e;
    border-radius: 8px;
    margin-bottom: 6px;
}
.player-item .player-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #2a2a4a;
    flex-shrink: 0;
}
canvas.player-avatar {
    border-radius: 6px;
}
.player-item .player-name { flex: 1; font-weight: 500; }
.player-item .host-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #FFA726;
    color: #1a1a2e;
    font-weight: 600;
}
.player-item .you-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #66bb6a;
    color: #1a1a2e;
    font-weight: 600;
}
.player-item.player-self {
    border-left: 3px solid #66bb6a;
}

/* ===== SETTINGS ===== */
.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
    padding-right: 4px;
}
.settings-panel label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: #aaa;
}
.settings-panel select,
.settings-panel input[type="range"] {
    padding: 8px 10px;
    background: #0f3460;
    border: 1px solid #444;
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    outline: none;
    cursor: pointer;
}
.settings-panel select:focus { border-color: #FFA726; }
.settings-panel.readonly select,
.settings-panel.readonly input {
    display: none;
}
.setting-readonly {
    display: block;
    padding: 8px 10px;
    background: #0f3460;
    border: 1px solid #333;
    border-radius: 6px;
    color: #ccc;
    font-size: 14px;
}

/* ===== ROOM BROWSER ===== */
.room-browser-layout {
    display: flex;
    flex-direction: column;
    max-width: 600px;
    margin: 0 auto;
    padding: 24px 16px;
    height: 100%;
    box-sizing: border-box;
}
.room-browser-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.room-browser-header h2 {
    flex: 1;
    margin: 0;
    font-size: 22px;
}
.room-browser-actions {
    margin-bottom: 16px;
}
.create-room-row {
    display: flex;
    gap: 8px;
}
.create-room-row input {
    flex: 1;
    padding: 10px 14px;
    background: #0f3460;
    border: 1px solid #444;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    outline: none;
}
.create-room-row input:focus { border-color: #FFA726; }
.create-room-row .btn { white-space: nowrap; }
.room-list-container {
    flex: 1;
    overflow-y: auto;
}
.room-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.room-list-empty {
    text-align: center;
    color: #888;
    padding: 40px 16px;
    font-size: 15px;
}
.room-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #16213e;
    border: 1px solid #333;
    border-radius: 10px;
    transition: border-color 0.15s, background 0.15s;
}
.room-card:hover { border-color: #FFA726; background: #1a2744; }
.room-card-info {
    flex: 1;
    min-width: 0;
}
.room-card-name {
    font-weight: 600;
    font-size: 15px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.room-card-meta {
    font-size: 12px;
    color: #aaa;
    margin-top: 2px;
}
.room-card-players {
    font-size: 13px;
    color: #ccc;
    white-space: nowrap;
    margin-right: 4px;
}
.room-card-status {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.room-card-status.open {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
}
.room-card-status.in-game {
    background: rgba(255, 167, 38, 0.2);
    color: #FFA726;
}
.room-card .btn {
    flex-shrink: 0;
}

/* ===== GAME SCREEN ===== */
.game-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* Top Bar */
.game-top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: #16213e;
    border-bottom: 1px solid #333;
    height: 48px;
    flex-shrink: 0;
}
.round-info {
    display: flex;
    flex-direction: column;
    font-size: 12px;
    color: #aaa;
    min-width: 100px;
    flex-shrink: 0;
}
.round-info #roundNumber { font-weight: 600; color: #FFA726; font-size: 14px; }
.word-display {
    flex: 1;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 4px;
    color: #fff;
    font-family: 'Courier New', monospace;
    white-space: nowrap;
    overflow: hidden;
}
.word-letter-count {
    font-size: 12px;
    color: #aaa;
    letter-spacing: 0;
    font-weight: 400;
    margin-left: 4px;
}
.timer-area {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 260px;  /* match sidebar */
    flex-shrink: 0;
}
.timer-bar {
    flex: 1;
    height: 20px;
    background: #2a2a4a;
    border-radius: 10px;
    overflow: visible;
    position: relative;
    border: 1px solid #3a3a5a;
}
.timer-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 10px;
    transition: width 1s linear;
    width: 100%;
}
.timer-text {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    min-width: 28px;
    text-align: center;
    pointer-events: none;
}

/* Main Area */
.game-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Canvas */
.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #1a1a2e;
    overflow: hidden;
}
#drawingCanvas {
    display: block;
    cursor: crosshair;
    background: #fff;
    /* CSS size set dynamically by DrawingCanvas._handleResize() */
}
.canvas-area.viewer #drawingCanvas {
    cursor: default;
}

/* Tool Palette */
.tool-palette {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(26, 26, 46, 0.95);
    border-top: 1px solid #333;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.tool-colors {
    display: grid;
    grid-template-columns: repeat(12, 22px);
    gap: 3px;
}
.color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.1s, transform 0.1s;
}
.color-swatch:hover { border-color: #fff; }
.color-swatch.active { border-color: #FFA726; transform: scale(1.15); }

.tool-sizes {
    display: flex;
    gap: 6px;
    align-items: center;
}
.size-btn {
    border-radius: 50%;
    background: #888;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.1s;
}
.size-btn:hover { border-color: #fff; }
.size-btn.active { border-color: #FFA726; }

.tool-buttons {
    display: flex;
    gap: 4px;
}
.tool-btn {
    padding: 6px 10px;
    background: #2a2a4a;
    border: 1px solid #444;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.1s;
    color: #ccc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.tool-btn svg { display: block; }
.tool-btn:hover { background: #3a3a5a; color: #fff; }
.tool-btn.active { background: #FFA726; border-color: #FFA726; color: #1a1a2e; }
.tool-btn-danger:hover { background: #f44336; border-color: #f44336; }

/* Sidebar */
.game-sidebar {
    width: 260px;
    display: flex;
    flex-direction: column;
    background: #16213e;
    border-left: 1px solid #333;
    flex-shrink: 0;
}
.scoreboard {
    padding: 8px;
    border-bottom: 1px solid #333;
    max-height: 200px;
    overflow-y: auto;
}
.score-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    margin-bottom: 2px;
    font-size: 13px;
}
.score-item.drawing { background: rgba(255, 167, 38, 0.15); }
.score-item.guessed { color: #4CAF50; }
.score-item .score-name { flex: 1; }
.score-item .score-points { font-weight: 700; color: #FFA726; }
.score-avatar {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Chat */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.chat-msg {
    padding: 4px 0;
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}
.chat-msg .chat-author { font-weight: 600; margin-right: 4px; }
.chat-msg.system { color: #888; font-style: italic; }
.chat-msg.correct { color: #4CAF50; font-weight: 600; }
.chat-msg.close { color: #FFA726; font-style: italic; }
.chat-msg.winners {
    color: #81d4fa;
    background: rgba(33, 150, 243, 0.08);
    border-left: 2px solid #42a5f5;
    padding-left: 6px;
    margin-left: 4px;
}
.chat-msg.winners .winners-badge {
    margin-right: 4px;
    font-size: 11px;
}

.chat-input-row {
    display: flex;
    gap: 4px;
    padding: 8px;
    border-top: 1px solid #333;
}
.chat-input-row input {
    flex: 1;
    padding: 8px 12px;
    background: #0f3460;
    border: 1px solid #444;
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    outline: none;
}
.chat-input-row input:focus { border-color: #FFA726; }
.chat-input-row input:disabled { opacity: 0.5; }
.chat-input-row input.winners-input {
    border-color: #42a5f5;
    background: #0d2744;
}
.chat-input-row input.winners-input:focus { border-color: #81d4fa; }
.chat-input-row .btn { padding: 8px 14px; font-size: 13px; }

/* ===== WORD PICKER MODAL ===== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal-content {
    text-align: center;
    background: #16213e;
    border: 1px solid #333;
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
}
.modal-content h2 { color: #FFA726; margin-bottom: 8px; }
.pick-timer {
    font-size: 36px;
    font-weight: 700;
    color: #f44336;
    margin-bottom: 20px;
}
.word-choices {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.word-choice {
    padding: 16px 24px;
    background: #0f3460;
    border: 2px solid #444;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 120px;
}
.word-choice:hover { border-color: #FFA726; transform: translateY(-2px); }
.word-choice .word-text { font-size: 18px; font-weight: 600; color: #fff; }
.word-choice .word-diff {
    font-size: 11px;
    margin-top: 4px;
    text-transform: uppercase;
    font-weight: 600;
}
.word-choice .word-diff.easy { color: #4CAF50; }
.word-choice .word-diff.medium { color: #FFA726; }
.word-choice .word-diff.hard { color: #f44336; }

/* ===== OVERLAYS ===== */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.results-content {
    text-align: center;
    padding: 32px;
}
.results-content h2 { color: #FFA726; font-size: 28px; margin-bottom: 12px; }
.results-word { font-size: 20px; margin-bottom: 20px; }
.results-word strong { color: #4CAF50; font-size: 24px; }
.result-scores {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

/* ===== GAME OVER ===== */
.gameover-content {
    text-align: center;
    padding: 40px;
}
.gameover-content h1 { font-size: 36px; color: #FFA726; margin-bottom: 24px; }
.final-rankings {
    margin-bottom: 32px;
}
.ranking-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: #16213e;
    border-radius: 10px;
    margin-bottom: 6px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}
.ranking-item:first-child { background: rgba(255, 167, 38, 0.2); border: 1px solid #FFA726; }
.ranking-position {
    font-size: 24px;
    font-weight: 700;
    min-width: 40px;
}
.ranking-item:nth-child(1) .ranking-position { color: #FFD700; }
.ranking-item:nth-child(2) .ranking-position { color: #C0C0C0; }
.ranking-item:nth-child(3) .ranking-position { color: #CD7F32; }
.ranking-name { flex: 1; font-size: 16px; font-weight: 500; }
.ranking-score { font-size: 18px; font-weight: 700; color: #FFA726; }

/* ===== ANIMATIONS ===== */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.3s ease; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .lobby-layout { flex-direction: column; gap: 16px; padding: 16px 0; }
    .lobby-left { flex: none; overflow: visible; }
    .lobby-right { width: 100%; min-width: unset; flex-shrink: 0; overflow: visible; }
    .game-sidebar { width: 200px; }
    .word-display { letter-spacing: 2px; }
    .tool-palette { padding: 6px 8px; gap: 8px; }
    .tool-colors { grid-template-columns: repeat(12, 18px); gap: 2px; }
    .color-swatch { width: 18px; height: 18px; }
}
@media (max-width: 480px) {
    .game-sidebar { display: none; } /* On very small screens, hide sidebar */
    .game-main { position: relative; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #666; }

/* ===== SOUND TOGGLE ===== */
.btn-sound-toggle {
    position: fixed;
    bottom: 12px;
    right: 12px;
    z-index: 9999;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
    background: rgba(26,26,46,0.85);
    color: #e0e0e0;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    backdrop-filter: blur(4px);
}
/* When inside the game timer area, sit inline instead of floating */
.btn-sound-toggle.in-game {
    position: static;
    width: 32px;
    height: 32px;
    font-size: 16px;
    flex-shrink: 0;
    z-index: auto;
    backdrop-filter: none;
}
.btn-sound-toggle:hover {
    background: rgba(26,26,46,1);
    border-color: rgba(255,255,255,0.4);
}
.btn-sound-toggle.muted {
    opacity: 0.5;
}
