@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800&family=Inter:wght@400;500;600&display=swap');

/* Online Status */
.online-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 12px;
}
.status-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
    animation: status-pulse 2s infinite;
}

/* Language specific display logic */
body.lang-en .ja-only { display: none !important; }
body.lang-ja .en-only { display: none !important; }
@keyframes status-pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
    100% { opacity: 1; transform: scale(1); }
}

/* Room List Area */
.room-list-area {
    margin-top: 24px;
    text-align: left;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.section-header h3 {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 600;
}
.room-list-area .room-list {
    max-height: 250px;
    overflow-y: auto;
    padding: 4px 0; /* Restored: width now aligns with buttons/inputs */
}
.room-list-area .room-list::-webkit-scrollbar {
    width: 4px;
}
.room-list-area .room-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

:root {
    /* Softer dark theme variables */
    --bg-dark: #0f172a; /* Slate 900 */
    --text-main: #f8fafc; /* Slate 50 */
    --text-muted: #cbd5e1; /* Slate 300 */
    
    --accent-primary: #6366f1; /* Indigo 500 */
    --accent-secondary: #8b5cf6; /* Violet 500 */
    --wolf-color: #f43f5e; /* Rose 500 */
    --citizen-color: #3b82f6; /* Blue 500 */
    
    --glass-bg: rgba(30, 41, 59, 0.7); /* Slate 800 with opacity */
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-highlight: rgba(255, 255, 255, 0.05);
    
    --chat-mine: linear-gradient(135deg, #6366f1, #4f46e5);
    --chat-other: #334155; /* Slate 700 */
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.4);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.6);
}

html {
    scrollbar-gutter: stable;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    /* Dynamic aurora-like background */
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.15), transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.15), transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(15, 23, 42, 1), rgba(15, 23, 42, 1));
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    scrollbar-gutter: stable;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.1), transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(139, 92, 246, 0.1), transparent 50%);
    z-index: -1;
    animation: aurora 20s infinite alternate ease-in-out;
}

@keyframes aurora {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.2) translate(2%, 2%); }
}

#app {
    width: 100%;
    max-width: 500px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    /* Remove heavy background and borders to let the aurora shine through */
    background: transparent;
}

/* ゲーム中画面は固定高さで、中身のエリアごとにスクロールを制御 */
#game-screen.active {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Typography */
h1, h2, h3 {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.01em;
}

/* Invite Bar */
.invite-bar {
    background: rgba(165, 180, 252, 0.1);
    border-bottom: 1px solid rgba(165, 180, 252, 0.1);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.invite-bar.hidden {
    display: none;
}

#copy-invite-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin-top: 0 !important;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 10000;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
}

.toast.hidden {
    opacity: 0;
    transform: translate(-50%, 20px);
    pointer-events: none;
}

.logo-container {
    text-align: center;
    margin-bottom: 2rem;
}

.wolf-icon {
    width: 100px; /* Slightly larger */
    height: 100px;
    margin: 0 auto 1rem;
    filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.6));
    animation: float 3s ease-in-out infinite;
    display: block;
    position: relative;
}
.wolf-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.2) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    z-index: -1;
}
.wolf-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 20px;
}

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

.app-title {
    font-size: clamp(2.2rem, 10vw, 3.5rem);
    font-weight: 800;
    letter-spacing: clamp(-3px, -0.5vw, -1px);
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 50%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    line-height: 1;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.3));
    text-transform: uppercase;
}

.app-subtitle {
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
    color: #a5b4fc;
    font-weight: 600;
    margin-top: 0.5rem;
    letter-spacing: clamp(1px, 1vw, 4px);
    text-transform: uppercase;
    opacity: 0.9;
    white-space: nowrap;
}

.game-features {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: #cbd5e1;
}

.feature-icon {
    font-size: 1.1rem;
    background: rgba(255, 255, 255, 0.08);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* Glassmorphism Classes */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    padding: 32px;
    box-shadow: 
        0 20px 50px rgba(0, 0, 0, 0.3),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.glass-header {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

/* Screens & Areas */
.screen {
    display: none;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height for modern browsers */
    flex-direction: column;
    position: relative;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    overflow: hidden;
}
#start-screen {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: max(40px, env(safe-area-inset-top)) 20px 40px; 
    overflow-y: auto;
}
#start-screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}
#start-screen .glass-card {
    margin: auto 0; /* Vertical center if space, top-align if not */
    width: 100%;
    max-width: 460px;
}
.screen.active {
    display: flex;
    animation: fadeIn 0.4s ease-out;
}

.area {
    display: none;
    flex-direction: column;
    flex: 1; /* Take remaining space */
    overflow-y: auto; /* Enable internal scrolling */
    padding: 20px;
    -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
}
.area.active {
    display: flex;
    animation: slideUp 0.4s ease-out;
}

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

/* Inputs */
.input-group {
    margin-bottom: 24px;
}
.icon-selector {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}
.icon-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
}
.icon-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}
.icon-item.active {
    background: var(--accent-primary);
    border-color: var(--accent-secondary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.input-group label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 600;
}
input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    transition: all 0.2s ease;
}
input[type="text"]::placeholder,
input[type="password"]::placeholder {
    color: #94a3b8;
}
input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

/* Buttons */
.primary-btn {
    width: 100%;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    margin-top: 12px;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
    position: relative;
    overflow: hidden;
}

.primary-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: 0.5s;
}

.primary-btn:hover::before {
    left: 100%;
}

.primary-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 28px rgba(99, 102, 241, 0.5);
    filter: brightness(1.1);
}

.primary-btn:active {
    transform: translateY(-1px) scale(0.98);
}

.primary-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.secondary-btn {
    width: 100%;
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.button-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.checkbox-label {
    display: flex !important;
    width: 100% !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 16px;
    padding: 0;
}

/* Toggle Switch Styling */
.toggle-switch {
    position: relative;
    display: inline-block !important;
    min-width: 46px !important;
    width: 46px !important;
    height: 24px !important;
    background: #334155 !important; /* Steel blue-grey for clear visibility */
    border-radius: 12px !important;
    transition: all 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    vertical-align: middle;
}
.checkbox-label input {
    display: none !important;
}
.toggle-switch::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white !important;
    top: 2px;
    left: 2px;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.checkbox-label input:checked + .toggle-switch {
    background: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
}
.checkbox-label input:checked + .toggle-switch::after {
    left: 24px !important;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 16px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--glass-border);
}
.divider span {
    padding: 0 10px;
}

/* Header & Timer */
.room-name-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    min-height: 30px;
}
.room-meta-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.header-info h2 {
    font-size: 1.25rem;
    color: var(--text-main);
    margin-bottom: 0;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.room-name-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--accent-primary);
    border-radius: 6px;
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    padding: 2px 8px;
    width: 200px;
}
.icon-btn-ghost {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 6px;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}
.icon-btn-ghost:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}
.icon-btn-ghost svg {
    width: 18px;
    height: 18px;
}
.badge {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    width: fit-content;
}
.timer {
    font-family: 'Outfit', sans-serif;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}
.timer.danger {
    color: var(--wolf-color);
}

/* Connection Status */
.connection-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: opacity 0.5s ease, visibility 0.5s;
}
.small-loader {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top: 2px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Lobby */
#lobby-players, #lobby-spectators {
    list-style: none;
    margin-top: 12px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 4px;
}
.players-list-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
#lobby-players li, #lobby-spectators li {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 10px;
    border-radius: 16px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    transition: transform 0.2s;
}

.player-info-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.player-icon-box {
    font-size: 1.4rem;
    min-width: 32px;
    display: flex;
    justify-content: center;
}

.player-name-text {
    font-size: 1rem;
    color: var(--text-main);
    font-weight: 600;
}

.badge-host {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-me {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.remove-cpu-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    margin-left: auto;
    transition: all 0.2s;
    line-height: 1;
}

.remove-cpu-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    color: white;
    border-color: #f87171;
    transform: scale(1.1);
}

.hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 12px;
}

.wolf-count-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.wolf-count-control label {
    font-size: 0.95rem;
    font-weight: 600;
}
.counter-group {
    display: flex;
    align-items: center;
    gap: 12px;
}
.counter-group span {
    font-size: 1.4rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    min-width: 24px;
    text-align: center;
}
.counter-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.08);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.counter-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.lobby-status-msg {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    margin-top: 1.5rem;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    display: inline-block;
}

.wolf-count-badge {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Chat Area */
#main-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.my-word-card {
    text-align: center;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 16px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
}
.highlight-text {
    font-family: 'Outfit', sans-serif;
    font-size: 2.2rem;
    font-weight: 800;
    color: #fcfcfc;
    line-height: 1.1;
    letter-spacing: 0.05em;
    text-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}
.word-sub-text {
    display: block;
    font-size: 0.85rem;
    color: var(--accent-primary);
    margin-top: 8px;
    font-weight: 600;
    opacity: 0.9;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px 12px 20px;
    scrollbar-width: none; 
    position: relative;
}
.chat-container::-webkit-scrollbar { display: none; }

.jump-latest-btn {
    position: absolute;
    bottom: 85px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(16, 185, 129, 0.9);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 50;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}
.jump-latest-btn:hover {
    background: rgba(16, 185, 129, 1.0);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}
.jump-latest-btn.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(10px);
}

#tray-chat-messages {
    gap: 10px; /* Further reduced for a tighter feel */
    padding: 10px 12px; /* Reduced vertical padding */
}

#tray-chat-messages .message-wrapper {
    margin-bottom: 0;
}

/* Compact gameplay chat */
#chat-messages {
    gap: 8px;
}

#chat-messages .message-wrapper {
    margin-bottom: 0;
}

#chat-messages .message-sender {
    margin-bottom: 2px;
}

#chat-messages .message-bubble {
    padding: 8px 14px;
}

#tray-chat-messages .message-bubble {
    padding: 8px 14px;
}

.system-message {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    align-self: center;
    border: 1px solid rgba(255, 255, 255, 0.06); margin: 0;
}

.message-wrapper.system {
    align-self: center;
    max-width: 100%;
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 0;
}
.system-message {
    white-space: pre-wrap;
    text-align: center;
    line-height: 1.4;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out forwards; flex-shrink: 0; margin-bottom: 4px;
}

.message-wrapper.mine { align-self: flex-end; }
.message-wrapper.other { align-self: flex-start; }

.message-sender {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    margin-left: 12px;
    font-weight: 500;
}

.message-bubble {
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 1rem;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
}

.message-bubble:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.message-bubble:active {
    transform: scale(0.98) translateY(0);
    filter: brightness(0.95);
}

.mode-badge-mini {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    height: 18px;
    vertical-align: middle;
    margin-left: 4px;
}

.mine .message-bubble {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-bottom-right-radius: 4px;
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.other .message-bubble {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom-left-radius: 4px;
    color: white;
}

/* Reply */
.reply-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--accent-primary);
    padding: 6px 12px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 4px;
    cursor: pointer;
    transition: background 0.2s;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.reply-preview:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Active Reply Preview Bar */
.reply-active-container {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    animation: slideUpIn 0.3s ease-out;
    margin-bottom: -1px; /* Align with input box border */
}

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

.reply-info {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    white-space: nowrap;
}

.reply-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-transform: uppercase;
}

.reply-content {
    font-size: 0.85rem;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
}

.cancel-reply-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-muted);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.cancel-reply-btn:hover {
    background: rgba(244, 63, 94, 0.2);
    color: var(--wolf-color);
}

.message-content {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.mine .message-content { justify-content: flex-end; }
.other .message-content { justify-content: flex-start; }

.reply-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0; /* Hidden by default, shown on hover */
}
.message-wrapper:hover .reply-btn {
    opacity: 1;
    color: rgba(255, 255, 255, 0.5);
}
.reply-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-primary) !important;
}
.reply-btn svg {
    width: 16px;
    height: 16px;
}
/* On touch devices, keep some opacity */
@media (hover: none) {
    .reply-btn {
        opacity: 0.6;
    }
}

/* Status Bar for Multi-round */
.status-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px !important;
    margin-bottom: 12px;
}

.player-chip {
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}
.player-chip:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.player-chip:active {
    transform: translateY(0);
    filter: brightness(0.9);
}
.player-chip.dead {
    opacity: 0.4;
    text-decoration: line-through;
    background: rgba(0, 0, 0, 0.2);
}
.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80; /* Green */
}
.player-chip.dead .status-dot {
    background: #94a3b8; /* Gray */
}
.role-badge-mini {
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
    margin-left: 4px;
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.role-badge-mini.wolf {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
}
.role-badge-mini.citizen {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.3);
}
.dead .role-badge-mini {
    opacity: 0.8;
}

.message-wrapper:hover .reply-btn {
    opacity: 1;
}
.reply-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.reply-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(99, 102, 241, 0.15);
    border-left: 3px solid var(--accent-primary);
    padding: 8px 14px;
    border-radius: 0 12px 12px 0;
    margin-bottom: 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
    animation: slideUp 0.2s ease-out;
}
.cancel-reply-btn {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #f87171 !important;
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
    flex-shrink: 0;
}
.cancel-reply-btn:hover {
    background: rgba(239, 68, 68, 0.3) !important;
    color: white !important;
    border-color: #f87171 !important;
    transform: scale(1.1);
}

.reply-active-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.8);
    padding: 8px 16px;
    border-radius: 12px 12px 0 0;
    border-left: 4px solid var(--accent-primary);
    margin-bottom: -1px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: slideUp 0.2s ease-out;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}
.reply-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    overflow: hidden;
    flex: 1;
    margin-right: 12px;
    min-width: 0;
    gap: 8px;
}
.reply-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--accent-primary);
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
}
.reply-content {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.message-wrapper.highlight .message-bubble {
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
    transition: box-shadow 0.3s;
}

/* Typing Indicator */
.typing-indicator {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.typing-indicator span:not(.typing-text) {
    width: 6px; height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

/* Lobby Settings UI */
.lobby-settings {
    margin: 16px 0;
    padding: 20px !important;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.settings-section {
    display: flex;
    flex-direction: column;
    gap: 18px; /* Increased from 12px for better breathing room */
}
.settings-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    opacity: 0.8;
}
.lobby-settings-preview {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px 20px;
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    margin-top: 10px;
}
.lobby-settings-preview div {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--text-muted);
}
.lobby-settings-preview span {
    color: var(--accent-primary);
    font-weight: 800;
}
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.setting-item label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}
.checkbox-label.mini {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 0;
    font-size: 0.85rem;
}
.setting-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
    padding-right: 60px; /* Leave space for toggle */
}
.counter-group {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.08);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
}
.counter-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: background 0.2s;
}
.counter-btn:hover {
    background: var(--accent-primary);
}
.counter-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    min-width: 56px;
    gap: 2px;
}
#wolf-count-display, #max-players-display, #time-count-display {
    font-weight: 700;
    min-width: 32px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.edit-group {
    display: flex;
    gap: 8px;
}
.edit-group input {
    padding: 8px 12px !important;
    font-size: 0.9rem !important;
}
.icon-btn-small {
    background: var(--accent-primary);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.checkbox-label.mini {
    margin-bottom: 0;
    font-size: 0.85rem;
}
.checkbox-label.mini .toggle-switch {
    min-width: 48px !important;
    width: 48px !important;
    height: 24px !important;
}
.checkbox-label.mini .toggle-switch::after {
    width: 18px;
    height: 18px;
    top: 3px;
    left: 3px;
}
.checkbox-label.mini input:checked + .toggle-switch::after {
    left: 27px !important;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.typing-text {
    font-size: 0.85rem;
    margin-left: 6px;
}

/* Input Area */
.input-container {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 24px;
    margin-top: auto;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}
.input-container:focus-within {
    border-color: var(--accent-primary);
    background: rgba(30, 41, 59, 0.9);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
    transform: translateY(-2px);
}
.input-container input {
    flex: 1;
    background: transparent !important;
    border: none !important;
    padding: 8px 16px;
    font-size: 1rem;
    color: white;
    box-shadow: none !important;
    outline: none !important;
}
.my-word-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 20px !important;
    margin-bottom: 12px;
    gap: 4px;
    text-align: center;
}
.word-row {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.label-row {
    opacity: 0.6;
    font-size: 0.75rem;
    font-weight: 500;
}
.main-row {
    gap: 8px;
    padding: 0;
}
.footer-row {
    margin-top: 0;
}
.word-display-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 12px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    gap: 2px;
    width: 100%;
    max-width: 280px;
    box-sizing: border-box;
}
.word-display-box.clickable {
    cursor: pointer;
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.2);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.1);
}
.word-display-box.clickable:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.2);
}
.word-display-box.clickable:active {
    transform: translateY(0) scale(0.98);
}
.word-display-box.clickable .highlight-text {
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}
.word-display-box.silent-wolf-alert {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    animation: pulse-red 2s infinite;
}
.word-display-box.silent-wolf-alert:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
}
.word-display-box.silent-wolf-alert .highlight-text {
    font-size: 1.8rem;
    white-space: nowrap;
    color: #f87171;
}
.word-sub-text {
    font-size: 0.7rem;
    opacity: 0.8;
    font-weight: 500;
    text-align: center;
    margin-top: 2px;
    line-height: 1.2;
    display: none;
}
.word-display-box.silent-wolf-alert .word-sub-text {
    display: block;
    color: #fca5a5;
    animation: fadeIn 0.5s ease forwards;
}
.word-display-box.hidden-word-mode {
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.25);
    padding: 10px 16px;
    user-select: none;
    box-shadow: none;
    transition: all 0.2s ease;
}
.word-display-box.hidden-word-mode:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.4);
}
.word-display-box.hidden-word-mode:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.98);
}
.word-display-box.hidden-word-mode .highlight-text {
    font-size: 1.2rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: none;
    letter-spacing: normal;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(2px); }
    to { opacity: 0.8; transform: translateY(0); }
}
@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.2); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.wolf-count-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Wolf Guessing Area */
#wolf-guessing-area .glass-card {
    padding: 40px 20px !important;
    max-width: 500px;
    margin: 0 auto;
}
.reversal-header h2 {
    color: #f87171;
    font-size: 1.8rem;
    margin-bottom: 8px;
    text-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}
.glass-input-large {
    width: 100%;
    max-width: 300px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 14px 20px;
    color: white;
    font-size: 1.2rem;
    text-align: center;
    outline: none;
    transition: all 0.3s;
    margin-bottom: 10px;
}
.glass-input-large:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.input-container input::placeholder {
    color: #94a3b8;
}
.icon-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}
.icon-btn:hover {
    background: var(--accent-secondary);
    transform: scale(1.05);
}

/* Voting Area */
.voting-grid {
    display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 24px;
}
.vote-btn {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    text-align: left;
}
.vote-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}
.vote-btn.selected {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}
.vote-btn.voted-done {
    border-color: rgba(74, 222, 128, 0.3); /* Soft green */
}
.voted-status {
    font-size: 0.75rem;
    opacity: 0.8;
}
.player-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Result Area */
.result-card h2 { text-align: center; margin-bottom: 10px; font-size: 1.8rem; }
.winner-text {
    text-align: center; font-size: 2.2rem; margin-bottom: 20px;
    font-family: 'Outfit', sans-serif; font-weight: 800;
    color: #fbbf24; /* Amber 400 */
}

#wolf-guess-display {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-primary);
    text-align: center;
    margin: 15px auto;
    padding: 12px 20px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    width: fit-content;
    max-width: 90%;
    animation: fadeInScale 0.4s ease-out;
}

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

.words-reveal { display: flex; flex-direction: column; gap: 12px; margin-bottom: 32px; }
.word-box {
    background: rgba(255, 255, 255, 0.06); 
    border: 1px solid var(--glass-border);
    padding: 20px; border-radius: 16px;
    display: flex; justify-content: space-between; align-items: center;
}
.wolf-box {
    border-left: 4px solid var(--wolf-color);
}
.word-box span { color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }
.word-box strong { font-size: 1.4rem; color: white; font-weight: 700; }

.players-result li {
    padding: 10px; border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 1.05rem;
}
.role-wolf { color: var(--wolf-color); font-weight: 700; }
.role-citizen { color: #60a5fa; font-weight: 600; }

.hidden { display: none !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 10px !important; }
.mt-4 { margin-top: 24px !important; }
.text-center { text-align: center; }

.setting-item-block {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Room List */
.room-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.room-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}
.room-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.room-id {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.room-stats {
    display: flex;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: 600;
}
.room-wolf-label {
    color: var(--wolf-color);
}
.room-time-label {
    color: #fbbf24; /* Amber 400 */
}
.room-reveal-label {
    color: #a78bfa; /* Violet 400 */
    cursor: pointer;
}

/* Login Footer */
.login-footer {
    margin-top: 24px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.login-footer a {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color 0.2s;
}
.login-footer a:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}
.divider {
    color: rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.header-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    min-width: 0;
}
.icon-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}
#header-chat-btn {
    width: 42px;
    padding: 6px 0;
}
#leave-room-btn {
    width: 76px;
    padding: 6px 0;
}
.icon-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}
.icon-btn-secondary svg {
    width: 16px;
    height: 16px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000;
    padding: 20px;
}
.modal-content {
    max-width: 450px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
.modal-body {
    overflow-y: auto;
    margin: 20px 0;
    padding-right: 10px;
}
.modal-body section {
    margin-bottom: 10px;
}
.modal-body h3 {
    font-size: 1rem;
    margin-bottom: 4px;
    color: var(--accent-primary);
}
.modal-body p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-muted);
}

/* How to Play Guide */
.wide-modal {
    max-width: 500px;
}

.how-to-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: left;
}

.how-to-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.step-badge {
    background: var(--accent-primary);
    color: white;
    width: 2.2rem;
    height: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.7rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.step-text h4 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    color: white;
}

.step-text p {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.text-link-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: color 0.2s;
}

.text-link-btn:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}
.modal-content h2 {
    font-size: 1.5rem;
    text-align: center;
}

/* Ghost Chat Styles */
.message-wrapper.ghost {
    opacity: 0.85;
}
.message-wrapper.ghost .message-bubble {
    background: rgba(100, 100, 100, 0.2) !important;
    border-left: 3px solid #94a3b8;
}
.ghost-label {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 600;
}

.lock-icon-mini {
    display: inline-flex;
    align-items: center;
    color: #fbbf24;
    margin-left: 2px;
}

.lock-icon-mini svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.5px;
}

/* Chat Tray Overlay */
.chat-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    animation: bounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) alternate;
}

.tray-start-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
    transition: all 0.2s;
}
.tray-start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.5);
}
.tray-start-btn:disabled {
    background: #334155;
    color: rgba(255,255,255,0.2);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}
.icon-btn-sm {
    background: rgba(255,255,255,0.05);
    border: none;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.icon-btn-sm:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}
.icon-btn-sm svg {
    width: 18px;
    height: 18px;
}

.chat-tray-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.chat-tray-input {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: max(env(safe-area-inset-bottom), 10px);
}
    padding-right: 10px;
}
.modal-body section {
    margin-bottom: 10px;
}
.modal-body h3 {
    font-size: 1rem;
    margin-bottom: 4px;
    color: var(--accent-primary);
}
.modal-body p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-muted);
}

/* How to Play Guide */
.wide-modal {
    max-width: 500px;
}

.how-to-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: left;
}

.how-to-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.step-badge {
    background: var(--accent-primary);
    color: white;
    width: 2.2rem;
    height: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.7rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.step-text h4 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    color: white;
}

.step-text p {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.text-link-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    cursor: pointer;
    margin-top: 0;
    transition: color 0.2s;
}

.text-link-btn:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}
.modal-content h2 {
    font-size: 1.5rem;
    text-align: center;
}

/* Ghost Chat Styles */
.message-wrapper.ghost {
    opacity: 0.85;
}
.message-wrapper.ghost .message-bubble {
    background: rgba(100, 100, 100, 0.2) !important;
    border-left: 3px solid #94a3b8;
}
.ghost-label {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 600;
}

.lock-icon-mini {
    display: inline-flex;
    align-items: center;
    color: #fbbf24;
    margin-left: 2px;
}

.lock-icon-mini svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.5px;
}

/* Chat Tray Overlay */
.chat-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    animation: bounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) alternate;
}

.chat-tray-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    transition: opacity 0.3s ease, visibility 0s linear;
}
.chat-tray-backdrop.hidden {
    display: block !important;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

.chat-tray {
    position: fixed; /* Keep it at the bottom of the viewport, not the container */
    bottom: 0;
    left: 0;
    right: 0;
    height: 75%;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-top: 1px solid var(--glass-border);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    z-index: 1001; /* Above almost everything */
    display: flex;
    flex-direction: column;
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.6);
}
.chat-tray.hidden {
    display: flex !important;
    transform: translateY(110%);
    pointer-events: none;
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.3s;
}
.chat-tray.display-none {
    display: none !important;
}

.chat-tray-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.chat-tray-title {
    font-weight: 700;
    color: var(--text-muted);
}
.chat-tray-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.tray-start-btn {
    padding: 6px 16px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
    transition: all 0.2s;
}
.tray-start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.5);
}
.tray-start-btn:disabled {
    background: #334155;
    color: rgba(255,255,255,0.2);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}
.icon-btn-sm {
    background: rgba(255,255,255,0.05);
    border: none;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.icon-btn-sm:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}
.icon-btn-sm svg {
    width: 18px;
    height: 18px;
}

.chat-tray-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.chat-tray-input {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: max(env(safe-area-inset-bottom), 10px);
}
.chat-tray-input input {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 10px 16px;
    color: white;
    font-size: 0.95rem;
}

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

/* Topic Evaluation */
.glass-card-mini {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 10px;
}

.evaluation-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.eval-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.eval-btn .icon {
    font-size: 1.5rem;
}

.eval-btn span:not(.icon) {
    font-size: 0.75rem;
    font-weight: 600;
}

.eval-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

.eval-btn.selected {
    background: var(--accent-primary);
    border-color: white;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
    opacity: 1 !important;
}

.eval-btn.selected .icon {
    transform: scale(1.3);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.eval-btn.selected span:not(.icon) {
    color: white;
}

.eval-btn:disabled {
    cursor: default;
    opacity: 0.6;
}

.mode-badge-mini {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
}

.category-reveal-box {
    margin-top: 15px;
    margin-bottom: 25px; /* Added spacing below */
    padding: 12px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    text-align: center;
}

.category-reveal-box span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.category-reveal-box strong {
    font-size: 1.2rem;
    color: var(--accent-primary);
}

.indent-setting {
    position: relative;
    width: 100%;
}

.indent-setting::before {
    content: '';
    position: absolute;
    left: 8px; /* Slightly inward */
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1px;
    z-index: 1;
}

.indent-text {
    padding-left: 28px; /* Aligned with the indicator line */
    display: inline-block;
}

.opacity-50 {
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.opacity-100 {
    opacity: 1;
}

/* Deep Link & Highlighting */
.room-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.room-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

.room-item.highlight-room {
    border: 2px solid var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
    animation: highlight-pulse 2s infinite;
}

@keyframes highlight-pulse {
    0% { border-color: var(--accent-primary); box-shadow: 0 0 10px rgba(99, 102, 241, 0.3); }
    50% { border-color: var(--accent-secondary); box-shadow: 0 0 25px rgba(139, 92, 246, 0.6); }
    100% { border-color: var(--accent-primary); box-shadow: 0 0 10px rgba(99, 102, 241, 0.3); }
}

/* Premium Language Toggle */
.premium-lang-toggle {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 30px;
    padding: 4px;
    position: relative;
    width: 140px;
    height: 38px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.premium-lang-slider {
    position: absolute;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 25px;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.6);
    pointer-events: none;
    top: 4px;
    left: 4px;
}

.premium-lang-btn {
    flex: 1;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    z-index: 1;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    letter-spacing: 0.5px;
}

.premium-lang-btn:hover {
    color: rgba(255, 255, 255, 0.9);
}

.premium-lang-btn.active {
    color: #ffffff;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}



