/**
 * FebeClassMaster 2.0 — Unified Tablet & Smartboard Responsive Design System
 * Supports:
 *   - Classroom Smartboards / Big Screens (1920x1080, 1440x900)
 *   - Tablets in Landscape & Portrait (iPad 1024x768, 768x1024, Android Tablets)
 *   - Mobile fallback (< 768px)
 */

:root {
    --fcm-bg: #FFF9E6;
    --fcm-surface: #FFFFFF;
    --fcm-surface-soft: #FFFDF7;
    --fcm-border: #E0D0B0;
    --fcm-text: #2C3140;
    --fcm-muted: #78716C;
    --fcm-primary: #FF8A00;
    --fcm-primary-dark: #D97706;
    --fcm-secondary: #10B981;
    --fcm-secondary-dark: #059669;
    --fcm-accent: #3B82F6;
    --fcm-accent-dark: #2563EB;
    --fcm-danger: #EF4444;
    --fcm-danger-dark: #DC2626;
    --fcm-purple: #8B5CF6;
    --fcm-radius-lg: 24px;
    --fcm-radius-md: 16px;
    --fcm-radius-sm: 12px;
    --fcm-shadow-card: 0 5px 0 #E0D0B0, 0 10px 24px rgba(120, 83, 24, 0.06);
}

/* Override any rigid body/app locks from base stylesheets */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: var(--fcm-bg);
    color: var(--fcm-text);
    font-family: 'Outfit', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

#fcm-app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
    position: relative;
    background-image: radial-gradient(rgba(224, 208, 176, 0.38) 2px, transparent 2px);
    background-size: 28px 28px;
}

/* ══════════════════════════════════════════════════════════════════
   1. TOP NAVIGATION BAR (Responsive Big Screen + Tablet)
   ══════════════════════════════════════════════════════════════════ */
.fcm-topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 3px solid var(--fcm-border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    z-index: 100;
}

.fcm-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.fcm-brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: linear-gradient(135deg, #FF8A00, #F59E0B);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 900;
    box-shadow: 0 3px 0 #D97706;
}

.fcm-brand-text h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 900;
    color: var(--fcm-text);
    line-height: 1.15;
}

.fcm-brand-text span {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: var(--fcm-primary-dark);
    letter-spacing: 0.3px;
}

/* Module Navigation Pills */
.fcm-nav-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #F5EFE0;
    padding: 5px;
    border-radius: 18px;
    border: 2px solid var(--fcm-border);
}

.fcm-nav-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    min-height: 44px;
    border: 2px solid transparent;
    border-radius: 13px;
    background: transparent;
    color: #57534E;
    font-family: inherit;
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.fcm-nav-tab:hover {
    color: var(--fcm-primary-dark);
    background: rgba(255, 255, 255, 0.55);
}

.fcm-nav-tab.active {
    background: #FFFFFF;
    color: var(--fcm-primary);
    border-color: var(--fcm-primary);
    box-shadow: 0 3px 0 var(--fcm-primary);
    transform: translateY(-1px);
}

.fcm-nav-tab .tab-icon {
    font-size: 18px;
}

/* Topbar Right Quick Actions */
.fcm-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.fcm-score-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    min-height: 40px;
    border-radius: 999px;
    background: #FFF;
    border: 2px solid var(--fcm-border);
    box-shadow: 0 3px 0 var(--fcm-border);
    font-weight: 900;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.15s;
}

.fcm-score-pill:active {
    transform: translateY(2px);
    box-shadow: none;
}

.fcm-score-pill .team-red {
    color: #DC2626;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.fcm-score-pill .team-blue {
    color: #2563EB;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.fcm-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 42px;
    height: 42px;
    padding: 0 12px;
    border-radius: 12px;
    border: 2px solid var(--fcm-border);
    background: #FFFFFF;
    color: var(--fcm-text);
    box-shadow: 0 3px 0 var(--fcm-border);
    font-family: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
}

.fcm-icon-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

/* Tablet Portrait & Compact Landscape Topbar Adaptation */
@media (max-width: 1080px) {
    .fcm-topbar {
        flex-wrap: wrap;
        padding: 8px 14px;
        gap: 8px;
    }
    .fcm-brand {
        order: 1;
    }
    .fcm-topbar-actions {
        order: 2;
        margin-left: auto;
    }
    .fcm-nav-tabs {
        order: 3;
        width: 100%;
        justify-content: stretch;
        overflow-x: auto;
    }
    .fcm-nav-tab {
        flex: 1 1 0;
        padding: 8px 10px;
        font-size: 14px;
    }
}

@media (max-width: 640px) {
    .fcm-brand-text span {
        display: none;
    }
    .fcm-nav-tab {
        flex-direction: column;
        gap: 2px;
        padding: 6px 4px;
        font-size: 12px;
    }
}

/* ══════════════════════════════════════════════════════════════════
   2. MAIN WORKSPACE & MODULE PANELS
   ══════════════════════════════════════════════════════════════════ */
.fcm-workspace {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: clamp(12px, 2vw, 24px);
    box-sizing: border-box;
}

.fcm-module {
    display: none;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    animation: fcmFadeIn 0.22s ease-out;
}

.fcm-module.active {
    display: block;
}

@keyframes fcmFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Prevent EdenAbacus global button rule from stretching buttons inside our modules */
.fcm-module button,
.fcm-modal-backdrop button,
.fcm-stage-toolbar button {
    width: auto;
    max-width: none;
    height: auto;
    margin: 0;
}

/* ══════════════════════════════════════════════════════════════════
   3. MODULE 1: EDEN ABACUS CLASSROOM MODE (课堂投屏出题)
   ══════════════════════════════════════════════════════════════════ */
.fcm-classroom-layout {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding-bottom: 28px;
}

.fcm-classroom-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    padding: 18px 24px;
    background: linear-gradient(135deg, #FFF7ED 0%, #FFEDD5 100%);
    border: 3px solid #FDBA74;
    border-radius: var(--fcm-radius-lg);
    box-shadow: 0 5px 0 #FDBA74;
}

.fcm-classroom-banner-info h2 {
    margin: 0 0 4px 0;
    font-size: clamp(18px, 2.2vw, 24px);
    font-weight: 900;
    color: #9A3412;
}

.fcm-classroom-banner-info p {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #C2410C;
}

.fcm-launch-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 32px !important;
    min-height: 56px !important;
    border-radius: 18px !important;
    border: none !important;
    background: linear-gradient(135deg, #FF8A00, #EA580C) !important;
    color: #FFFFFF !important;
    font-size: 18px !important;
    font-weight: 900 !important;
    box-shadow: 0 6px 0 #9A3412, 0 12px 24px rgba(234, 88, 12, 0.28) !important;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.fcm-launch-btn:hover {
    transform: translateY(-2px);
}

.fcm-launch-btn:active {
    transform: translateY(4px) !important;
    box-shadow: 0 2px 0 #9A3412 !important;
}

/* Responsive 2-column card grid for SettingsManagerV2 on wide screens */
#fcm-classroom-settings-mount .v2-settings-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    max-width: 100%;
    width: 100%;
    align-items: start;
}

#fcm-classroom-settings-mount .v2-setting-card {
    max-width: 100%;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
}

/* Span wide formula matrices across both columns on desktop */
#fcm-classroom-settings-mount .v2-setting-card[data-id="subStages"],
#fcm-classroom-settings-mount .v2-setting-card[data-id="level"] {
    grid-column: span 2;
}

@media (max-width: 960px) {
    #fcm-classroom-settings-mount .v2-settings-list {
        grid-template-columns: 1fr;
    }
    #fcm-classroom-settings-mount .v2-setting-card[data-id="subStages"],
    #fcm-classroom-settings-mount .v2-setting-card[data-id="level"] {
        grid-column: span 1;
    }
    .fcm-launch-btn {
        width: 100% !important;
    }
}

/* ── FULLSCREEN PLAYER OVERLAY (#v2-screen-player) ── */
#v2-screen-player {
    position: fixed;
    inset: 0;
    z-index: 2500;
    background: var(--v2-bg-main, #FFF9E6);
    display: none;
    flex-direction: column;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
}

#v2-screen-player.active {
    display: flex;
}

.fcm-player-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 3px solid var(--fcm-border);
    z-index: 20;
}

.fcm-player-header-left,
.fcm-player-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fcm-progress-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 999px;
    background: #FFF7ED;
    border: 2px solid #FDBA74;
    color: #C2410C;
    font-size: 18px;
    font-weight: 900;
}

.fcm-stage-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px !important;
    min-height: 46px !important;
    border-radius: 14px !important;
    border: 2px solid var(--fcm-border) !important;
    background: #FFFFFF !important;
    color: var(--fcm-text) !important;
    box-shadow: 0 4px 0 var(--fcm-border) !important;
    font-size: 15px !important;
    font-weight: 900 !important;
    cursor: pointer;
    transition: transform 0.12s;
}

.fcm-stage-btn:active {
    transform: translateY(3px) !important;
    box-shadow: none !important;
}

.fcm-stage-btn.primary {
    background: var(--fcm-primary) !important;
    border-color: var(--fcm-primary-dark) !important;
    color: #FFFFFF !important;
    box-shadow: 0 4px 0 var(--fcm-primary-dark) !important;
}

.fcm-stage-btn.danger {
    background: #FEF2F2 !important;
    border-color: #FECACA !important;
    color: #DC2626 !important;
    box-shadow: 0 4px 0 #FECACA !important;
}

.fcm-stage-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 20px max(14px, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.94);
    border-top: 3px solid var(--fcm-border);
    z-index: 20;
}

.fcm-stage-next-btn {
    min-width: 240px !important;
    min-height: 54px !important;
    font-size: 18px !important;
    background: linear-gradient(135deg, #10B981, #059669) !important;
    border-color: #047857 !important;
    color: #FFFFFF !important;
    box-shadow: 0 5px 0 #047857 !important;
}

/* Temporary peek state when teacher holds/toggles peek on frosted glass */
#v2-screen-player.peek-active #v2-look-cover {
    opacity: 0.08 !important;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* ══════════════════════════════════════════════════════════════════
   4. MODULE 2: ABACUS V2 & GUIDED FINGERING (算盘演示与逐口跟拨)
   ══════════════════════════════════════════════════════════════════ */
.fcm-subnav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #FFFFFF;
    border: 3px solid var(--fcm-border);
    border-radius: var(--fcm-radius-lg);
    box-shadow: var(--fcm-shadow-card);
}

.fcm-submode-pills {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.fcm-submode-pill {
    padding: 10px 18px;
    min-height: 44px;
    border-radius: 14px;
    border: 2px solid var(--fcm-border);
    background: #FAF5E8;
    color: var(--fcm-text);
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.15s;
}

.fcm-submode-pill.active {
    background: var(--fcm-primary);
    border-color: var(--fcm-primary-dark);
    color: #FFFFFF;
    box-shadow: 0 3px 0 var(--fcm-primary-dark);
}

.fcm-abacus-panel {
    display: none;
}

.fcm-abacus-panel.active {
    display: block;
}

/* Free Abacus Sandbox */
.fcm-sandbox-card {
    background: #FFFFFF;
    border: 3px solid var(--fcm-border);
    border-radius: var(--fcm-radius-lg);
    box-shadow: var(--fcm-shadow-card);
    padding: clamp(14px, 2.2vw, 26px);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.fcm-sandbox-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 2px dashed var(--fcm-border);
}

.fcm-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.fcm-control-label {
    font-size: 13px;
    font-weight: 900;
    color: var(--fcm-muted);
}

.fcm-chip-btn {
    padding: 8px 14px;
    min-height: 40px;
    border-radius: 12px;
    border: 2px solid var(--fcm-border);
    background: #FFF9E6;
    color: var(--fcm-text);
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.15s;
}

.fcm-chip-btn.active {
    background: var(--fcm-accent);
    border-color: var(--fcm-accent-dark);
    color: #FFFFFF;
    box-shadow: 0 3px 0 var(--fcm-accent-dark);
}

.fcm-sandbox-readout-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 12px 20px;
    background: #FFFBEB;
    border: 2px solid #FDE68A;
    border-radius: 18px;
}

.fcm-sandbox-value-box {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.fcm-sandbox-value-box .lbl {
    font-size: 14px;
    font-weight: 900;
    color: #92400E;
}

.fcm-sandbox-value-box .val {
    font-size: clamp(32px, 5vw, 54px);
    font-weight: 900;
    color: var(--fcm-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

#fcm-free-abacus-mount {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

#fcm-free-abacus-mount .abv2-frame {
    width: 100%;
    box-sizing: border-box;
    --abv2-b: clamp(24px, 4.2vw, 48px) !important;
}

@media (max-width: 900px) {
    #fcm-free-abacus-mount .abv2-frame {
        --abv2-b: clamp(20px, 5.2vw, 38px) !important;
    }
}

/* Place value bar under sandbox abacus */
.fcm-place-labels {
    display: flex;
    width: 100%;
    max-width: 1200px;
    margin: -6px auto 0;
    padding: 0 clamp(12px, 3.2vw, 24px);
    box-sizing: border-box;
}

.fcm-place-labels span {
    flex: 1;
    text-align: center;
    font-size: 12px;
    font-weight: 900;
    color: var(--fcm-muted);
}

.fcm-place-labels span.unit-rod {
    color: var(--fcm-primary-dark);
    font-weight: 900;
}

/* Guided Abacus Stage (In-Module & Responsive) */
.fcm-guided-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    padding: 12px 18px;
    background: #FFFFFF;
    border: 3px solid var(--fcm-border);
    border-radius: var(--fcm-radius-md);
}

.fcm-guided-stage-card {
    background: #FFFFFF;
    border: 3px solid var(--fcm-border);
    border-radius: var(--fcm-radius-lg);
    box-shadow: var(--fcm-shadow-card);
    padding: 20px;
    min-height: 480px;
    display: flex;
    flex-direction: column;
}

.fcm-guided-stage-card .v2-player-stage {
    min-height: 440px;
}

/* Landscape / Big Screen side-by-side layout for Guided Abacus */
@media (min-width: 860px) {
    .fcm-guided-stage-card .guided-abacus-wrap {
        display: grid;
        grid-template-columns: minmax(220px, 340px) minmax(0, 1fr);
        gap: 24px;
        align-items: center;
        width: 100%;
    }
    .fcm-guided-stage-card .guided-abacus-wrap .abv2-question {
        max-height: 420px;
        height: 100%;
        background: #FFFDF7;
        border: 2px dashed var(--fcm-border);
        border-radius: 20px;
        padding: 16px;
        box-sizing: border-box;
    }
}

/* ══════════════════════════════════════════════════════════════════
   5. MODULE 3: CLASSROOM MINI-GAMES (8款趣味小游戏)
   ══════════════════════════════════════════════════════════════════ */
.fcm-games-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    padding: 16px 22px;
    background: #FFFFFF;
    border: 3px solid var(--fcm-border);
    border-radius: var(--fcm-radius-lg);
    box-shadow: var(--fcm-shadow-card);
}

.fcm-games-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

@media (max-width: 1180px) {
    .fcm-games-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .fcm-games-grid {
        grid-template-columns: 1fr;
    }
}

.fcm-game-card {
    background: #FFFFFF;
    border: 3px solid var(--fcm-border);
    border-radius: var(--fcm-radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: var(--fcm-shadow-card);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease;
    position: relative;
    overflow: hidden;
}

.fcm-game-card:hover {
    transform: translateY(-4px);
    border-color: var(--fcm-primary);
}

.fcm-game-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.fcm-game-icon {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    background: #FFF7ED;
    border: 2px solid #FDBA74;
}

.fcm-game-tag {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 900;
    background: #FEF3C7;
    color: #B45309;
}

.fcm-game-card h3 {
    margin: 4px 0 0;
    font-size: 18px;
    font-weight: 900;
    color: var(--fcm-text);
}

.fcm-game-card p {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--fcm-muted);
    line-height: 1.45;
    flex: 1;
}

.fcm-game-play-btn {
    margin-top: 6px;
    padding: 10px 16px;
    border-radius: 12px;
    background: var(--fcm-primary);
    color: #FFFFFF;
    font-weight: 900;
    font-size: 14px;
    text-align: center;
    box-shadow: 0 3px 0 var(--fcm-primary-dark);
}

/* Active Game Arena */
.fcm-game-arena {
    display: none;
    flex-direction: column;
    gap: 14px;
    background: #FFFFFF;
    border: 3px solid var(--fcm-border);
    border-radius: var(--fcm-radius-lg);
    box-shadow: var(--fcm-shadow-card);
    overflow: hidden;
    min-height: calc(100dvh - 130px);
}

.fcm-game-arena.active {
    display: flex;
}

.fcm-arena-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 18px;
    background: #FFFBEB;
    border-bottom: 3px solid var(--fcm-border);
}

.fcm-arena-left,
.fcm-arena-center,
.fcm-arena-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.fcm-arena-title {
    font-size: 18px;
    font-weight: 900;
    color: var(--fcm-text);
}

.fcm-arena-select {
    padding: 8px 12px;
    min-height: 40px;
    border-radius: 12px;
    border: 2px solid var(--fcm-border);
    background: #FFFFFF;
    color: var(--fcm-text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
}

.fcm-stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    min-height: 38px;
    border-radius: 12px;
    background: #FFFFFF;
    border: 2px solid var(--fcm-border);
    font-size: 15px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.fcm-arena-stage {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(14px, 2.2vw, 28px);
    position: relative;
    min-height: 480px;
    box-sizing: border-box;
}

/* ══════════════════════════════════════════════════════════════════
   6. MODULE 4: CLASSROOM INTERACTIVE TOOLS (课堂互动工具箱)
   ══════════════════════════════════════════════════════════════════ */
.fcm-tools-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    align-items: stretch;
}

@media (max-width: 1100px) {
    .fcm-tools-grid {
        grid-template-columns: 1fr;
    }
}

.fcm-tool-card {
    background: #FFFFFF;
    border: 3px solid var(--fcm-border);
    border-radius: var(--fcm-radius-lg);
    box-shadow: var(--fcm-shadow-card);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.fcm-tool-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 2px dashed var(--fcm-border);
    padding-bottom: 12px;
}

.fcm-tool-card-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fcm-picker-display {
    min-height: 140px;
    border-radius: 20px;
    background: linear-gradient(135deg, #FFF7ED, #FEF3C7);
    border: 3px solid #FDBA74;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
}

.fcm-picker-name {
    font-size: clamp(32px, 4vw, 48px);
    font-weight: 900;
    color: #9A3412;
}

.fcm-timer-display {
    font-size: clamp(48px, 6vw, 72px);
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    text-align: center;
    color: var(--fcm-text);
    padding: 20px;
    background: #F8FAFC;
    border: 3px solid var(--fcm-border);
    border-radius: 20px;
}

.fcm-timer-display.urgent {
    color: var(--fcm-danger);
    background: #FEF2F2;
    border-color: #FECACA;
    animation: fcmPulse 0.8s infinite;
}

@keyframes fcmPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.fcm-team-versus {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    flex: 1;
}

.fcm-team-box {
    border-radius: 20px;
    padding: 18px 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.fcm-team-box.red {
    background: #FEF2F2;
    border: 3px solid #FCA5A5;
    color: #991B1B;
}

.fcm-team-box.blue {
    background: #EFF6FF;
    border: 3px solid #93C5FD;
    color: #1E40AF;
}

.fcm-team-score {
    font-size: clamp(44px, 5vw, 68px);
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.fcm-team-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ══════════════════════════════════════════════════════════════════
   7. MODALS (Answer Sheet, Formula Review, Victory Podium)
   ══════════════════════════════════════════════════════════════════ */
.fcm-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3500;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.fcm-modal-backdrop.active {
    display: flex;
}

.fcm-modal-card {
    background: #FFFFFF;
    border: 4px solid var(--fcm-border);
    border-radius: 28px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    width: min(960px, 100%);
    max-height: calc(100dvh - 36px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fcmFadeIn 0.2s ease-out;
}

.fcm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: #FFFBEB;
    border-bottom: 3px solid var(--fcm-border);
}

.fcm-modal-header h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 900;
    color: var(--fcm-text);
}

.fcm-modal-body {
    padding: 22px 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.fcm-answer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}

.fcm-answer-cell {
    background: #FFFDF7;
    border: 2px solid var(--fcm-border);
    border-radius: 16px;
    padding: 12px 14px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}

.fcm-answer-cell:hover {
    transform: translateY(-2px);
    border-color: var(--fcm-primary);
}

.fcm-answer-cell .q-num {
    font-size: 12px;
    font-weight: 900;
    color: var(--fcm-muted);
}

.fcm-answer-cell .q-ans {
    font-size: 28px;
    font-weight: 900;
    color: var(--fcm-secondary-dark);
    margin: 4px 0;
    font-variant-numeric: tabular-nums;
}

.fcm-answer-cell .q-expr {
    font-size: 12px;
    font-weight: 700;
    color: #57534E;
    word-break: break-all;
}
