html {
    font-size: 17.5px;
}

:root {
    /* Accent colors (Space & Warm Palette) */
    --primary: #C9A0DC;     /* Wisteria (藤色) */
    --primary-dark: #86608E; /* Aster (アスター) */
    --secondary: #FFCCBB;    /* Pale Salmon (ペールサーモン) */

    /* Extended Palette */
    --color-creme: #FFFDD0;  /* Cream */
    --color-horizon: #A6D4FF; /* Horizon Blue */
    --color-peony: #E2586A;  /* Peony */
    --color-baby: #F4C2C2;   /* Baby Pink */

    /* SafeKids Premium Modern Theme (#1A0F2E) */
    --bg-color: #1a0f2e;
    --card-bg: rgba(255, 255, 255, 0.05);
    --glass-bg: rgba(26, 15, 46, 0.75);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(201, 160, 220, 0.2);
    --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.6);

    /* Chat Bubbles (Premium Style) */
    --chat-bubble-received-bg: rgba(255, 255, 255, 0.08);
    --chat-bubble-sent-bg: linear-gradient(135deg, #4f2a55, var(--primary-dark));
    --chat-bubble-text: #ffffff;
}

html.theme-dark {
    --bg-color: #0b0c10;
    --card-bg: rgba(255, 253, 208, 0.05);
    --glass-bg: rgba(11, 12, 16, 0.85);
    --text-main: #f0f2f5;
    --text-muted: #a0aab5;
    --border: rgba(166, 212, 255, 0.1);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --chat-bubble-received-bg: #262626;
    --chat-bubble-sent-bg: #2d235c;
    --chat-bubble-text: #ffffff;
}

html.theme-light {
    --bg-color: #f4f4f5;
    --card-bg: rgba(255, 255, 255, 0.9);
    --glass-bg: rgba(255, 255, 255, 0.9);
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: rgba(0, 0, 0, 0.06);
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    --chat-bubble-received-bg: #f1f5f9;
    --chat-bubble-sent-bg: #ede9fe;
    --chat-bubble-text: #000000;
}

/* Respect system light / dark preference ONLY if theme-system is active */
@media (prefers-color-scheme: light) {
    html.theme-system {
        --bg-color: #f4f4f5;
        --card-bg: rgba(255, 255, 255, 0.9);
        --glass-bg: rgba(255, 255, 255, 0.9);
        --text-main: #111827;
        --text-muted: #6b7280;
        --border: rgba(0, 0, 0, 0.06);
        --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
        --chat-bubble-received-bg: #f1f5f9;
        --chat-bubble-sent-bg: #ede9fe;
        --chat-bubble-text: #000000;
    }
}

@media (prefers-color-scheme: dark) {
    html.theme-system {
        --bg-color: #0b0c10;
        --card-bg: rgba(255, 253, 208, 0.05);
        --glass-bg: rgba(11, 12, 16, 0.85);
        --text-main: #f0f2f5;
        --text-muted: #a0aab5;
        --border: rgba(166, 212, 255, 0.1);
        --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
        --chat-bubble-received-bg: #262626;
        --chat-bubble-sent-bg: #2d235c;
        --chat-bubble-text: #ffffff;
    }
}

html.theme-light .glass {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

html.theme-light .bottom-nav {
    background: rgba(255, 255, 255, 0.92);
}

html.theme-light .voice-call-overlay {
    background: rgba(15, 23, 42, 0.96);
    color: #f9fafb;
}

@media (prefers-color-scheme: light) {
    html.theme-system .glass {
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }

    html.theme-system .bottom-nav {
        background: rgba(255, 255, 255, 0.92);
    }

    html.theme-system .voice-call-overlay {
        background: rgba(15, 23, 42, 0.96);
        color: #f9fafb;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'M PLUS Rounded 1c', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    width: 100%;
    position: relative;
    padding-bottom: calc(75px + env(safe-area-inset-bottom));
    /* Space for bottom nav + safe area */
}

/* Glassmorphism Effect */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: 20px;
}

/* Layout */
.container {
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    padding: 0 10px;
    position: relative;
    overflow-x: clip;
}

.header {
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.header h1 {
    font-size: 1.25rem;
    /* Reduced from 1.5rem to prevent wrapping */
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary), var(--color-horizon));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 10px rgba(201, 160, 220, 0.3);
    white-space: nowrap;
}

/* Adjust title for Japanese to be even smaller to fit */
html[lang="ja"] .header h1 {
    font-size: 1.15rem;
}

/* Feed Moments */
.moment-card {
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    transition: transform 0.2s;
}

.moment-card:active {
    transform: scale(0.98);
}

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

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    border: 2px solid white;
    background-color: var(--card-bg);
}

.user-meta h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.user-meta span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.moment-content {
    font-size: 1rem;
    margin-bottom: 12px;
}

.moment-actions {
    display: flex;
    gap: 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateZ(0);
    width: 100%;
    max-width: 600px;
    height: 65px;
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    justify-content: space-around;
    align-items: center;
    /* Ultimate z-index to stay above all ad overlays */
    z-index: 2147483647 !important;
    pointer-events: auto !important;
    box-sizing: content-box;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    /* Slightly reduced */
    cursor: pointer;
    transition: color 0.3s;
    white-space: nowrap;
    /* Prevent wrapping labels */
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 1.4rem;
    margin-bottom: 2px;
}

/* Discovery Page */
.match-card {
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    margin-top: 40px;
}

.match-avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    margin-bottom: 16px;
    border: 4px solid var(--primary);
    background-color: var(--card-bg);
}

.match-tags {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 12px 0;
}

.tag {
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 500;
}

button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    width: 100%;
}

button:active {
    opacity: 0.8;
}

.block-btn {
    background: transparent;
    border: 1px solid #64748b;
    color: #64748b;
    font-size: 0.8rem;
    padding: 8px 16px;
    margin-top: 10px;
    transition: all 0.2s;
}

.block-btn.blocked {
    border-color: #ef4444;
    color: #ef4444;
}

.block-btn:hover {
    background: rgba(239, 68, 68, 0.05);
    border-color: #ef4444;
    color: #ef4444;
}

/* Page Control */
.page {
    display: none;
    animation: fadeIn 0.3s ease;
    padding-top: 10px;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
}

.page.active {
    display: block;
}

/* Forms */
.glass-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.1);
    margin-bottom: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.3s;
    color: var(--text-main);
}

.glass-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.glass-input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.7);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Discover Page Extensions */
.discover-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.random-match-card {
    background: linear-gradient(135deg, rgba(45,27,78,0.8), rgba(31,41,55,0.8));
    /* Deep Violet to Dark */
    border: 1px solid var(--border);
    color: #f8fafc;
    padding: 30px;
    border-radius: 28px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
}

.random-match-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 35px rgba(201, 160, 220, 0.25);
    border-color: rgba(201, 160, 220, 0.5);
}

.random-match-card:active {
    transform: scale(0.97);
}

.random-match-card i {
    font-size: 2.2rem;
    margin-bottom: 8px;
    display: block;
}

.random-match-card h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.random-match-card p {
    font-size: 0.9rem;
    opacity: 0.8;
}

.random-match-card button {
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s;
}

.random-match-card button:hover {
    filter: brightness(1.1);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 10px 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.party-list {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 15px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    width: 100%;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.party-list::-webkit-scrollbar {
    display: none;
}

.party-card {
    min-width: 160px;
    padding: 18px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.party-card h4 {
    font-size: 0.9rem;
    line-height: 1.3;
    margin: 0;
}

.party-card .stats {
    font-size: 0.9rem;
    opacity: 0.9;
    background: rgba(0, 0, 0, 0.1);
    padding: 4px 8px;
    border-radius: 8px;
    align-self: flex-start;
}

/* Talk Page specific */
body.voice-active .header {
    display: none;
}

#talk-page {
    /* Special page that might need 100% height minus header/nav */
    height: calc(100vh - 150px);
    height: calc(100dvh - 150px);
    display: none;
    flex-direction: column;
}

body.voice-active #talk-page {
    height: calc(100vh - 70px);
    height: calc(100dvh - 65px - env(safe-area-inset-bottom));
    padding-top: 0;
}

/* Language Filter Chips */
.lang-chip {
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.lang-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 600;
}

#talk-page.active {
    display: flex;
}

.voice-call-overlay-content {
    border-radius: 24px;
    overflow: hidden;
    flex: 1;
}

/* Speaker Grid Layout */
.call-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-top: 15px;
    overflow: hidden;
    display: none;
    /* Only show in expanded */
}

.expanded .call-chat-container {
    display: flex;
}

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

.chat-msg {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 85%;
}

.chat-msg.me {
    align-self: flex-start;
    flex-direction: row;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    background: var(--chat-bubble-received-bg);
    color: var(--chat-bubble-text);
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.chat-msg.me .chat-bubble {
    background: var(--chat-bubble-sent-bg);
    color: var(--chat-bubble-text);
}

.chat-input-area {
    padding: 15px;
    display: flex;
    gap: 10px;
}

.chat-input-area input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 20px;
    padding: 10px 15px;
    color: var(--text-main);
    font-size: 0.9rem;
}

/* Speaker Grid Layout */
.voice-avatar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    /* Compact gap */
    position: relative;
    padding: 5px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    transition: all 0.3s ease;
}

.voice-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
    object-fit: cover;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.reward-badge {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
    gap: 6px;
    padding: 2px 10px;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: 20px;
    color: #fbbf24;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: default;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.reward-label {
    opacity: 0.9;
    font-weight: 600;
}

.reward-badge:hover {
    background: rgba(16, 185, 129, 0.2);
    transform: translateY(-1px);
}

.reward-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-right: 4px;
}

.ad-tracking-pulse {
    animation: reward-pulse 2s infinite;
}

@keyframes reward-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.speaker-name {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-main);
    max-width: 76px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    margin-top: 2px;
}

#call-participants {
    min-height: auto;
}

/* ---- New Talk Room Layout (Step1: CSS) ---- */

/* Compact header for talk room */
#room-visibility-banner {
    flex-wrap: wrap;
}

/* Top row: first 3 speaker slots (horizontal scroll) */
#talk-top-row {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    overflow-x: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 6px 8px;
    flex-shrink: 0;
}

#talk-top-row::-webkit-scrollbar {
    display: none;
}

/* Right column: slots 4-7 (vertical) */
#talk-right-col {
    flex: 0 0 100px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    scrollbar-width: none;
    padding: 8px 6px;
}

#talk-right-col::-webkit-scrollbar {
    display: none;
}

/* Listeners strip */
#talk-listeners-row {
    padding: 5px 12px;
    flex-shrink: 0;
}

/* Small control buttons for header (36px) */
.control-btn.sm {
    width: 36px;
    height: 36px;
    font-size: 1rem;
}


.minimized .voice-avatar {
    width: 40px;
    height: 40px;
    border-width: 2px;
}

.minimized .voice-avatar-container {
    padding: 0;
    background: transparent;
    flex-direction: row;
}

.wave-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 30px;
    /* Compact wave height */
    margin-bottom: -5px;
}

.wave-bar {
    width: 4px;
    /* Thinner bars */
    height: 6px;
    background: var(--primary);
    border-radius: 2px;
    transition: height 0.05s ease;
}

.call-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    padding-top: 10px;
}

.control-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.15);
    transition: background 0.2s;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.control-btn.end {
    background: #ef4444;
}

/* Listener Avatar */
.listener-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    opacity: 0.6;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Notification Banner */
.notification-banner {
    position: fixed;
    top: -100px;
    /* Start hidden above */
    left: 20px;
    right: 20px;
    margin: 0 auto;
    max-width: 400px;
    z-index: 10000;
    transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 16px;
    /* Glassmorphism inherited if class="glass notification-banner" */
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.notification-banner.active {
    top: 20px;
}

/* Ad Banner Card Refinement */
.page-ad.ad-banner {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
    margin: 15px auto;
    border-radius: 20px;
    overflow: hidden;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 10px;
    max-width: 600px;
    width: calc(100% - 20px);
}

.page-ad.ad-banner iframe,
.page-ad.ad-banner script {
    max-width: 100% !important;
    border-radius: 12px;
}
/* OpenClaw Enchancements - Dynamic Animations & Micro-interactions */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

button {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 14px rgba(0, 0, 0, 0.1), 0 3px 6px rgba(0, 0, 0, 0.08);
}

button:active {
    transform: translateY(1px);
}

.moment-card, .party-card, .random-match-card {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.moment-card:hover, .party-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15), 0 6px 6px rgba(0, 0, 0, 0.1);
    border-color: rgba(201, 160, 220, 0.4);
}

/* Enhancing Gradients */
.header h1 {
    background: linear-gradient(to right, var(--primary), var(--secondary), var(--color-horizon));
    background-size: 200% auto;
    animation: shimmer 4s linear infinite;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
