/* ===========================================
   WebGame - Complete Redesign
   =========================================== */

:root {
    --bg-dark: #0a0f1c;
    --bg-card: #111827;
    --border: #1f2937;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.3);
    --success: #22c55e;
    --danger: #ef4444;
    --text: #f3f4f6;
    --text-muted: #9ca3af;
    --radius: 12px;
}

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

body.webgame-body,
.webgame-theme {
    height: 100%;
    background: linear-gradient(135deg, #0a0f1c 0%, #1a1f2e 100%);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* ===========================================
   Cards & Common Elements
   =========================================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.button.primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.button.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.button.secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}

.button.secondary:hover {
    background: var(--border);
}

.button.small {
    padding: 6px 12px;
    font-size: 13px;
}

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

.webgame-body input[type="text"],
.webgame-body input[type="password"],
.webgame-body input[type="email"],
.webgame-body textarea,
.customizer-modal input[type="text"],
.customizer-modal input[type="password"],
.customizer-modal input[type="email"],
.auth-card input[type="text"],
.auth-card input[type="password"],
.auth-card input[type="email"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease;
}

.webgame-body input:focus,
.webgame-body textarea:focus,
.customizer-modal input:focus,
.auth-card input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.webgame-body label,
.customizer-modal label,
.auth-card label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.feedback {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

.feedback.error {
    color: var(--danger);
}

.feedback.success {
    color: var(--success);
}

/* ===========================================
   Auth Section (State 1)
   =========================================== */

.auth-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-form .button {
    margin-top: 8px;
}

/* ===========================================
   Lobby Section (State 2)
   =========================================== */

.lobby-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.lobby-header h1 {
    font-size: 24px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 14px;
}

.lobby-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.search-bar {
    display: flex;
    gap: 8px;
}

.search-bar input {
    flex: 1;
}

/* ===========================================
   Rooms Grid
   =========================================== */

.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    flex: 1;
    align-content: start;
}

.room-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.room-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.room-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.room-card-header h3 {
    font-size: 16px;
    margin: 0;
}

.room-type-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--accent-glow);
    color: var(--accent);
    text-transform: uppercase;
}

.room-card-meta {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.room-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.room-players {
    font-size: 13px;
    color: var(--text-muted);
}

.room-lock {
    font-size: 12px;
    opacity: 0.6;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text);
}

.accordion-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(17, 24, 39, 0.55);
    margin-bottom: 12px;
    overflow: hidden;
}

.accordion-toggle {
    width: 100%;
    background: rgba(10, 15, 28, 0.85);
    color: var(--text);
    border: none;
    text-align: left;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accordion-content {
    padding: 12px;
}

/* ===========================================
   Friends & Direct Messages (Lobby)
   =========================================== */

.friends-layout {
    display: flex;
    gap: 16px;
    min-height: 520px;
    max-height: 700px;
}

.friends-sidebar {
    flex: 0 0 340px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 12px;
}

.friends-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.friends-nav-tabs {
    display: flex;
    gap: 4px;
}

.friends-tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.friends-tab-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.friends-tab-btn.active {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.4);
    color: #fff;
}

.tab-count-badge {
    font-size: 11px;
    opacity: 0.8;
}

.tab-count-highlight {
    background: var(--accent);
    color: #fff;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 10px;
}

.icon-only-btn {
    padding: 6px 10px;
    font-size: 13px;
    font-weight: bold;
}

.friends-tab-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.search-bar.compact {
    margin-bottom: 10px;
}

.search-bar.compact input {
    padding: 8px 10px;
    font-size: 13px;
}

.friends-items-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 4px;
}

.friend-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(10, 15, 28, 0.6);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.friend-card:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.35);
    transform: translateX(2px);
}

.friend-card.active {
    background: rgba(59, 130, 246, 0.22);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.friend-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #fff;
    font-size: 14px;
    flex-shrink: 0;
    text-transform: uppercase;
}

.friend-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.friend-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}

.friend-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.friend-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.friend-msg-preview {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.unread-pill {
    background: #3b82f6;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 7px;
    border-radius: 10px;
    flex-shrink: 0;
}

.new-request-box {
    background: rgba(10, 15, 28, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 12px;
}

.new-request-box h4 {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.requests-group {
    margin-bottom: 12px;
}

.requests-group h5 {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
}

.requests-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 160px;
    overflow-y: auto;
}

.request-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 10px;
    background: rgba(10, 15, 28, 0.6);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
}

.request-card-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.request-card-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.request-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.button.danger {
    background: #dc2626;
    color: #fff;
}

.button.danger:hover {
    background: #b91c1c;
}

.friends-chat-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 520px;
    padding: 16px;
}

.dm-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 440px;
    text-align: center;
    color: var(--text-muted);
    padding: 30px;
}

.dm-empty-icon {
    font-size: 48px;
    margin-bottom: 14px;
    opacity: 0.6;
}

.dm-empty-state h3 {
    font-size: 17px;
    color: var(--text);
    margin-bottom: 8px;
}

.dm-empty-state p {
    font-size: 13.5px;
    max-width: 360px;
}

.dm-active-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 480px;
}

.dm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.dm-header-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dm-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #059669);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: bold;
    color: #fff;
    text-transform: uppercase;
}

.dm-user-meta h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.dm-user-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.dm-header-actions {
    display: flex;
    gap: 6px;
}

.dm-messages-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 18px;
    background: rgba(10, 15, 28, 0.7);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    min-height: 320px;
    max-height: 440px;
}

.dm-msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.4;
    word-break: break-word;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dm-msg-self {
    align-self: flex-end;
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    color: #fff;
    border-bottom-right-radius: 2px;
}

.dm-msg-friend {
    align-self: flex-start;
    background: #1f2937;
    color: var(--text);
    border-bottom-left-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.dm-msg-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 10.5px;
    opacity: 0.75;
}

.dm-msg-english {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.4;
}

.dm-msg-native {
    font-size: 13px;
    font-weight: 400;
    font-style: italic;
    opacity: 0.9;
    line-height: 1.4;
    margin-top: 3px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 3px;
}

.dm-msg-gec {
    font-size: 11.5px;
    background: rgba(245, 158, 11, 0.15);
    border-left: 2px solid #f59e0b;
    padding: 4px 8px;
    border-radius: 0 4px 4px 0;
    color: #fde68a;
    margin-top: 3px;
}

.dm-input-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dm-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.dm-input-row textarea {
    flex: 1;
    min-height: 52px;
    max-height: 110px;
    resize: vertical;
    padding: 10px 12px;
    font-size: 13.5px;
}

.dm-input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
}

.dm-input-hint {
    opacity: 0.7;
}

/* ===========================================
   Admin Config Panel
   =========================================== */

.admin-config {
    margin-top: 8px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.admin-header-actions {
    display: flex;
    gap: 8px;
}

.admin-header h2 {
    font-size: 18px;
}

.admin-intro {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 10px;
}

.admin-group-create {
    margin-bottom: 18px;
}

.admin-group-create h3 {
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 14px;
}

.admin-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 1fr 2fr auto;
}

.admin-groups {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-group-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    background: rgba(10, 15, 28, 0.55);
}

.admin-group-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.admin-group-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-group-meta strong {
    font-size: 15px;
}

.admin-group-key {
    font-size: 12px;
    color: var(--text-muted);
    font-family: ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.admin-group-actions {
    display: flex;
    gap: 6px;
}

.admin-inline-form {
    display: grid;
    grid-template-columns: 1.2fr 1fr 2fr auto;
    gap: 8px;
    margin-bottom: 10px;
}

.admin-item-form {
    display: grid;
    grid-template-columns: 1.2fr 1.2fr 1fr 2fr auto auto;
    gap: 8px;
    margin-bottom: 8px;
}

.admin-item-row {
    background: rgba(17, 24, 39, 0.8);
}

.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

.admin-table th,
.admin-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    font-size: 12px;
}

.admin-table th {
    text-align: left;
    color: var(--text-muted);
    background: rgba(10, 15, 28, 0.85);
}

.admin-table td pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-modal {
    position: fixed;
    inset: 0;
    z-index: 2500;
    background: rgba(3, 7, 18, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.admin-modal-content {
    width: min(780px, 100%);
    max-height: 86vh;
    overflow-y: auto;
    position: relative;
}

.admin-modal-form {
    display: grid;
    gap: 10px;
}

.admin-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.admin-redis {
    margin-top: 14px;
}

.admin-pre {
    margin: 0;
    padding: 10px;
    border-radius: 8px;
    background: rgba(10, 15, 28, 0.9);
    border: 1px solid var(--border);
    color: var(--text);
    max-height: 360px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
}

/* ===========================================
   Game Section (State 3)
   =========================================== */

.game-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.room-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.room-info h2 {
    font-size: 18px;
    margin: 0;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 20px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
}

.status.connected .status-dot {
    background: var(--success);
}

.game-container {
    flex: 1;
    display: flex;
    gap: 16px;
    padding: 16px;
    min-height: 0;
    overflow: hidden;
}

.game-sidebar {
    width: min(380px, 32vw);
    min-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.game-sidebar h3 {
    font-size: 14px;
    margin: 0 0 12px 0;
    color: var(--text-muted);
}

.player-config .form-row {
    margin-bottom: 12px;
}

.character-select {
    display: flex;
    gap: 8px;
}

.character-option {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s ease;
}

.character-option.selected {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.character-option.locked {
    opacity: 0.55;
    cursor: not-allowed;
    border-color: var(--border);
    background: var(--bg-dark);
}

.char-icon {
    width: 12px;
    height: 24px;
    border-radius: 3px;
}

.char-icon.male {
    background: linear-gradient(to bottom, #3b82f6, #1d4ed8);
}

.char-icon.female {
    background: linear-gradient(to bottom, #ec4899, #be185d);
}

.players-list {
    flex: 1;
    min-height: 100px;
    overflow-y: auto;
}

#playersList {
    font-size: 13px;
}

#playersList .player-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

#playersList .player-item.clickable {
    cursor: pointer;
    border-radius: 8px;
    padding: 8px;
    margin: 2px 0;
    transition: background-color 0.15s ease;
}

#playersList .player-item.clickable:hover {
    background: rgba(59, 130, 246, 0.12);
}

#playersList .player-item:last-child {
    border-bottom: none;
}

.player-badge {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.chat-box {
    flex: 2;
    display: flex;
    flex-direction: column;
    min-height: 280px;
    padding-inline: 0;
}

.chat-box > h3,
.chat-language-selector,
.chat-input {
    margin-inline: 16px;
}

.chat-language-selector {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.chat-language-title {
    font-weight: 600;
}

.chat-language-options {
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.language-switch {
    position: relative;
    display: inline-flex;
    margin: 0;
    cursor: pointer;
}

.language-switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.language-switch-track {
    position: relative;
    width: 38px;
    height: 22px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-dark);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.language-switch-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.language-switch input:checked + .language-switch-track {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.language-switch input:checked + .language-switch-track::after {
    transform: translateX(16px);
    background: var(--accent);
}

.language-switch input:focus-visible + .language-switch-track {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

#chatMessages {
    flex: 1;
    min-height: 180px;
    max-height: none;
    overflow-y: auto;
    background: var(--bg-dark);
    border-radius: 0;
    padding: 12px 16px;
    margin-bottom: 12px;
    font-size: 13px;
}

#chatMessages .msg {
    margin-bottom: 4px;
}

#chatMessages .msg-name {
    color: var(--accent);
    font-weight: 600;
}

#chatMessages .msg-translated {
    color: #60a5fa;
}

#chatMessages .msg-original {
    color: var(--text-muted);
    font-size: 12px;
}

#chatMessages .system-msg {
    color: var(--text-muted);
    font-style: italic;
    font-size: 12px;
}

#chatMessages .msg-pending {
    opacity: 0.7;
}

#chatMessages .msg-spinner {
    display: inline-block;
    animation: spin-emoji 1.2s linear infinite;
    font-size: 11px;
}

@keyframes spin-emoji {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

#chatMessages .msg-error .msg-translated {
    color: var(--danger, #ef4444);
}

#chatMessages .msg-error-text {
    font-size: 11px;
    color: var(--danger, #ef4444);
    margin-top: 2px;
}

.chat-input {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.chat-input-field {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

.chat-input textarea {
    width: 100%;
    resize: none;
}

.chat-limit-counter {
    margin-top: 5px;
    padding-inline: 4px;
    color: #ef4444;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
}

.chat-limit-counter[hidden] {
    display: none !important;
}

/* ===========================================
   Game World
   =========================================== */

.game-world {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.world-hud {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 13px;
}

.hud-item {
    color: var(--text-muted);
}

.hud-item strong {
    color: var(--text);
}

#worldViewport {
    position: relative;
    flex: 0 0 auto;
    margin: auto;
    overflow: hidden;
}

#world {
    position: relative;
    background-color: #000;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    margin: 0;
    transform-origin: top left;
    will-change: transform;
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    z-index: 1;
}

#worldEntities {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
}

.world-overlay {
    position: absolute;
    inset: 0;
    cursor: crosshair;
    z-index: 2;
}

/* Character Sprite Rendering */
.player-box {
    position: absolute;
    transform: translate(-50%, -100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    transition: left 0.1s linear, top 0.1s linear;
    z-index: 100;
}

.player-shadow {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 12px;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0) 75%);
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
}

.player-box.self .player-shadow {
    width: 52px;
    height: 16px;
    background: radial-gradient(ellipse at center, rgba(253, 224, 71, 0.55) 0%, rgba(0, 0, 0, 0.35) 45%, rgba(0, 0, 0, 0) 75%);
}

.character-sprite {
    display: block;
    width: 60px;
    height: 85px; /* 120x170 aspect ratio (85 / 60 = 1.416667) */
    overflow: hidden;
    flex-shrink: 0;
    z-index: 1;
    pointer-events: none;
}

.character-sprite image,
.sprite-layer {
    width: 840px !important;
    height: 680px !important;
    max-width: none !important;
    max-height: none !important;
    pointer-events: none;
}

.player-name {
    margin-top: 2px;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.82);
    color: #ffffff;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

.player-box.self .player-name {
    background: rgba(253, 224, 71, 0.25);
    color: #fde047;
    border: 1px solid rgba(253, 224, 71, 0.5);
}

.target-marker {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--accent);
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: ping 0.7s ease-out infinite;
}

@keyframes ping {
    0% {
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0;
    }
}

/* ===========================================
   Focus Windows
   =========================================== */

.focus-layer {
    position: fixed;
    inset: 0;
    z-index: 1200;
    pointer-events: none;
}

.focus-window {
    position: fixed;
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    background: #fff;
    color: #111827;
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
    overflow: hidden;
    pointer-events: auto;
}

.focus-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    cursor: grab;
    user-select: none;
}

.focus-header:active {
    cursor: grabbing;
}

.focus-name {
    background: transparent;
    border: none;
    color: #111827;
    font-weight: 700;
    font-size: 14px;
    text-align: left;
    max-width: calc(100% - 34px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.focus-close {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 999px;
    background: #e11d48;
    color: #fff;
    font-size: 16px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
}

.focus-body {
    flex: 1;
    display: grid;
    grid-template-columns: 74px 1fr;
    gap: 10px;
    padding: 10px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.focus-avatar {
    width: 58px;
    height: 58px;
    border-radius: 999px;
    border: 2px solid #e2e8f0;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-top: 3px;
    cursor: pointer;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.focus-avatar .character-sprite {
    width: 48px;
    height: 68px;
    margin-top: 12px;
}

.focus-avatar .character-sprite::after,
.focus-avatar .character-sprite::before {
    display: none;
}

.focus-messages {
    min-width: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 2px;
}

.focus-empty {
    color: #6b7280;
    font-size: 12px;
    font-style: italic;
    margin-top: 6px;
}

.focus-message {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 9px;
}

.focus-message-main {
    color: #111827;
    font-size: 13px;
    line-height: 1.3;
    font-weight: 600;
    word-break: break-word;
}

.focus-message-original {
    color: #6b7280;
    font-size: 12px;
    margin-top: 4px;
    word-break: break-word;
}

.focus-message-main a,
.focus-message-original a {
    color: #2563eb;
    text-decoration: underline;
}

.focus-message-actions {
    margin-top: 6px;
    display: flex;
    gap: 6px;
}

.focus-message-actions button {
    border: 1px solid #d1d5db;
    border-radius: 999px;
    background: #fff;
    color: #374151;
    font-size: 11px;
    padding: 3px 8px;
    cursor: pointer;
}

.focus-message-actions button:hover {
    background: #f3f4f6;
}

/* ===========================================
   Character Profile Modal
   =========================================== */

.profile-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(3, 7, 18, 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.profile-modal-content {
    width: min(920px, 100%);
    max-height: min(86vh, 820px);
    overflow-y: auto;
    position: relative;
    background: #fff;
    color: #0f172a;
    border-radius: 16px;
    padding: 28px;
}

.profile-modal-close {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 999px;
    background: #f43f5e;
    color: #fff;
    font-size: 22px;
    line-height: 34px;
    text-align: center;
    cursor: pointer;
}

.profile-header-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.profile-avatar-box {
    width: 68px;
    height: 68px;
    border-radius: 999px;
    border: 2px solid #e2e8f0;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.profile-avatar-box .character-sprite {
    width: 52px;
    height: 74px;
    margin-top: 14px;
}

.profile-avatar-box .character-sprite::after,
.profile-avatar-box .character-sprite::before {
    display: none;
}

.profile-meta {
    color: #64748b;
    margin-bottom: 0;
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.profile-card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    background: #f8fafc;
}

.profile-card h3 {
    margin: 0 0 8px;
    color: #0f172a;
}

.profile-card p {
    margin: 4px 0;
}

.profile-loading,
.profile-error {
    color: #475569;
}

/* ===========================================
   Responsive
   =========================================== */

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

    .admin-grid,
    .admin-inline-form,
    .admin-item-form {
        grid-template-columns: 1fr;
    }

    .game-sidebar {
        width: 100%;
        min-width: 0;
        flex-direction: row;
        flex-wrap: wrap;
        overflow-x: auto;
        max-height: 42vh;
    }

    .game-sidebar .card {
        flex: 1;
        min-width: 200px;
    }

    .game-world {
        min-height: 300px;
    }

    .focus-window {
        max-width: calc(100vw - 16px);
    }

    .focus-body {
        grid-template-columns: 58px 1fr;
    }

    .focus-avatar {
        width: 48px;
        height: 48px;
    }

    .focus-avatar-character {
        width: 18px;
        height: 34px;
    }

    .profile-modal {
        padding: 10px;
    }

    .profile-modal-content {
        padding: 20px 16px;
    }

    .profile-grid {
        grid-template-columns: 1fr;
    }
}

/* ===========================================
   In-Game DM Notification Toast
   =========================================== */

.game-dm-notification-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    pointer-events: none;
    max-width: 90vw;
    width: 560px;
}

.game-dm-toast {
    pointer-events: auto;
    width: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid #3b82f6;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65), 0 0 18px rgba(59, 130, 246, 0.35);
    padding: 12px 16px;
    animation: toastSlideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #ffffff;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes toastSlideDown {
    from {
        opacity: 0;
        transform: translateY(-24px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.game-dm-toast-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 6px;
}

.game-dm-toast-user {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.game-dm-toast-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #2563eb;
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 999px;
    flex-shrink: 0;
}

.game-dm-toast-sender {
    font-size: 14px;
    font-weight: 700;
    color: #93c5fd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-dm-toast-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.15s ease, background-color 0.15s ease;
    flex-shrink: 0;
}

.game-dm-toast-close:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.1);
}

.game-dm-toast-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.game-dm-toast-english {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.4;
    word-break: break-word;
}

.game-dm-toast-native {
    font-size: 13px;
    font-weight: 400;
    font-style: italic;
    color: #cbd5e1;
    line-height: 1.4;
    margin-top: 2px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 4px;
    word-break: break-word;
}

/* ===========================================
   Home Live Game Embedded Section
   =========================================== */

.cap-livegame-section {
    padding: 3rem 1rem 4rem;
    background: radial-gradient(circle at 50% 20%, rgba(30, 58, 138, 0.15), transparent 70%),
                linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
    position: relative;
    z-index: 10;
}

.cap-livegame-container {
    max-width: 960px;
    margin: 0 auto;
}

.cap-livegame-header {
    text-align: center;
    margin-bottom: 2rem;
}

.cap-livegame-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.cap-livegame-subtitle {
    font-size: 1.05rem;
    color: #475569;
    max-width: 640px;
    margin: 0 auto;
    line-height: 1.5;
}

.home-game-card {
    position: relative;
    background: #0f172a;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px -15px rgba(15, 23, 42, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.home-game-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-wrap: wrap;
    gap: 10px;
}

.home-game-status-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.livegame-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #94a3b8;
    font-weight: 500;
}

.livegame-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #eab308;
    box-shadow: 0 0 8px rgba(234, 179, 8, 0.5);
}

.livegame-status.connected .status-dot {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.livegame-status.connected {
    color: #4ade80;
}

.home-online-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
}

.btn-cap-customize {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #0284c7;
    color: #ffffff;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    padding: 4px 16px 4px 6px;
    border-radius: 9999px;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: var(--cap-font-heading, 'Outfit', system-ui, sans-serif);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-cap-customize:hover {
    background: #0369a1;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.5);
}

.btn-cap-customize-avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1.5px solid rgba(255, 255, 255, 0.75);
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2);
}

.btn-cap-customize-avatar .character-sprite {
    width: 33px;
    height: 47px;
    margin-top: 16px;
}

.btn-cap-customize-avatar .character-sprite::after,
.btn-cap-customize-avatar .character-sprite::before {
    display: none;
}

/* Home Viewport & Floating Elements */
.home-world-viewport {
    position: relative;
    width: 100%;
    height: 540px;
    background: #020617;
    overflow: hidden;
    user-select: none;
}

.home-world-viewport #world {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    transition: transform 0.05s linear;
}

/* Floating Ephemeral Toast Messages (matching mobile/game UI) */
.home-floating-chat {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 30;
    pointer-events: none;
}

.home-chat-toast-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.home-chat-toast {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 24px;
    padding: 8px 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    color: #0f172a;
    pointer-events: auto;
    animation: toastSlideDown 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.home-chat-toast.fading-out {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    pointer-events: none;
}

.toast-avatar-col {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    background: #f1f5f9;
    border: 1.5px solid #0284c7;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

.toast-avatar-canvas {
    width: 38px;
    height: 38px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.toast-content-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.toast-author-line {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    line-height: 1.35;
    white-space: normal;
    word-break: break-word;
}

.toast-author-line strong {
    font-weight: 700;
    color: #0284c7;
    margin-right: 4px;
}

.toast-sub-line {
    font-size: 11px;
    font-style: italic;
    color: #64748b;
    line-height: 1.3;
}

.home-chat-toast-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 2px;
}

.btn-home-view-all {
    background: #0284c7 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
    padding: 2px 16px !important;
    border-radius: 9999px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    font-family: var(--cap-font-heading, 'Outfit', system-ui, sans-serif) !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    box-shadow: 0 4px 16px rgba(2, 132, 199, 0.45) !important;
    pointer-events: auto !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.btn-home-view-all:hover {
    background: #0369a1 !important;
    border-color: #ffffff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.6) !important;
}

.home-move-hint {
    position: absolute;
    bottom: 12px;
    right: 14px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 8px;
    pointer-events: none;
    z-index: 20;
}

.home-map-controls {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.home-zoom-shell,
.home-audio-shell {
    position: relative;
}

.home-zoom-toggle,
.home-audio-toggle,
.home-zoom-control {
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(15, 23, 42, 0.82);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.home-zoom-toggle,
.home-audio-toggle {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 12px;
    color: #ffffff;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.home-zoom-toggle:hover,
.home-zoom-toggle:focus-visible,
.home-zoom-toggle[aria-expanded="true"],
.home-audio-toggle:hover,
.home-audio-toggle:focus-visible {
    background: #0284c7;
    outline: none;
}

.home-zoom-toggle:active,
.home-audio-toggle:active {
    transform: scale(0.96);
}

.home-audio-toggle.is-muted {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.18);
}

.home-audio-toggle.is-muted:hover,
.home-audio-toggle.is-muted:focus-visible {
    background: #dc2626;
    color: #ffffff;
}

.home-audio-toggle .audio-icon-active {
    display: block;
}

.home-audio-toggle .audio-icon-muted {
    display: none;
}

.home-audio-toggle.is-muted .audio-icon-active {
    display: none;
}

.home-audio-toggle.is-muted .audio-icon-muted {
    display: block;
}

.home-audio-toggle svg[hidden],
.home-audio-toggle [hidden] {
    display: none !important;
}

.home-zoom-control {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 8px 7px 7px;
    border-radius: 14px;
}

.home-zoom-control[hidden] {
    display: none;
}

.home-zoom-button {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font: 700 20px/1 var(--cap-font-heading, 'Outfit', system-ui, sans-serif);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.home-zoom-button:hover,
.home-zoom-button:focus-visible {
    background: #0284c7;
    outline: none;
    transform: scale(1.05);
}

.home-zoom-slider {
    width: 24px;
    height: 132px;
    margin: 0;
    writing-mode: vertical-lr;
    direction: rtl;
    accent-color: #38bdf8;
    cursor: pointer;
}

.home-zoom-value {
    min-width: 34px;
    color: #e2e8f0;
    font: 700 10px/1 var(--cap-font-heading, 'Outfit', system-ui, sans-serif);
    text-align: center;
}

/* Home Chat Pill Bar (Modern Pill Design matching screenshot) */
.home-chat-pill-bar {
    display: flex !important;
    align-items: center !important;
    flex-direction: row !important;
    gap: 10px !important;
    padding: 12px 16px !important;
    background: #0f172a !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.home-chat-pill-bar > .chat-input-field,
.home-chat-history-footer > .chat-input-field {
    flex: 1 1 auto;
}

.home-chat-pill-input-wrap {
    flex: 1 1 auto !important;
    display: flex !important;
    align-items: center !important;
    background: #ffffff !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 9999px !important;
    padding: 3px 6px 3px 16px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
    box-sizing: border-box !important;
}

.home-chat-pill-input-wrap:focus-within {
    border-color: #cbd5e1 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    outline: none !important;
}

.home-chat-pill-input-wrap input {
    flex: 1 1 auto !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    font-size: 14px !important;
    font-family: var(--cap-font-body, 'Inter', system-ui, sans-serif) !important;
    color: #0f172a !important;
    padding: 8px 0 !important;
}

.home-chat-pill-input-wrap input:focus,
.home-chat-pill-input-wrap input:focus-visible {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.home-chat-pill-input-wrap input::placeholder {
    color: #94a3b8 !important;
}

.btn-chat-lang-badge {
    background: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    padding: 4px 9px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    font-family: var(--cap-font-heading, 'Outfit', system-ui, sans-serif) !important;
    cursor: pointer !important;
    text-transform: uppercase !important;
    margin-right: 4px !important;
    flex-shrink: 0 !important;
    transition: all 0.12s ease !important;
}

.btn-chat-lang-badge:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}

.btn-home-send-circle {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    background: #0284c7 !important;
    color: #ffffff !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.45) !important;
    flex-shrink: 0 !important;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.btn-home-send-circle:hover {
    background: #0369a1 !important;
    transform: scale(1.06) !important;
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.6) !important;
}

.btn-home-send-circle:active {
    transform: scale(0.96) !important;
}

/* Chat History Modal (Expanded & Styled as Native Capiverso App Chat) */
.home-chat-history-modal {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    border-radius: 18px;
}

.home-chat-history-modal.hidden {
    display: none !important;
}

.home-chat-history-content {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    width: 95%;
    max-width: 680px;
    height: 90%;
    max-height: 620px;
    min-height: 480px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.home-chat-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
}

.home-chat-history-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    font-family: 'Outfit', -apple-system, sans-serif;
    color: #0f172a;
}

.home-chat-history-list {
    flex: 1;
    min-height: 0;
    padding: 24px 20px 20px 20px;
    overflow-y: auto;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

/* History Chat Rows */
.history-chat-row {
    display: flex;
    align-items: flex-start;
    width: 100%;
    position: relative;
}

.history-chat-row.history-self {
    flex-direction: row-reverse;
}

.history-chat-row.history-other {
    flex-direction: row;
}

.history-avatar-col {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    overflow: hidden;
    background: #ffffff;
    border: 2.5px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 3;
    margin-top: 2px;
}

.history-other .history-avatar-col {
    margin-right: -14px;
}

.history-self .history-avatar-col {
    margin-left: -14px;
    border-color: #ffffff;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25), 0 0 0 1px rgba(2, 132, 199, 0.18);
}

.history-avatar-canvas {
    width: 58px;
    height: 58px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.history-bubble-col {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    position: relative;
    z-index: 1;
}

.history-self .history-bubble-col {
    align-items: flex-end;
}

.history-other .history-bubble-col {
    align-items: flex-start;
}

.history-bubble {
    position: relative;
    padding: 14px 18px;
    font-family: 'Inter', -apple-system, sans-serif;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Bubble nuances */
.history-self .history-bubble {
    background: #eaf4fc;
    border: 1px solid #d4e7f8;
    border-radius: 20px 6px 20px 20px;
    color: #0f172a;
    padding-right: 22px;
    padding-left: 18px;
}

.history-other .history-bubble {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px 20px 20px 20px;
    color: #0f172a;
    padding-left: 22px;
    padding-right: 18px;
}

/* Play button floating between bubble box and outside */
.btn-bubble-play {
    position: absolute;
    top: -13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    color: #334155;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.15s ease;
    padding: 0;
    z-index: 4;
}

.history-other .btn-bubble-play {
    right: 16px;
}

.history-self .btn-bubble-play {
    left: 16px;
}

.btn-bubble-play:hover {
    background: #0284c7;
    border-color: #0284c7;
    color: #ffffff;
    transform: scale(1.12);
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
}

.history-author-line {
    font-size: 12.5px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 3px;
}

.history-main-text {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.45;
    color: #0f172a;
    word-break: break-word;
}

.history-sub-text {
    font-size: 13px;
    font-style: italic;
    color: #64748b;
    margin-top: 5px;
    line-height: 1.35;
    word-break: break-word;
}

.history-time-line {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    padding: 0 4px;
}

.home-chat-history-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

@keyframes toastSlideDown {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* In-Box Customizer for Home Card */
.home-game-card .customizer-modal {
    position: absolute;
    inset: 0;
    border-radius: 18px;
    z-index: 100;
}

.home-game-card .customizer-modal-content {
    max-height: 100%;
    max-width: 100%;
    border-radius: 18px;
}

/* ===========================================
   Character Customizer Modal (Light White Theme)
   =========================================== */

.customizer-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 16px;
    animation: customizerModalFade 0.2s ease-out;
}

.customizer-modal.hidden {
    display: none !important;
}

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

.customizer-modal-content {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.05);
    color: #0f172a;
    overflow: hidden;
}

.customizer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.customizer-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    font-family: 'Outfit', -apple-system, sans-serif;
    color: #0f172a;
    margin: 0;
}

.customizer-close-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #64748b;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.customizer-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.customizer-guest-notice {
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    grid-column: 1 / -1;
    margin: 0 0 4px 0;
    box-sizing: border-box;
    width: 100%;
}

.customizer-notice-icon {
    font-size: 20px;
    line-height: 1.2;
    flex-shrink: 0;
}

.customizer-notice-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}

.customizer-notice-content p {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: #000000;
    text-align: center;
}

.btn-customizer-auth-toggle {
    background: #78af1a;
    color: #ffffff;
    border: none;
    padding: 6px 18px;
    border-radius: 9999px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(120, 175, 26, 0.25);
    transition: background 0.15s ease;
    margin: 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-customizer-auth-toggle:hover {
    background: #5f8c15;
}

.customizer-user-badge {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 14px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12.5px;
    color: #065f46;
    grid-column: 1 / -1;
    margin: 0 0 4px 0;
    box-sizing: border-box;
    width: 100%;
}

.btn-customizer-logout {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
    border-radius: 9999px;
    padding: 4px 14px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-customizer-logout:hover {
    background: #fecaca;
    color: #991b1b;
}

.customizer-auth-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    grid-column: 1 / -1;
    margin: 0 0 4px 0;
    box-sizing: border-box;
    width: 100%;
}

.customizer-auth-step label {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
    display: block;
}

.customizer-auth-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.customizer-auth-input-row input {
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 9999px;
    color: #0f172a;
    padding: 7px 14px;
    font-size: 12.5px;
    flex: 1;
    outline: none;
    transition: border-color 0.15s ease;
}

.customizer-auth-input-row input:focus {
    border-color: #0284c7;
}

.btn-customizer-send-code,
.btn-customizer-verify-code {
    background: #0284c7;
    color: #ffffff;
    border: none;
    padding: 7px 18px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
    transition: background 0.15s ease;
}

.btn-customizer-send-code:hover,
.btn-customizer-verify-code:hover {
    background: #0369a1;
}

.btn-customizer-back-email {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
    padding: 7px 14px;
    border-radius: 9999px;
    font-size: 11.5px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.btn-customizer-back-email:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.customizer-auth-feedback {
    font-size: 11.5px;
    line-height: 1.3;
    font-weight: 500;
}

.customizer-auth-feedback.success {
    color: #16a34a;
}

.customizer-auth-feedback.error {
    color: #dc2626;
}

.customizer-body {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 20px;
    padding: 22px;
    overflow-y: auto;
    background: #ffffff;
}

.customizer-preview-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.customizer-name-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.customizer-name-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    align-self: flex-start;
    padding-left: 2px;
}

.customizer-name-input-row {
    width: 100%;
    position: relative;
}

.customizer-name-input {
    width: 100%;
    box-sizing: border-box;
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    color: #0f172a;
    font-weight: 700;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 9999px;
    font-family: 'Outfit', -apple-system, sans-serif;
    text-align: center;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.customizer-name-input:focus {
    background: #ffffff;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.customizer-name-input::placeholder {
    color: #94a3b8;
    font-weight: 500;
}

.customizer-name-feedback {
    font-size: 11px;
    line-height: 1.3;
    text-align: center;
    width: 100%;
    word-break: break-word;
    color: #ef4444;
    font-weight: 600;
    margin-top: 2px;
}

.customizer-name-feedback.success {
    color: #10b981;
}

.customizer-name-feedback.hidden {
    display: none;
}

.customizer-player-name-badge {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    font-weight: 700;
    font-size: 13px;
    padding: 5px 16px;
    border-radius: 9999px;
    font-family: 'Outfit', -apple-system, sans-serif;
    text-align: center;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.customizer-canvas-wrap {
    width: 140px;
    height: 190px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.customizer-canvas-wrap canvas {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.customizer-gender-toggle {
    display: flex;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 9999px;
    padding: 3px;
    width: 100%;
    gap: 2px;
}

.gender-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #64748b;
    padding: 7px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.gender-btn.active {
    background: #0284c7;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.35);
}

.customizer-slots-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.customizer-slot-row {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.customizer-slot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.customizer-slot-label {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    font-family: 'Outfit', -apple-system, sans-serif;
}

.customizer-slot-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.slot-style-select {
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 9999px;
    color: #0f172a;
    padding: 6px 14px;
    font-size: 12.5px;
    outline: none;
    cursor: pointer;
    min-width: 130px;
    font-weight: 500;
    transition: border-color 0.15s ease;
}

.slot-style-select:focus {
    border-color: #0284c7;
}

.slot-color-palette {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.color-swatch:hover {
    transform: scale(1.2);
}

.color-swatch.active {
    border-color: #0284c7;
    transform: scale(1.25);
    box-shadow: 0 0 0 2px #ffffff, 0 0 8px rgba(2, 132, 199, 0.6);
}

.customizer-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 22px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
}

.btn-customizer-save {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #ffffff;
    border: none;
    padding: 9px 26px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.35);
    transition: all 0.15s ease;
}

.btn-customizer-save:hover {
    background: linear-gradient(135deg, #16a34a, #15803d);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.4);
}

.btn-customizer-cancel {
    background: #ef4444;
    color: #ffffff;
    border: none;
    padding: 9px 24px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.28);
    transition: all 0.15s ease;
}

.btn-customizer-cancel:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
}

@media (max-width: 640px) {
    .customizer-body {
        grid-template-columns: 1fr;
    }
    .customizer-preview-col {
        flex-direction: column;
        justify-content: center;
    }

    /* Topbar & Customize button adjustments to fit on single line */
    .home-game-topbar {
        padding: 8px 12px;
        flex-wrap: nowrap;
        gap: 8px;
    }
    .home-game-status-group {
        gap: 6px;
        min-width: 0;
        flex-shrink: 1;
    }
    .livegame-status {
        font-size: 11.5px;
        gap: 4px;
        white-space: nowrap;
    }
    .livegame-status .status-dot {
        width: 7px;
        height: 7px;
    }
    .home-online-badge {
        font-size: 11px;
        padding: 2px 7px;
        white-space: nowrap;
    }
    .btn-cap-customize {
        flex-shrink: 1;
        min-width: 0;
        padding: 3px 10px 3px 4px;
        gap: 6px;
        font-size: 0.75rem;
        box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35);
        white-space: nowrap;
    }
    .btn-cap-customize-avatar {
        width: 22px;
        height: 22px;
        border-width: 1px;
        flex-shrink: 0;
    }
    .btn-cap-customize-avatar .character-sprite {
        width: 23px;
        height: 33px;
        margin-top: 11px;
    }
    .btn-cap-customize-label {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }

    /* Increase game area vertically by 100px (320px -> 420px) */
    .home-world-viewport {
        height: 420px;
    }

    /* Reduce zoom and audio buttons */
    .home-map-controls {
        top: 10px;
        right: 10px;
        gap: 6px;
    }
    .home-zoom-toggle,
    .home-audio-toggle {
        width: 30px;
        height: 30px;
        border-radius: 8px;
    }
    .home-zoom-toggle svg,
    .home-audio-toggle svg {
        width: 15px;
        height: 15px;
    }
    .home-zoom-control {
        right: 0;
        top: calc(100% + 6px);
        padding: 5px 4px 4px;
        border-radius: 10px;
        gap: 5px;
    }
    .home-zoom-button {
        width: 24px;
        height: 24px;
        font-size: 15px;
        border-radius: 6px;
    }
    .home-zoom-slider {
        height: 80px;
        width: 20px;
    }
    .home-zoom-value {
        min-width: 28px;
        font-size: 9px;
    }

    /* Vertically compact "View all messages" button with 2px white border */
    .btn-home-view-all {
        padding: 2px 14px !important;
        font-size: 12px !important;
        line-height: 1.2 !important;
        border: 2px solid #ffffff !important;
        gap: 6px !important;
    }

    /* Chat History Modal (View all messages) mobile font and bubble reductions */
    .home-chat-history-content {
        width: 96%;
        height: 94%;
        max-height: 94%;
        min-height: 360px;
        border-radius: 16px;
    }
    .home-chat-history-header {
        padding: 10px 14px;
    }
    .home-chat-history-header h4 {
        font-size: 13.5px;
    }
    .home-chat-history-list {
        padding: 14px 10px 12px 10px;
        gap: 12px;
    }
    .history-avatar-col {
        width: 38px;
        height: 38px;
        border-width: 2px;
        margin-top: 1px;
    }
    .history-avatar-canvas {
        width: 38px;
        height: 38px;
    }
    .history-other .history-avatar-col {
        margin-right: -10px;
    }
    .history-self .history-avatar-col {
        margin-left: -10px;
    }
    .history-bubble-col {
        max-width: 84%;
    }
    .history-bubble {
        padding: 8px 12px;
    }
    .history-self .history-bubble {
        padding-right: 14px;
        padding-left: 10px;
        border-radius: 16px 4px 16px 16px;
    }
    .history-other .history-bubble {
        padding-left: 14px;
        padding-right: 10px;
        border-radius: 4px 16px 16px 16px;
    }
    .btn-bubble-play {
        width: 20px;
        height: 20px;
        top: -9px;
    }
    .btn-bubble-play svg {
        width: 10px;
        height: 10px;
    }
    .history-other .btn-bubble-play {
        right: 12px;
    }
    .history-self .btn-bubble-play {
        left: 12px;
    }
    .history-author-line {
        font-size: 11px;
        margin-bottom: 2px;
    }
    .history-main-text {
        font-size: 12px;
        line-height: 1.35;
    }
    .history-sub-text {
        font-size: 11px;
        margin-top: 3px;
        line-height: 1.3;
    }
    .history-time-line {
        font-size: 9.5px;
        margin-top: 2px;
        padding: 0 2px;
    }
    .home-chat-history-footer {
        padding: 8px 10px;
        gap: 8px;
    }
    .home-chat-history-footer .home-chat-pill-input-wrap input {
        font-size: 12.5px !important;
        padding: 6px 0 !important;
    }
}

@media (max-width: 380px) {
    .home-game-topbar {
        padding: 6px 8px;
        gap: 6px;
    }
    .livegame-status {
        font-size: 11px;
    }
    .home-online-badge {
        font-size: 10.5px;
        padding: 2px 5px;
    }
    .btn-cap-customize {
        padding: 2px 8px 2px 3px;
        font-size: 0.72rem;
    }
}
