/* --- Coin Theme (Gold) --- */
:root {
    --coin-bg: #FFFBEB;       /* Amber Light */
    --coin-card-bg: #FEF3C7;  /* Amber 100 */
    --coin-gold: #F59E0B;     /* Amber 500 */
    --coin-gold-dark: #B45309;/* Amber 700 */
    --coin-text: #78350F;     /* Amber 900 */
    --coin-size: 150px;
    
    /* New Accent mapping for Info-Wrapper */
    --accent-coin: var(--coin-gold);
    --accent-coin-light: var(--coin-card-bg);
}

.calc-header { margin-bottom: 32px; }
.subtitle { color: var(--text-secondary); margin-top: 8px; }

.calc-grid { display: grid; grid-template-columns: 1fr; gap: 24px; align-items: start; }
@media (min-width: 900px) { .calc-grid { grid-template-columns: 1.5fr 1fr; } }

/* --- ARENA --- */
.card--coin {
    background: var(--coin-card-bg);
    border: 2px solid #FCD34D;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 60px 20px;
    min-height: 550px; 
    overflow: hidden; 
    position: relative;
    background-image: radial-gradient(circle at center, #FFFBEB 0%, #FEF3C7 70%);
    perspective: 1200px;
}

.coin-scene {
    position: relative;
    width: 100%; height: 400px;
    display: flex; justify-content: center; align-items: center;
    transform-style: preserve-3d;
    z-index: 1;
}

/* --- ПОЛ --- */
.coin-floor {
    position: absolute;
    top: 50%; left: 50%; 
    width: 400px; height: 400px; 
    background: radial-gradient(circle, rgba(180, 83, 9, 0.2) 0%, transparent 60%);
    border-radius: 50%;
    transform: translate(-50%, -50%) rotateX(90deg) scale(0);
    margin-top: 70px;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1;
    pointer-events: none;
}
.coin-floor.visible { transform: translate(-50%, -50%) rotateX(90deg) scale(1); }

/* --- 3D COIN --- */
.coin-container {
    width: var(--coin-size);
    height: var(--coin-size);
    position: relative;
    z-index: 10;
    transform-style: preserve-3d;
    transform: translateY(0);
}

.coin-container.is-falling { animation: tossAndFall 2.2s cubic-bezier(0.45, 0.05, 0.55, 0.95) forwards; }
@keyframes tossAndFall {
    0% { transform: translateY(0) scale(1) rotateX(0); }
    40% { transform: translateY(-350px) scale(0.7) rotateX(0); }
    100% { transform: translateY(60px) scale(0.4) rotateX(75deg); } 
}

.coin-container.is-lifting {
    transform: translateY(60px) scale(0.4) rotateX(75deg);
    animation: liftUp 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes liftUp {
    0% { transform: translateY(60px) scale(0.4) rotateX(75deg); }
    60% { transform: translateY(-20px) scale(1.1) rotateX(-10deg); }
    100% { transform: translateY(0) scale(1.3) rotateX(0) translateZ(50px); }
}

.coin { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; }

.coin__face {
    position: absolute; width: 100%; height: 100%; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    backface-visibility: hidden;
    box-shadow: inset 0 0 20px rgba(180, 83, 9, 0.6);
    border: 8px solid var(--coin-gold);
    background: linear-gradient(135deg, #FCD34D 0%, #F59E0B 50%, #D97706 100%);
}

.face-content {
    display: flex; flex-direction: column; align-items: center;
    color: #78350F; text-shadow: 0 1px 0 rgba(255,255,255,0.4); margin-top: -5px;
}
.face-content i { font-size: 64px; line-height: 1; margin-bottom: 2px; }
.face-content span { font-size: 18px; font-weight: 800; text-transform: uppercase; letter-spacing: 2px; line-height: 1; }

.coin__face--heads { transform: rotateX(0deg); }
.coin__face--tails { transform: rotateX(180deg); }

.coin__edge {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    border-radius: 50%; transform: translateZ(-4px);
    border: 8px solid #B45309; opacity: 0; transition: opacity 0.2s;
}
.coin.is-spinning .coin__edge { opacity: 1; }

.coin.spin-animation { animation: constantSpin 0.4s linear infinite; }
@keyframes constantSpin { 0% { transform: rotateX(0); } 100% { transform: rotateX(360deg); } }

/* Shadow */
.coin-shadow {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 140px; height: 140px;
    background: radial-gradient(circle, rgba(180, 83, 9, 0.5) 0%, transparent 70%);
    opacity: 0; margin-top: 60px; transition: all 0.3s; z-index: 2; filter: blur(10px);
}
.card--coin.falling .coin-shadow { animation: shadowAppear 2.2s forwards; }
@keyframes shadowAppear {
    0% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
    40% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(0.4); }
}
.card--coin.lifting .coin-shadow { opacity: 0; transition: opacity 0.5s; }

/* Controls */
.flip-btn {
    padding: 16px 48px; font-size: 18px; font-weight: 700;
    color: #fff; background: linear-gradient(to bottom, #D97706, #B45309);
    border: none; border-radius: 99px;
    cursor: pointer; box-shadow: 0 8px 20px rgba(180, 83, 9, 0.3);
    transition: all 0.2s; position: relative; z-index: 30; margin-top: -30px;
}
.flip-btn:hover { transform: translateY(-2px); background: linear-gradient(to bottom, #F59E0B, #D97706); }
.flip-btn:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
.coin-status { margin-top: 20px; font-size: 15px; font-weight: 600; color: var(--coin-text); min-height: 24px; }

/* --- STATS & HISTORY HEADER FIX --- */
.history-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 16px; 
    gap: 16px; /* Гарантированный отступ */
}

.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #9CA3AF; font-weight: 700; margin: 0; }

/* Новая кнопка сброса */
.reset-action {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; color: #92400E;
    background: #FFF7ED; border: 1px solid #FDE68A;
    padding: 6px 12px; border-radius: 99px;
    cursor: pointer; text-decoration: none;
    transition: all 0.2s;
    flex-shrink: 0; /* Не сжиматься */
}
.reset-action:hover { background: #FDE68A; color: #78350F; transform: translateY(-1px); }
.reset-action i { font-size: 14px; }

/* Stats Bar */
.stats-bar { display: flex; gap: 12px; margin-bottom: 24px; }
.stat-pill { flex: 1; padding: 12px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; border: 1px solid #E5E7EB; background: #fff; overflow: hidden; }
.stat-heads { border-bottom: 3px solid #F59E0B; }
.stat-tails { border-bottom: 3px solid #92400E; }
.stat-pill .label { font-size: 11px; text-transform: uppercase; opacity: 0.7; }
.stat-pill .count { font-size: 20px; font-weight: 800; color: #1F2937; line-height: 1.2; }
.stat-pill .percent { font-size: 11px; font-weight: 600; color: #6B7280; }

.divider { height: 1px; background: #E5E7EB; margin: 24px 0; width: 100%; }
.history-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.history-item { display: flex; justify-content: space-between; align-items: center; background: #fff; padding: 10px 14px; border-radius: 8px; border: 1px solid #F3F4F6; font-size: 14px; animation: slideIn 0.3s ease-out; }
.res-heads { color: #F59E0B; font-weight: 700; }
.res-tails { color: #92400E; font-weight: 700; }
.history-time { font-size: 11px; color: #9CA3AF; }
.empty-history { text-align: center; color: #D1D5DB; font-size: 13px; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }

@media (max-width: 480px) {
    .card--coin { min-height: 500px; padding: 40px 20px; }
    :root { --coin-size: 130px; }
    .face-content i { font-size: 48px; }
    @keyframes tossAndFall {
        0% { transform: translateY(0) scale(1) rotateX(0); }
        40% { transform: translateY(-250px) scale(0.7) rotateX(0); }
        100% { transform: translateY(60px) scale(0.4) rotateX(75deg); }
    }
}

/* --- НОВЫЕ ИНФОРМАЦИОННЫЕ БЛОКИ (Coin Theme) --- */

.info-wrapper {
    padding: 60px 0 60px 0;
    margin-top: 60px;
    border-top: 1px solid rgba(0,0,0,0.06);
    margin-bottom: 20px;
}

/* Центрирование контента */
.formulas-section,
.calc-description,
.faq-section {
    max-width: 800px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Заголовки с иконками */
.icon-heading {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.3;
}

.header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
    flex-shrink: 0;
    margin-top: -4px;
}

.header-icon svg { width: 24px; height: 24px; stroke-width: 2px; }

/* Цвета иконок */
.blue-icon svg { color: #2563EB; }
.orange-icon svg { color: #F59E0B; }
.green-icon svg { color: #10B981; }
.red-icon svg { color: #E11D48; }
.purple-icon svg { color: #9333EA; }
.yellow-icon svg { color: var(--coin-gold); } /* Gold/Amber icon */

/* Маленькие подзаголовки */
.small-heading {
    margin-top: 40px;
    margin-bottom: 16px;
    font-size: 20px;
}
.small-heading .header-icon { width: 40px; height: 40px; }
.small-heading .header-icon svg { width: 20px; height: 20px; }

.intro-text {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.6;
}

/* --- Секция Формул --- */
.formulas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 48px;
}

.formula-card {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.04);
    box-shadow: var(--shadow-soft);
    border-radius: var(--radius-lg); 
    padding: 24px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
}
.formula-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }

/* Вертикальный хедер (бейдж сверху) */
.formula-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.formula-card h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

/* Бейджи */
.badge-blue {
    background: #2563EB; color: #fff;
    padding: 6px 12px; border-radius: 99px;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    display: inline-block;
}
.badge-green {
    background: #10B981; color: #fff;
    padding: 6px 12px; border-radius: 99px;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    display: inline-block;
}

.formula-card p {
    font-size: 14px; color: var(--text-secondary);
    margin: 0; line-height: 1.5; font-weight: 500;
}

.math-expression {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 700;
    color: var(--accent-coin); /* Gold/Amber акцент для формул */
    text-align: center;
    margin-bottom: 16px;
    font-size: 15px;
}

/* Разделитель */
.soft-divider {
    border: none; height: 1px;
    background: linear-gradient(90deg, transparent, #E5E7EB, transparent);
    margin: 48px auto;
    max-width: 800px;
    width: 100%;
}

/* Описание */
.calc-description p {
    font-size: 16px; line-height: 1.7;
    color: var(--text-secondary); margin-bottom: 24px;
}
.calc-description strong { color: var(--text-primary); }

/* FAQ (Coin) */
.faq-section .faq-item {
    background: #fff; border: 1px solid #E5E7EB;
    border-radius: 12px; margin-bottom: 12px;
    overflow: hidden; transition: all 0.2s ease;
}

.faq-section .faq-item[open] {
    border-color: var(--accent-coin); 
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.15); /* Amber shadow */
}

.faq-section summary.faq-question {
    padding: 16px 20px; cursor: pointer;
    font-weight: 600; color: var(--text-primary);
    list-style: none; position: relative;
    display: flex; justify-content: space-between;
    align-items: center; transition: background 0.2s;
}

.faq-section summary.faq-question:hover { background-color: #F9FAFB; }

.faq-section .faq-item[open] summary.faq-question {
    color: var(--accent-coin);
    background: var(--accent-coin-light);
}

.faq-question::after {
    content: '+'; font-size: 20px;
    color: var(--text-secondary); font-weight: 400; line-height: 1;
}
.faq-question .icon-plus { display: none; }

.faq-section .faq-item[open] summary.faq-question::after {
    content: '−'; color: var(--accent-coin);
}

.faq-answer {
    padding: 20px; color: var(--text-secondary);
    line-height: 1.6; font-size: 15px;
}

/* --- МОБИЛЬНАЯ АДАПТАЦИЯ --- */
@media (max-width: 900px) {
    .formulas-grid { grid-template-columns: 1fr; gap: 16px; margin-bottom: 32px; }
    
    .icon-heading { font-size: 20px; gap: 12px; margin-bottom: 20px; }
    .header-icon { width: 40px; height: 40px; border-radius: 12px; }
    .header-icon svg { width: 20px; height: 20px; }
    
    .formula-card { 
        padding: 24px; 
        text-align: center; 
        align-items: center; 
    }

    .formula-header {
        align-items: center;
        width: 100%;
    }

    .math-expression {
        width: 100%;
        max-width: 300px;
        margin-left: auto;
        margin-right: auto;
    }

    .info-wrapper { margin-top: 40px; padding-top: 40px; }
}