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 */

    /* Dark theme defaults */
    --bg-color: #0b0c10;
    /* Deep Space Black */
    --card-bg: rgba(255, 253, 208, 0.05);
    /* Creme tint glass */
    --glass-bg: rgba(11, 12, 16, 0.85);
    --text-main: #f0f2f5;
    --text-muted: #a0aab5;
    --border: rgba(166, 212, 255, 0.1);
    /* Horizon Blue hint */
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);

    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);

    /* Chat Bubbles (Dark Default - Refined from reference image) */
    --chat-bubble-received-bg: #262626;
    /* Dark slate-black */
    --chat-bubble-sent-bg: #2d235c;
    /* Dark purple-blue */
    --chat-bubble-text: #ffffff;
}

/* Respect system light / dark preference */
@media (prefers-color-scheme: light) {
    :root {
        --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);

        --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);

        /* Chat Bubbles (Light Mode) */
        --chat-bubble-received-bg: #f1f5f9;
        --chat-bubble-sent-bg: #ede9fe;
        --chat-bubble-text: #000000;
    }

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

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

    .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;
    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(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

/* Layout */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 10px;
}

.header {
    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: 0;
    right: 0;
    height: 65px;
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    border-top: 1px solid var(--border);
    box-sizing: content-box;
    /* Ensures height + padding */
    transform: translateZ(0);
    /* Fix for occasional shifting/flickering on mobile */
    -webkit-transform: translateZ(0);
}

.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;
}

/* Page Control */
.page {
    display: none;
    animation: fadeIn 0.3s ease;
    padding-top: 10px;
}

.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.4);
}

.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, #2D1B4E, #1F2937);
    /* Deep Violet to Dark */
    border: 1px solid var(--primary-dark);
    color: #e2e8f0;
    padding: 30px;
    border-radius: 28px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(67, 56, 202, 0.2);
}

.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;
}

.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;
}

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

.voice-call-overlay-content {
    background: var(--card-bg);
    border-radius: 24px;
    border: 1px solid var(--border);
    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-end;
    flex-direction: row-reverse;
}

.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;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.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: 8px;
    /* Reduced gap */
    position: relative;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    transition: all 0.3s ease;
}

.voice-avatar {
    width: 64px;
    /* Slightly smaller base size */
    height: 64px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
    object-fit: cover;
    background-color: var(--card-bg);
}

.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: 20px;
    justify-content: center;
    margin-top: auto;
    /* Push to bottom */
    padding-top: 20px;
}

.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;
}