@font-face {
    font-family: 'CustomFont';
    src: url('../../../fonts/font3.woff2') format('woff2'),
        url('../../../fonts/font3.woff') format('woff'),
        url('../../../fonts/font3.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* Color Variables */
:root {
    /* === メンバー識別色（固定：テーマでは変化させない） === */
    /* つかさ/はやと本人を表す色。テーマCSSでは絶対に上書きしないこと。 */
    --member-hayato: #006400; /* Hayato Green */
    --member-tsukasa: #005A5A; /* Tsukasa Teal */
    --member-hayato-light: #2ecc71; /* Brighter Hayato Green */
    --member-tsukasa-light: #00d2d3; /* Brighter Tsukasa Teal */

    /* === テーマパレット（可変：テーマCSSで上書きされる） === */
    /* アプリ全体のUI（ヘッダー/ナビ/ボタン/アクセント等）の基調色。
       デフォルト値は従来の見た目を維持するためメンバー色と同値にしている。 */
    --app-main-color-1: #006400;
    --app-main-color-2: #005A5A;
    --app-accent-purple: #8e44ad;
    --app-primary-gradient: linear-gradient(to right, var(--app-main-color-1), var(--app-main-color-2));
    --app-primary-gradient-alt: linear-gradient(135deg, var(--app-main-color-1), var(--app-main-color-2));

    /* === 基調サーフェス／テキスト（可変：ダークテーマ対応） === */
    /* デフォルト値は従来のライトテーマと同一。ダークテーマCSSでまとめて上書きする。 */
    --app-bg: #f7f8fa;
    /* ページ地色 */
    --app-surface: #ffffff;
    /* カード・ヘッダー・ナビ等の面 */
    --app-surface-2: #f8f9fa;
    /* やや沈んだ面・hover地 */
    --app-border: #e0e0e0;
    /* 罫線・枠 */
    --app-border-light: #f0f0f0;
    /* 薄い区切り線 */
    --app-text: #2c3e50;
    /* 主要テキスト */
    --app-text-strong: #34495e;
    /* 見出しテキスト */
    --app-text-muted: #95a5a6;
    /* 補助・プレースホルダ */
    --app-shadow: rgba(0, 0, 0, 0.05);
    /* 標準シャドウ色 */
}

/* Dev Environment Overrides */
body.is-dev {
    --app-main-color-1: #ff4757;
    /* Red */
    --app-main-color-2: #ff6b81;
    /* Pink */
    --app-accent-purple: #ff4757;
}

/* 基本的なリセットとフォント設定 */
body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    /* body自体のスクロールを禁止 */
    position: fixed;
    /* iOSでのスクロールバグ対策 */
    -webkit-touch-callout: none;
    /* iOS Safari: 長押しメニュー禁止 */
    user-select: none;
    /* テキスト選択禁止 */
}

/* 入力要素などは例外として許可 */
input,
textarea,
select {
    -webkit-touch-callout: default;
    user-select: auto;
}

body,
html,
input,
textarea,
button {
    font-family: 'CustomFont', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--app-bg);
    color: var(--app-text);
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

body::-webkit-scrollbar,
html::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari and Opera */
}

.container {
    max-width: 480px;
    margin: 40px auto;
    padding: 30px;
    background-color: var(--app-surface);
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
}

.containerTwitch {
    max-width: 480px;
    padding: 30px;
    background-color: var(--app-surface);
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
}

h1 {
    text-align: center;
    color: var(--app-text-strong);
    font-weight: 600;
    margin-bottom: 25px;
}

/* フォームのスタイル */
.form-group {
    margin-bottom: 20px;
}

/* Toggle Switch Style */
.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #2196F3;
}

input:checked+.slider:before {
    transform: translateX(14px);
}


.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--app-text-strong);
    font-size: 14px;
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-sizing: border-box;
    background-color: var(--app-bg);
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--app-accent-purple);
    background-color: var(--app-surface);
    box-shadow: 0 0 0 3px rgba(142, 68, 173, 0.15);
}

button {
    font-family: 'CustomFont', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    width: 100%;
    padding: 15px;
    background-image: var(--app-primary-gradient);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(155, 89, 182, 0.3);
}

button:hover {
    box-shadow: 0 6px 20px rgba(155, 89, 182, 0.4);
}

/* メッセージ表示エリア */
.message {
    padding: 15px;
    margin-top: 20px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
}

.message.success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.message.error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

/* アプリケーションのレイアウト */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 480px;
    /* スマートフォンサイズに合わせる */
    margin: 0 auto;
    background-color: var(--app-surface);
    border-left: 1px solid var(--app-border);
    border-right: 1px solid var(--app-border);
    overflow: hidden;
    position: relative;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    padding-top: calc(10px + env(safe-area-inset-top));
    height: calc(60px + env(safe-area-inset-top));
    background-color: var(--app-surface);
    border-bottom: 1px solid var(--app-border-light);
    box-sizing: border-box;
    flex-shrink: 0;
    z-index: 1001;
}

.header-logo {
    height: 35px;
}

.app-content {
    flex: 1;
    overflow-y: auto;
    /* コンテンツが多ければスクロール */
    padding: 20px;
    padding-bottom: calc(120px + env(safe-area-inset-bottom));
    /* 下部ナビゲーションの高さ分 + 余裕 */
    background-color: var(--app-bg);
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
    -webkit-overflow-scrolling: touch;
}

.app-content::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari and Opera */
}

/* 下部ナビゲーション */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 480px;
    /* コンテナの幅に合わせる */
    margin: 0 auto;
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 70px;
    background-color: var(--app-surface);
    border-top: 1px solid var(--app-border-light);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.04);
    padding-bottom: constant(safe-area-inset-bottom);
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: content-box;
    /* height: 70px + padding-bottom になるように content-box を明示 (デフォルトだが念のため) */
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--app-text-muted);
    font-size: 12px;
    transition: color 0.3s ease;
}

.nav-item.active,
.nav-item:hover {
    color: var(--app-accent-purple);
}

.nav-icon {
    font-size: 22px;
    margin-bottom: 5px;
}

.nav-unread-dot {
    position: absolute;
    top: -5px;
    right: calc(50% - 18px);
    width: 10px;
    height: 10px;
    background-color: #e74c3c;
    border-radius: 50%;
    border: 2px solid #fff;
    z-index: 10;
}

/* ログイン・登録ページのリンク */
.auth-link {
    text-align: center;
    margin-top: 20px;
}

.auth-link a {
    color: var(--app-accent-purple);
    text-decoration: none;
    font-weight: 600;
}

.auth-link a:hover {
    text-decoration: underline;
}

.auth-btn-link {
    display: inline-block;
    width: 100%;
    padding: 12px;
    background-color: transparent;
    border: 2px solid var(--app-accent-purple);
    color: var(--app-accent-purple);
    text-decoration: none;
    font-weight: bold;
    border-radius: 8px;
    transition: all 0.3s;
    box-sizing: border-box;
    margin-top: 10px;
}

.auth-btn-link:hover {
    background-color: var(--app-accent-purple);
    color: white;
    text-decoration: none;
}

.info-btn {
    background: none;
    border: none;
    color: #bdc3c7;
    /* Light grey */
    cursor: pointer;
    font-size: 1em;
    padding: 0 5px;
    text-decoration: none;
    transition: color 0.3s ease;
}

.info-btn:hover {
    color: var(--app-accent-purple);
}

.modal-image-container {
    text-align: center;
    padding: 10px;
}

.modal-image-container img {
    max-width: 100%;
    height: auto;
    max-height: 70vh;
    /* モーダルからはみ出ないように */
    border-radius: 8px;
}

/* --- Point and Shop Themes --- */

/* Tsukasa (fj) Theme */
.balance-card.theme-fj {
    background: linear-gradient(135deg, var(--member-tsukasa), #008080);
}

.theme-fj .price-tag {
    color: var(--member-tsukasa);
}

.current-points.theme-fj {
    background-color: #e0f2f1;
    border-left: 4px solid var(--member-tsukasa);
}

.theme-fj .redeem-button {
    background-image: linear-gradient(to right, #00796b, #00897b);
}


/* Hayato (hyt) Theme */
.balance-card.theme-hyt {
    background: linear-gradient(135deg, var(--member-hayato), #2E8B57);
}

.theme-hyt .price-tag {
    color: var(--member-hayato);
}

.current-points.theme-hyt {
    background-color: #e8f5e9;
    border-left: 4px solid var(--member-hayato);
}

.theme-hyt .redeem-button {
    background-image: linear-gradient(to right, #388e3c, #43a047);
}

/* Fav (fav) Theme */
.balance-card.theme-favPt {
    background: linear-gradient(135deg, #FFD700, #FFA500);
}

.theme-favPt .price-tag {
    color: #DAA520;
}

.current-points.theme-favPt {
    background-color: #fff8e1;
    border-left: 4px solid #FFC107;
}

.theme-favPt .redeem-button {
    background-image: linear-gradient(to right, #FFB300, #FFC107);
}

/* LsPtLite Theme */
.balance-card.theme-lsptlite {
    background: linear-gradient(135deg, #fffaf0, #fdf5e6);
    color: #796000;
    border: 1px solid #ffcc00;
}

.theme-lsptlite .price-tag {
    color: #ffcc00;
}

.current-points.theme-lsptlite {
    background-color: #fffde6;
    border-left: 4px solid #ffd700;
    color: var(--app-text);
}

.theme-lsptlite .redeem-button {
    background-image: linear-gradient(to right, #ffcc00, #ffd700);
}

/* JPY Theme (Negative balance display) */
.balance-card.theme-jpy {
    background: linear-gradient(135deg, #FF4500, #DC143C);
}

.current-points.theme-jpy {
    background-color: #ffebee;
    border-left: 4px solid #f44336;
}

/* --- Points & Shop Page Cards --- */
.balance-cards-container {
    display: flex;
    gap: 15px;
    /* カード間の隙間 */
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.balance-card {
    flex: 1;
    /* 親要素の幅を均等に分ける */
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.balance-card h3 {
    margin: 0 0 10px 0;
    font-weight: normal;
    font-size: 1.2em;
}

.balance-card .balance-amount {
    font-size: 2.5em;
    font-weight: bold;
}

.balance-card .point-unit {
    font-size: 0.5em;
    margin-left: 5px;
}

/* Theme classes for Quiz Rules Cards (moved from inline styles) */
.balance-card.theme-tsukasa-quiz {
    background: white;
    border: 1px solid #008080;
    color: var(--app-text);
}

.balance-card.theme-hayato-quiz {
    background: white;
    border: 1px solid var(--member-hayato);
    color: var(--app-text);
}

.balance-card.theme-other-quiz {
    background: white;
    border: 1px solid #f1c40f;
    color: var(--app-text);
}

.point-history h3 {
    border-bottom: 2px solid var(--app-border-light);
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.log-list {
    list-style: none;
    padding: 0;
}

.log-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 10px;
    border-bottom: 1px solid var(--app-border-light);
}

.log-item:last-child {
    border-bottom: none;
}

.log-task {
    font-weight: bold;
    display: block;
}

.log-date {
    font-size: 0.9em;
    color: var(--app-text-muted);
}

.log-amount {
    font-weight: bold;
    font-size: 1.1em;
}

.log-item.gain .log-amount {
    color: #28a745;
    /* Green */
}

.log-item.spend .log-amount {
    color: #dc3545;
    /* Red */
}

/* Theme-based point history colors */
.log-item.theme-fj.gain .log-amount {
    color: var(--member-tsukasa);
    /* Tsukasa Member Color */
}

.log-item.theme-hyt.gain .log-amount {
    color: var(--member-hayato);
    /* Hayato Member Color */
}

.log-item.theme-favPt.gain .log-amount {
    color: #DAA520;
    /* fav theme color */
}

/* --- Shop Page --- */
.rewards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
}

.reward-item {
    border: 1px solid var(--app-border);
    border-radius: 12px;
    text-align: center;
    background-color: var(--app-surface);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 15px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.reward-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.reward-item img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 10px;
}

.reward-item h3 {
    font-size: 1em;
    margin: 0 0 5px 0;
    font-weight: 600;
}

.creator {
    font-size: 0.8em;
    color: var(--app-text-muted);
    margin-bottom: 10px;
}

.description {
    font-size: 0.9em;
    color: var(--app-text);
    min-height: 40px;
}

.price-tag {
    font-weight: bold;
    margin: 10px 0;
    font-size: 1.2em;
}

.redeem-button {
    width: 100%;
    padding: 10px;
    font-size: 0.9em;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.redeem-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.redeem-button.disabled {
    background-image: none;
    background-color: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

/* --- Custom Radio Player --- */
.custom-player {
    display: flex;
    align-items: center;
    gap: 15px;
    background-color: var(--app-surface-2);
    padding: 10px;
    border-radius: 50px;
    margin-top: 10px;
}

.play-pause-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #333;
    color: white;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 50%;
    transition: background-color 0.2s;
    padding: 0;
    flex-shrink: 0;
}

.play-pause-btn.playing {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M6 19h4V5H6v14zm8-14v14h4V5h-4z'/%3E%3C/svg%3E");
}

.play-pause-btn:hover {
    background-color: #555;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.current-time,
.duration {
    font-size: 0.9em;
    color: var(--app-text);
    min-width: 35px;
    text-align: center;
}

.progress-bar-container {
    flex-grow: 1;
    height: 8px;
    background-color: #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.progress-bar {
    height: 100%;
    width: 0;
    background-color: var(--app-accent-purple);
    border-radius: 4px;
}

/* --- Account Settings Page (iOS Style) --- */
.settings-group {
    background-color: var(--app-surface);
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid var(--app-border);
    overflow: hidden;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--app-border-light);
    transition: background-color 0.2s ease;
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item:not(.non-interactive):hover {
    background-color: var(--app-surface-2);
}

.settings-item:not(.non-interactive)::after {
    content: '\f054';
    /* FontAwesome chevron-right */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: #c7c7cc;
    margin-left: 10px;
}

.settings-label {
    font-weight: 500;
}

.settings-value {
    color: #8e8e93;
}

.actions-container {
    margin-top: 30px;
    text-align: center;
}

.logout-button {
    display: inline-block;
    padding: 12px 35px;
    background-color: #ff3b30;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    transition: background-color 0.3s;
}

.logout-button:hover {
    background-color: #e02b22;
}

/* --- Edit Pages (Username, Password, etc.) --- */
.edit-container {
    padding: 10px 0;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    text-decoration: none;
    color: var(--app-accent-purple);
    font-weight: 500;
}

.back-link i {
    margin-right: 5px;
}

.edit-container h2 {
    margin-bottom: 25px;
}

.contents-links {
    margin-bottom: 25px;
}

.creator-links {
    margin-bottom: 25px;
}

.creator-links h3 {
    margin-bottom: 15px;
}

.creator-links-container {
    display: flex;
    flex-direction: row;
    gap: 15px;
}

.creator-toggle {
    flex: 1;
    background-color: var(--app-surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.creator-toggle.theme-fj h4 {
    background-color: var(--member-tsukasa);
}

.creator-toggle.theme-hyt h4 {
    background-color: var(--member-hayato);
}

.creator-toggle h4 {
    margin: 0;
    padding: 15px 20px;
    color: white;
    font-size: 1.1em;
}

.creator-links-content {
    padding: 10px 0;
}

.creator-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    text-decoration: none;
    color: var(--app-text);
    transition: background-color 0.2s;
}

.creator-link:hover {
    background-color: var(--app-surface-2);
}

.creator-link i:first-child {
    width: 24px;
    margin-right: 12px;
}

.creator-link span {
    flex: 1;
}

.creator-link .fa-chevron-right {
    color: #ccc;
    font-size: 0.9em;
}

.theme-fj .creator-link i:first-child {
    color: var(--member-tsukasa);
}

.theme-hyt .creator-link i:first-child {
    color: var(--member-hayato);
}

/* --- Quick Links --- */
.quick-links-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    text-align: center;
}

@media (min-width: 768px) {
    .quick-links-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.quick-link-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 10px;
    background-color: var(--app-surface-2);
    border-radius: 8px;
    text-decoration: none;
    color: var(--app-text);
    font-weight: bold;
    transition: transform 0.2s, box-shadow 0.2s;
    word-break: break-word;
    overflow-wrap: break-word;
}

.quick-link-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.quick-link-item i {
    font-size: 2.2em;
    margin-bottom: 10px;
}

.quick-link-item span {
    line-height: 1.3;
}

/* Theme colors for quick links */
.quick-link-item.theme-fj i {
    color: #008080;
}

.quick-link-item.theme-hyt i {
    color: #2E8B57;
}


.action-button {
    display: inline-block;
    padding: 12px 25px;
    background-color: #ff69b4;
    /* Hot pink */
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s;
}

.action-button:hover {
    background-color: #ff85c1;
}

select {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-sizing: border-box;
    background-color: var(--app-bg);
    transition: all 0.3s ease;
    font-family: inherit;
    /* textareaにフォントを継承 */
    appearance: none;
    /* デフォルトの矢印を消す */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23999'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
}

/* Fan Team Banner Style */
.fan-team-banner {
    background-color: var(--app-accent-purple);
    /* Purple theme color */
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
}

.fan-team-banner p {
    margin: 0;
}

/* --- Invite Type Radio Buttons --- */
.form-group input[type="radio"] {
    accent-color: var(--app-accent-purple);
    width: 18px;
    height: 18px;
    margin-right: 8px;
    vertical-align: middle;
    cursor: pointer;
}

.form-group>div {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.form-group>div:last-child {
    margin-bottom: 0;
}

.form-group label[for="fukyou"],
.form-group label[for="suteaka"] {
    font-weight: 500;
    color: var(--app-text-strong);
    font-size: 15px;
    cursor: pointer;
    margin-bottom: 0;
}

/* --- Custom Modal (Replaces Bootstrap Modal) --- */
.custom-modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    outline: 0;
    background-color: rgba(0, 0, 0, 0.5);
    /* Black w/ opacity */
    align-items: center;
    /* Center vertically */
    justify-content: center;
    /* Center horizontally */
}

/* Ensure no underlines in bottom nav - reset for all states */
.bottom-nav a,
.bottom-nav a:hover,
.bottom-nav a:active,
.bottom-nav a:focus,
.bottom-nav .nav-item,
.bottom-nav .nav-item:hover,
.bottom-nav .nav-text,
.bottom-nav .nav-icon {
    text-decoration: none !important;
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* Chat Button States */
.nav-chat-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.2s ease;
}

.nav-chat-content.state-chat {
    background: linear-gradient(135deg, var(--app-main-color-1), var(--app-main-color-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-chat-content.state-close {
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: border-box !important;
    -webkit-text-fill-color: #e74c3c !important;
    color: #e74c3c !important;
}

.custom-modal.show {
    display: flex;
}

.custom-modal-dialog {
    position: relative;
    width: auto;
    margin: 0.5rem;
    pointer-events: none;
    max-width: 500px;
    width: 100%;
    max-height: calc(100% - 30vh);
    display: flex;
}

.custom-modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 100%;
    pointer-events: auto;
    background-color: var(--app-surface);
    background-clip: padding-box;
    border: 1px solid rgba(0, 0, 0, .2);
    border-radius: 0.3rem;
    outline: 0;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, .5);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.custom-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem;
    border-bottom: 1px solid var(--app-border);
    border-top-left-radius: calc(0.3rem - 1px);
    border-top-right-radius: calc(0.3rem - 1px);
    background: var(--app-primary-gradient);
    color: white;
}

.custom-modal-title {
    margin-bottom: 0;
    line-height: 1.5;
    font-size: 1.25rem;
    font-weight: 500;
}

.custom-modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1rem;
    overflow-y: auto;
    min-height: 0;
}

.custom-modal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    padding: 0.75rem;
    border-top: 1px solid var(--app-border);
    border-bottom-right-radius: calc(0.3rem - 1px);
    border-bottom-left-radius: calc(0.3rem - 1px);
}

/* Quiz Specific Modal Styles */
.quiz-modal-header {
    background: var(--app-primary-gradient);
    /* Hayato (Green) to Tsukasa (Teal) */
    color: white;
}

.quiz-title {
    font-weight: bold;
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1.1em;
}

.quiz-question-card {
    margin-bottom: 1rem;
    background-color: var(--app-surface-2);
    /* bg-light */
    border: 1px solid var(--app-border);
    border-radius: 0.25rem;
}

.quiz-question-body {
    padding: 1.25rem;
    text-align: center;
}

.quiz-question-text {
    margin-bottom: 0;
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.2;
}

.quiz-choices-grid {
    display: grid;
    gap: 0.5rem;
}

.btn-quiz-choice,
.btn-quiz-start {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    text-align: center;
    cursor: pointer;
    user-select: none;
    background-image: none !important;
    /* Override global button style */
    background-color: white !important;
    border: 2px solid var(--member-tsukasa) !important;
    /* Tsukasa Color */
    border-radius: 0.25rem;
    color: var(--member-tsukasa) !important;
    font-weight: bold;
    transition: all 0.3s ease;
    margin-bottom: 0.5rem;
    /* spacing */
}

.btn-quiz-choice:hover,
.btn-quiz-choice:focus,
.btn-quiz-start:hover,
.btn-quiz-start:focus {
    background: var(--app-primary-gradient) !important;
    color: white !important;
    border-color: transparent !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-quiz-choice.correct,
.btn-quiz-start.correct {
    background-color: #28a745 !important;
    background-image: none !important;
    border-color: #28a745 !important;
    color: white !important;
}

.btn-quiz-choice.incorrect,
.btn-quiz-start.incorrect {
    background-color: #dc3545 !important;
    background-image: none !important;
    border-color: #dc3545 !important;
    color: white !important;
}

.quiz-rules-link {
    font-size: 80%;
    color: var(--app-text-muted);
    text-decoration: none;
}

.quiz-rules-link:hover {
    color: var(--app-text-strong);
    text-decoration: underline;
}

.text-right {
    text-align: right;
}

.mt-2 {
    margin-top: 0.5rem;
}

/* Rule Section for quiz_rules.php */
.rule-section {
    background-color: var(--app-surface);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
    border: 1px solid var(--app-border);
}

/* Quiz Selection Buttons */
.btn-quiz-select {
    width: 100%;
    padding: 15px;
    font-size: 1.1em;
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    background-image: none !important;
    /* Reset default gradient */
}

.btn-quiz-select.theme-fj {
    background: linear-gradient(135deg, var(--member-tsukasa), #008080) !important;
    box-shadow: 0 4px 10px rgba(0, 90, 90, 0.3);
}

.btn-quiz-select.theme-hyt {
    background: linear-gradient(135deg, var(--member-hayato), #2E8B57) !important;
    box-shadow: 0 4px 10px rgba(0, 100, 0, 0.3);
}

.btn-quiz-select:hover {
    transform: translateY(-3px);
    opacity: 0.9;
}

.btn-quiz-select:active {
    transform: translateY(0);
}

.quiz-bonus-text {
    display: none;
    font-size: 0.8em;
    width: 100%;
    margin-top: 2px;
}

/* Quiz Answer Modal Text */
#correctAnswerDisplay {
    font-size: 1.5em;
    margin: 15px 0;
    padding: 10px;
    background-color: #f8d7da;
    border-radius: 5px;
    color: #721c24;
}

/* Fan Team Dashboard Styles */
.fan-dashboard-container {
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.fan-status-box {
    background: var(--app-surface-2);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.fan-status-title {
    font-size: 1.2em;
    color: var(--app-text-muted);
    margin-bottom: 10px;
}

.fan-rank-display {
    font-size: 2.5em;
    font-weight: bold;
    color: var(--app-accent-purple);
    /* Purple */
}

.fan-rank-sub {
    font-size: 0.9em;
    color: var(--app-text-muted);
}

.fan-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    background: var(--app-surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.fan-table th,
.fan-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--app-border-light);
}

.fan-table th {
    background: var(--app-surface-2);
    font-weight: bold;
    color: var(--app-text);
    width: 30%;
}

.fan-action-btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--app-accent-purple);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9em;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
}

.fan-action-btn:hover {
    background: #732d91;
    color: white;
}

.fan-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: bold;
    color: white;
    background: #ccc;
}

.fan-badge.success {
    background: #28a745;
}

.fan-badge.warning {
    background: #ffc107;
    color: var(--app-text);
}

.fan-badge.danger {
    background: #dc3545;
}

.fan-badge.info {
    background: #17a2b8;
}

/* Modal Override for Fan Team */
.fan-modal-body {
    max-height: 70vh;
    overflow-y: auto;
    padding: 20px;
}

.fan-rank-table {
    width: 100%;
    border: 1px solid var(--app-border);
    border-collapse: collapse;
}

.fan-rank-table th,
.fan-rank-table td {
    border: 1px solid var(--app-border);
    padding: 10px;
}

/* MXD Theme Colors Override */
.fan-dashboard-container h1,
.fan-dashboard-container h3,
.fan-status-title {
    color: var(--app-text);
    /* Darker text */
}

/* Gradient Button / Header */
.fan-gradient-bg {
    background: var(--app-primary-gradient);
    color: white;
}

.fan-action-btn {
    background: var(--app-primary-gradient);
    color: white;
    border: none;
}

.fan-action-btn:hover {
    background: linear-gradient(to right, #004d00, #004d4d);
    opacity: 0.9;
}

/* Rank Display Update */
.rank-transition-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.rank-current {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--app-text);
}

.rank-arrow {
    font-size: 1.5em;
    color: var(--app-text-muted);
}

.rank-next {
    font-size: 0.8em;
    /* Smaller font for next month */
    color: var(--app-text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;

}

.rank-next-label {
    font-size: 0.7em;
}

/* Admin Alert */
.admin-alert-box {
    margin-bottom: 20px;
}

/* Modal Improvements */
.custom-modal-header .close {
    font-size: 1.5rem;
    padding: 0;
    margin: 0;
    color: white;
    opacity: 0.8;
    width: auto;
    /* Fix for global button width: 100% */
    background: transparent;
    /* Fix for global button background */
    box-shadow: none;
    /* Fix for global button shadow */
}

.custom-modal-header .close:hover {
    opacity: 1;
}

.margin-bottom-10 {
    margin-bottom: 10px;
}

.apps_title {
    font-size: 0.8em;
}

/* --- Footer Toggle & Floating Window --- */
.footer-toggle-btn {
    position: fixed;
    right: 20px;
    bottom: calc(85px + env(safe-area-inset-bottom));
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--app-main-color-2), var(--app-main-color-1));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.footer-toggle-btn:active {
    transform: scale(0.9);
}

.footer-toggle-btn i {
    font-size: 20px;
}

/* フローティングウィンドウ (タブ切替的な挙動) */
.floating-window {
    display: none;
    position: fixed;
    top: calc(60px + env(safe-area-inset-top));
    /* ヘッダーの下 */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    /* フッターの上までの高さを計算 */
    height: calc(100dvh - (60px + env(safe-area-inset-top)) - (70px + env(safe-area-inset-bottom)));
    background-color: var(--app-surface);
    border-radius: 0;
    /* タブのように見せるため角丸をなくす */
    box-shadow: none;
    z-index: 2000;
    /* ヘッダー(1001)より下、コンテンツより上 */
    overflow: hidden;
    flex-direction: column;
    border-bottom: 1px solid var(--app-border-light);
}

.floating-window-header {
    height: 50px;
    background: var(--app-surface-2);
    border-bottom: 1px solid var(--app-border-light);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 15px;
    flex-shrink: 0;
}

.floating-window-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    color: var(--app-text-muted);
}

.floating-window-body {
    flex: 1;
    position: relative;
}

.floating-window-body iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* フッター切り替え */
#footer-nav-1,
#footer-nav-2 {
    display: none;
}

#footer-nav-1 {
    justify-content: space-around;
}

@media (min-width: 481px) {
    .footer-toggle-btn {
        right: auto;
        left: 50%;
        margin-left: 170px;
        /* 240px - 50px - 20px */
    }
}

/* --- New Home Layout Styles --- */
.home-container {
    padding: 15px;
}

.section-title {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--app-text);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Live Notification */
.live-notification {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 25px;
    text-align: center;
    animation: pulse 2s infinite;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    70% {
        transform: scale(1.02);
    }

    100% {
        transform: scale(1);
    }
}

/* Banner Carousel */
.banner-carousel-container {
    margin: 0 -15px 30px -15px;
    overflow: hidden;
}

.banner-carousel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 12px;
    padding: 0 15px 10px 15px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.banner-carousel::-webkit-scrollbar {
    display: none;
}

.banner-item {
    flex: 0 0 85%;
    scroll-snap-align: center;
}

.banner-item img {
    width: 100%;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: block;
}

/* Creator Dashboard */
.creator-cards {
    display: flex;
    gap: 12px;
}

.creator-card {
    flex: 1;
    background: var(--app-surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.creator-header h4 {
    margin: 0;
    padding: 10px;
    color: white;
    text-align: center;
    font-size: 0.9em;
}

.theme-fj .creator-header {
    background: var(--member-tsukasa);
}

.theme-hyt .creator-header {
    background: var(--member-hayato);
}

.creator-body {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 15px 5px;
    row-gap: 15px;
    column-gap: 5px;
}

.creator-tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    color: var(--app-text);
    transition: transform 0.2s;
}

.creator-tool i {
    font-size: 1.2em;
    margin-bottom: 6px;
}

.theme-fj .creator-tool i {
    color: var(--member-tsukasa);
}

.theme-hyt .creator-tool i {
    color: var(--member-hayato);
}

.creator-tool span {
    font-size: 0.65em;
    font-weight: bold;
    line-height: 1.3;
}

.creator-tool:active {
    transform: scale(0.9);
}

/* Unified Tool Grid */
.unified-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 5px;
    background: var(--app-surface);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    text-decoration: none;
    color: var(--app-text);
    transition: all 0.2s;
}

.grid-item i {
    font-size: 1.8em;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--app-main-color-2), var(--app-main-color-1));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.grid-item span {
    font-size: 0.75em;
    font-weight: bold;
    text-align: center;
}

.grid-item:active {
    transform: translateY(2px);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.grid-item.highlight {
    border: 2px solid #e74c3c;
    background: #fff5f5;
}

/* External Grid */
.external-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.external-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f0f2f5;
    border-radius: 10px;
    text-decoration: none;
    color: var(--app-text);
}

.external-item img {
    width: 30px;
    height: 30px;
    border-radius: 6px;
}

.external-item span {
    font-size: 0.8em;
    font-weight: bold;
}

/* PWA Button */
.pwa-btn {
    width: auto !important;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe) !important;
    border: none !important;
    padding: 12px 30px !important;
    border-radius: 30px !important;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3) !important;
}

.notif-request-btn {
    position: fixed;
    bottom: calc(85px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: #6c5ce7;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 40px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    width: auto;
}

/* Favp TV Broadcasting Banner */
.tv-broadcasting-banner {
    width: 100%;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white !important;
    border-radius: 12px;
    margin-bottom: 25px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    animation: pulse 2s infinite;
    text-decoration: none !important;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    box-sizing: border-box;
}

.tv-broadcasting-banner:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tv-broadcasting-banner i {
    color: #e74c3c;
    font-size: 2.2em;
    margin-right: 15px;
    filter: drop-shadow(0 0 5px rgba(231, 76, 60, 0.4));
}

.tv-broadcasting-banner .text-container {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.tv-broadcasting-banner .main-text {
    font-weight: bold;
    font-size: 1.15em;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.tv-broadcasting-banner .sub-text {
    font-size: 0.85em;
    opacity: 0.9;
    margin-top: 4px;
}