:root {
    --community-panel-bg: rgba(8, 14, 28, 0.82);
    --community-panel-border: rgba(255, 255, 255, 0.12);
    --community-panel-shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
    --community-text-main: #f7fbff;
    --community-text-sub: rgba(234, 241, 249, 0.78);
    --community-accent: #ffd166;
    --community-accent-soft: rgba(255, 209, 102, 0.16);
    --community-success: #8ce99a;
    --community-error: #ffb4b4;
    --community-card-bg: rgba(255, 255, 255, 0.08);
    --community-input-bg: rgba(255, 255, 255, 0.1);
}

.start-hub {
    width: min(560px, 94vw);
}

.hero-panel,
.community-panel {
    position: relative;
    padding: 2rem;
    border-radius: 24px;
    background: var(--community-panel-bg);
    box-shadow: var(--community-panel-shadow);
    backdrop-filter: blur(14px);
}

.hero-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 520px;
    border: 1px solid var(--community-panel-border);
}

.hero-panel .title {
    margin-bottom: 1rem;
}

.hero-panel .subtitle {
    margin-bottom: 2.2rem;
}

.hero-panel .button-container {
    margin-bottom: 1rem;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.hero-panel #topStartBtn,
.hero-panel #communityOpenButton {
    min-width: 220px;
}

.community-panel {
    color: var(--community-text-main);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: min(780px, 94vw);
    max-height: 88vh;
    overflow-y: auto;
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.06), transparent 30%),
        radial-gradient(circle at bottom left, rgba(76, 201, 240, 0.14), transparent 28%),
        var(--community-panel-bg);
    background-attachment: local;
    border: none;
}

.community-panel.is-register {
    max-height: none;
    overflow-y: visible;
}

.community-overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.58);
    overflow-y: auto;
}

.community-overlay.active {
    display: flex;
}

.community-overlay.is-register {
    align-items: flex-start;
}

.community-overlay.is-register .community-panel {
    margin: 1rem auto;
}

.community-close-row {
    display: flex;
    justify-content: flex-end;
}

.community-screen {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.community-screen[hidden],
.community-tab-panel[hidden] {
    display: none !important;
}

.community-register-screen {
    min-height: 0;
    grid-column: 1;
}

.community-panel-header {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.community-panel-header h2 {
    margin: 0;
    font-size: 1.75rem;
    color: var(--community-text-main);
}

.community-panel-header p {
    margin: 0;
    color: var(--community-text-sub);
    line-height: 1.5;
}

.community-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.community-card {
    background: var(--community-card-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    min-height: 0;
}

.community-card--board,
.community-card--room,
.community-card--tabs {
    grid-column: 1 / -1;
}

.community-card--register {
    gap: 1rem;
}

.community-card--tabs {
    padding: 0.85rem;
    gap: 0.9rem;
}

.community-card--tabs > .community-card {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
}

.community-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
}

.community-auth-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
}

.community-auth-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.75rem 1rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.05);
    color: var(--community-text-sub);
    font-family: 'KHドット小伝馬町16', sans-serif;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.community-auth-tab:hover {
    transform: translateY(-1px);
    color: var(--community-text-main);
    border-color: rgba(255, 209, 102, 0.3);
}

.community-auth-tab.active {
    background: linear-gradient(135deg, rgba(255, 209, 102, 0.18), rgba(76, 201, 240, 0.12));
    border-color: rgba(255, 209, 102, 0.46);
    color: var(--community-text-main);
}

.community-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 52px;
    padding: 0.8rem 1rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.05);
    color: var(--community-text-sub);
    font-family: 'KHドット小伝馬町16', sans-serif;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.community-tab:hover {
    transform: translateY(-1px);
    color: var(--community-text-main);
    border-color: rgba(255, 209, 102, 0.3);
}

.community-tab.active {
    background: linear-gradient(135deg, rgba(255, 209, 102, 0.18), rgba(76, 201, 240, 0.12));
    border-color: rgba(255, 209, 102, 0.46);
    color: var(--community-text-main);
}

.community-tab-badge {
    width: 0.58rem;
    height: 0.58rem;
    border-radius: 999px;
    background: #ff6b6b;
    box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.18);
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.community-tab-badge.visible {
    opacity: 1;
    transform: scale(1);
}

.community-tab-panel {
    display: none;
}

.community-tab-panel.active {
    display: block;
}

.community-card h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--community-text-main);
}

.community-card p {
    margin: 0;
    color: var(--community-text-sub);
    line-height: 1.45;
}

.community-legal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.community-legal-card {
    min-height: 0;
    padding: 1rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.community-legal-card h4,
.community-legal-block h5 {
    margin: 0;
    color: var(--community-text-main);
}

.community-legal-card h4 {
    font-size: 1rem;
}

.community-legal-block h5 {
    font-size: 0.92rem;
}

.community-legal-body {
    max-height: 320px;
    overflow-y: auto;
    padding-right: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
}

.community-legal-body p {
    margin: 0;
    color: var(--community-text-sub);
    line-height: 1.55;
}

.community-legal-body ul {
    margin: 0.45rem 0 0 1.15rem;
    padding: 0;
    color: var(--community-text-sub);
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.community-legal-body li {
    line-height: 1.55;
}

.community-legal-block {
    display: flex;
    flex-direction: column;
    gap: 0.38rem;
}

.community-consent-row {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--community-text-main);
    line-height: 1.5;
    cursor: pointer;
}

.community-consent-row input {
    width: 1rem;
    height: 1rem;
    margin-top: 0.2rem;
    accent-color: #ffd166;
}

.community-auth-row,
.community-room-row,
.community-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.community-auth-row .btn {
    flex: 1 1 0;
}

.community-room-row .community-input {
    flex: 1 1 220px;
}

.community-input,
.community-textarea {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    background: var(--community-input-bg);
    color: var(--community-text-main);
    padding: 0.8rem 0.9rem;
    font-size: 0.95rem;
    font-family: 'KHドット小伝馬町16', sans-serif;
}

.community-input::placeholder,
.community-textarea::placeholder {
    color: rgba(240, 246, 255, 0.52);
}

.community-input:focus,
.community-textarea:focus {
    outline: 2px solid rgba(255, 209, 102, 0.35);
    border-color: rgba(255, 209, 102, 0.65);
}

.community-textarea {
    min-height: 88px;
    resize: vertical;
    line-height: 1.5;
}

.community-feed {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 0.2rem;
}

.community-item {
    padding: 0.8rem 0.9rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.community-item-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.45rem;
}

.community-item-author {
    font-weight: bold;
    color: #fff4bf;
}

.community-item-time {
    font-size: 0.8rem;
    color: rgba(240, 246, 255, 0.62);
    white-space: nowrap;
}

.community-item-body {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.55;
}

.community-badge-row {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.community-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.32rem 0.7rem;
    border-radius: 999px;
    background: var(--community-accent-soft);
    border: 1px solid rgba(255, 209, 102, 0.32);
    color: #fff5cf;
    font-size: 0.82rem;
}

.community-code {
    font-size: 1.1rem;
    letter-spacing: 0.18em;
    font-weight: bold;
    color: var(--community-accent);
}

.community-notice {
    min-height: 1.2rem;
    font-size: 0.85rem;
    color: var(--community-text-sub);
}

.community-notice[data-tone="success"] {
    color: var(--community-success);
}

.community-notice[data-tone="error"] {
    color: var(--community-error);
}

.community-empty {
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    padding: 1rem;
    color: var(--community-text-sub);
    text-align: center;
    line-height: 1.5;
}

.community-authenticated {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.community-room-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.community-room-title {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.community-room-title h4 {
    margin: 0;
    font-size: 1rem;
}

.community-room-title p {
    margin: 0;
    font-size: 0.85rem;
}

@media (max-width: 960px) {
    .start-hub {
        width: min(92vw, 560px);
    }

    .hero-panel,
    .community-panel {
        min-height: auto;
    }

    .community-legal-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .hero-panel,
    .community-panel {
        padding: 1.3rem;
        border-radius: 18px;
    }

    .community-overlay {
        padding: 0.8rem;
    }

    .community-stack {
        grid-template-columns: 1fr;
    }

    .community-tabs {
        grid-template-columns: 1fr;
    }

    .community-auth-row,
    .community-room-row,
    .community-actions {
        flex-direction: column;
    }

    .community-auth-row .btn,
    .community-room-row .btn,
    .community-actions .btn {
        width: 100%;
    }
}
