body:has(.redblue-app) {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%) !important;
    color: #f8fafc !important;
}

body:has(.redblue-app) header.yz-header,
body:has(.redblue-app) footer.yz-footer {
    background: rgba(15, 23, 42, 0.85) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.redblue-app {
    max-width: 600px;
    margin: 0 auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 120px);
    box-sizing: border-box;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.redblue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 12px;
    backdrop-filter: blur(8px);
}

.redblue-title-area h1 {
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: 0.05em;
    background: linear-gradient(90deg, #f87171, #60a5fa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.redblue-subtitle {
    font-size: 0.75rem;
    color: #94a3b8;
    margin: 2px 0 0 0;
}

.redblue-top-stats {
    display: flex;
    gap: 12px;
}

.stat-box {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 4px 10px;
    text-align: center;
    min-width: 50px;
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    color: #94a3b8;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f8fafc;
}

/* 続きからバナー */
.rb-resume-banner {
    background: rgba(129, 140, 248, 0.15);
    border: 1px solid rgba(129, 140, 248, 0.3);
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.rb-resume-btns {
    display: flex;
    gap: 8px;
}

.redblue-main-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.rb-card {
    background: rgba(30, 41, 59, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    text-align: center;
}

.rb-card h2 {
    font-size: 1.1rem;
    margin-top: 0;
    margin-bottom: 16px;
    color: #e2e8f0;
}

/* 難易度ボタン */
.rb-diff-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.rb-diff-btn {
    background: rgba(15, 23, 42, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px 16px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rb-diff-btn:hover {
    border-color: rgba(129, 140, 248, 0.5);
    background: rgba(30, 41, 59, 0.9);
}

.rb-diff-btn.active {
    border-color: #818cf8;
    background: rgba(129, 140, 248, 0.15);
}

.rb-diff-btn .diff-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.rb-diff-btn .diff-desc {
    font-size: 0.75rem;
    color: #94a3b8;
}

.rb-primary-btn {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    transition: transform 0.1s, opacity 0.2s;
}

.rb-primary-btn:hover {
    opacity: 0.95;
    transform: translateY(-1px);
}

.rb-primary-btn:active {
    transform: translateY(1px);
}

/* プレイ中画面 */
.rb-game-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 16px;
}

.badge-diff {
    background: rgba(129, 140, 248, 0.2);
    color: #c7d2fe;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.rb-prompt-box {
    background: rgba(15, 23, 42, 0.4);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 20px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rb-prompt-box p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.4;
}

.rb-prompt-box small {
    color: #94a3b8;
    font-size: 0.75rem;
}

/* 選択ボタン (RED / BLUE) */
.rb-choice-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.rb-choice-btn {
    border: none;
    border-radius: 14px;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.1s, filter 0.2s;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.rb-choice-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.rb-choice-btn:active {
    transform: translateY(2px);
}

.rb-choice-btn.rb-red {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.rb-choice-btn.rb-blue {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

.choice-icon {
    font-size: 2rem;
}

.choice-text {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.05em;
}

.choice-key {
    font-size: 0.65rem;
    opacity: 0.8;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

/* 結果発表エリア */
.rb-result-reveal {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.reveal-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #94a3b8;
}

.reveal-badge {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
}

.reveal-badge.red {
    background: #ef4444;
    color: white;
}

.reveal-badge.blue {
    background: #3b82f6;
    color: white;
}

.reveal-vs {
    font-weight: 800;
    color: #64748b;
    font-size: 0.9rem;
}

.reveal-outcome {
    grid-column: 1 / -1;
    margin-top: 8px;
    font-weight: 800;
    font-size: 1rem;
    padding: 6px;
    border-radius: 6px;
    text-align: center;
}

.reveal-outcome.win {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.reveal-outcome.lose {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.rb-action-row {
    display: flex;
    gap: 10px;
}

.rb-sub-btn {
    background: rgba(51, 65, 85, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.8rem;
    cursor: pointer;
    flex: 1;
    transition: background 0.2s;
}

.rb-sub-btn:hover {
    background: rgba(71, 85, 105, 0.8);
    color: #f8fafc;
}

.rb-sub-btn-alt {
    background: rgba(99, 102, 241, 0.3);
    border-color: rgba(99, 102, 241, 0.5);
    color: #c7d2fe;
}

/* ゲームオーバー画面 */
.gameover-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.gameover-score-box {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 10px;
    padding: 12px;
    margin: 14px 0;
    display: flex;
    justify-content: space-around;
    font-size: 0.9rem;
}

.gameover-score-box strong {
    color: #f87171;
    font-size: 1.1rem;
}

.gameover-msg {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 10px;
}

/* モーダル */
.rb-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    box-sizing: border-box;
}

.rb-modal-content {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.rb-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rb-modal-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #f8fafc;
}

.rb-close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
}

.rb-close-btn:hover {
    color: #f8fafc;
}

.rb-modal-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.stat-item {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 10px;
    text-align: center;
}

.stat-item .s-label {
    display: block;
    font-size: 0.7rem;
    color: #94a3b8;
    margin-bottom: 4px;
}

.stat-item .s-val {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f8fafc;
}

.habit-analysis-box {
    background: rgba(129, 140, 248, 0.1);
    border: 1px solid rgba(129, 140, 248, 0.2);
    border-radius: 10px;
    padding: 12px;
}

.habit-analysis-box h4 {
    margin: 0 0 6px 0;
    font-size: 0.85rem;
    color: #c7d2fe;
}

.habit-analysis-box p {
    margin: 0;
    font-size: 0.8rem;
    color: #cbd5e1;
    line-height: 1.4;
}

.history-log-section h4 {
    margin: 0 0 8px 0;
    font-size: 0.85rem;
    color: #94a3b8;
}

.rb-history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
}

.history-row {
    background: rgba(15, 23, 42, 0.4);
    border-radius: 6px;
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
}

.history-badges {
    display: flex;
    gap: 6px;
}

.h-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
}

.h-badge.red { background: rgba(239, 68, 68, 0.3); color: #f87171; }
.h-badge.blue { background: rgba(59, 130, 246, 0.3); color: #60a5fa; }

.history-row.win { border-left: 3px solid #22c55e; }
.history-row.lose { border-left: 3px solid #ef4444; }

.no-history {
    text-align: center;
    color: #64748b;
    font-size: 0.8rem;
    margin: 10px 0;
}

.modal-footer-btns {
    display: flex;
    justify-content: flex-end;
}

.rb-danger-btn {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

.rb-danger-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

.redblue-footer-tip {
    text-align: center;
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 10px;
}
