/* ===============================
   RESET
================================*/

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    padding: 20px;
    color: #222;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ===============================
   HEADER
================================*/

.header {
    text-align: center;
    color: #333;
    margin-bottom: 40px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
    color: #fc5768;
}

.header p {
    font-size: 1.1rem;
    color: #666;
}

/* ===============================
   SIMULATOR BOX
================================*/

.simulator-box {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    margin-bottom: 30px;
}

.input-section {
    margin-bottom: 40px;
}

/* ===============================
   INPUT
================================*/

.input-group {
    margin-bottom: 30px;
}

.input-group label {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.input-row input {
    flex: 1;
    padding: 15px 20px;
    font-size: 1.2rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    transition: all 0.3s;
}

.input-row input:focus {
    outline: none;
    border-color: #fc5768;
    box-shadow: 0 0 0 3px rgba(252, 87, 104, 0.1);
}

.input-row select {
    padding: 15px 20px;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    min-width: 150px;
}

/* ===============================
   RADIO (もし使う場合用)
================================*/

.radio-group {
    display: flex;
    gap: 20px;
    margin-top: 10px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.radio-option input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.radio-option label {
    margin: 0;
    cursor: pointer;
    font-weight: 500;
}

/* ===============================
   PLAN SELECTOR
================================*/

.plan-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.plan-card {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.plan-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.plan-card.selected {
    border-color: #fc5768;
    background: linear-gradient(135deg, rgba(252, 87, 104, 0.08), rgba(252, 87, 104, 0.08));
}

.plan-card .period {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
}

.plan-card .rate {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fc5768;
    margin-bottom: 5px;
}

.plan-card .label {
    font-size: 0.9rem;
    color: #666;
}

/* ===============================
   TIER SELECTOR
================================*/

.tier-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.tier-card {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
}

.tier-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.tier-card.selected {
    border-color: #fc5768;
    background: linear-gradient(135deg, rgba(252, 87, 104, 0.08), rgba(252, 87, 104, 0.08));
}

.tier-card .tier-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.tier-card .tier-range {
    font-size: 0.95rem;
    color: #666;
    margin-bottom: 5px;
}

.tier-card .tier-bonus {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fc5768;
}

.tier-card .tier-note {
    font-size: 0.85rem;
    color: #999;
    margin-top: 5px;
    font-style: italic;
}

/* ===============================
   CHECKBOX
================================*/

.checkbox-group {
    margin-top: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.checkbox-option {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.checkbox-option input[type="checkbox"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.checkbox-option label {
    margin: 0;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
}

.checkbox-description {
    margin-top: 8px;
    padding-left: 36px;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.6;
}

/* ===============================
   BUTTON
================================*/

.calculate-btn {
    width: 100%;
    padding: 18px;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    background: #fc5768;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 20px;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(252, 87, 104, 0.4);
    background: #fd6b7c;
}

/* ===============================
   RESULT SECTION
================================*/

.result-section {
    display: none;
    margin-top: 40px;
}

.result-section.show {
    display: block;
}

.result-header {
    text-align: center;
    margin-bottom: 30px;
}

.result-header h2 {
    font-size: 2rem;
    color: #333;
    margin-bottom: 10px;
}

.result-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.result-card {
    background: #fc5768;
    color: white;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
}

.result-card .label {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 8px;
}

.result-card .value {
    font-size: 2rem;
    font-weight: 700;
}

.result-card .unit {
    font-size: 1rem;
    opacity: 0.9;
    margin-left: 5px;
}

/* ===============================
   TIMELINE TABLE
================================*/

.timeline-section {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
}

.timeline-header {
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 20px;
}

.timeline-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
}

.timeline-table th {
    background: #fc5768;
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

.timeline-table td {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    color: #333;
}

.timeline-table tr:last-child td {
    border-bottom: none;
}

.timeline-table tr:hover {
    background: #f8f9fa;
}

.highlight {
    color: #fc5768;
    font-weight: 700;
}

/* ===============================
   BAR CHART
================================*/

.chart-container {
    background: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
}

.chart-header {
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 20px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 300px;
    border-bottom: 2px solid #e0e0e0;
    padding: 20px 0;
}

.bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 120px;
}

.bar {
    width: 60px;
    background: linear-gradient(to top, #fc5768 0%, #fd8692 100%);
    border-radius: 8px 8px 0 0;
    position: relative;
    transition: all 0.3s;
}

.bar:hover {
    opacity: 0.8;
}

.bar-value {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    font-weight: 700;
    color: #fc5768;
    white-space: nowrap;
}

.bar-label {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #666;
    text-align: center;
}

/* ===============================
   FORMULA SECTION
================================*/

.formula-section {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
}

.formula-header {
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 20px;
}

.formula-content {
    background: white;
    padding: 25px;
    border-radius: 10px;
    border-left: 4px solid #fc5768;
}

.formula-item {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.formula-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.formula-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fc5768;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.formula-title .period-badge {
    background: #fc5768;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
}

.formula-expression {
    font-family: 'Courier New', monospace;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 0.95rem;
    color: #333;
    line-height: 1.8;
    overflow-x: auto;
}

.formula-expression .highlight {
    color: #fc5768;
    font-weight: 700;
}

.formula-result {
    font-size: 1rem;
    color: #333;
    margin-top: 10px;
    padding: 10px;
    background: #e8f5e9;
    border-radius: 6px;
    font-weight: 600;
}

.formula-result .result-value {
    color: #2e7d32;
    font-size: 1.1rem;
}

/* ===============================
   NOTES
================================*/

.notes {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 10px;
    padding: 20px;
    margin-top: 30px;
}

.notes h3 {
    color: #856404;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.notes ul {
    list-style: none;
    padding-left: 0;
}

.notes li {
    color: #856404;
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
    line-height: 1.6;
}

.notes li:before {
    content: "※";
    position: absolute;
    left: 0;
    font-weight: 700;
}

/* ===============================
   REALTIME PRICE AREA
================================*/

.realtime-prices {
    margin-bottom: 40px;
}

.crypto-prices {
    background: #ffffff;
    border-radius: 18px;
    padding: 24px 20px 26px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
}

.prices-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.prices-header h3 {
    font-size: 1.2rem;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.prices-header i {
    color: #fc5768;
}

.price-update {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: #666;
}

.btn-refresh {
    padding: 6px 12px;
    border-radius: 999px;
    border: none;
    background: #fc5768;
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-refresh i {
    font-size: 0.85rem;
}

.prices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.price-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(252, 87, 104, 0.05);
    border-radius: 12px;
}

.price-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.crypto-icon-img {
    width: 70%;
    height: 70%;
    object-fit: contain;
}

.price-info {
    min-width: 0;
}

.price-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}

.price-value {
    font-size: 1rem;
    font-weight: 700;
    color: #fc5768;
    word-break: break-all;
}

/* ===============================
   RESPONSIVE (タブレット)
================================*/

@media (max-width: 768px) {
    body {
        padding: 16px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .simulator-box {
        padding: 25px 18px;
    }

    .plan-selector {
        grid-template-columns: repeat(2, 1fr);
    }

    .tier-selector {
        grid-template-columns: 1fr;
    }

    .result-summary {
        grid-template-columns: 1fr;
    }

    .timeline-table {
        font-size: 0.9rem;
    }

    .timeline-table th,
    .timeline-table td {
        padding: 10px 8px;
    }

    .bar-chart {
        height: 260px;
    }
}

/* ===============================
   RESPONSIVE (スマホ細かい調整)
================================*/

@media (max-width: 480px) {

    /* 入力金額＋通貨の行を縦並びにしてはみ出し防止 */
    .input-row {
        flex-direction: column;
        align-items: stretch;
    }

    .input-row input,
    .input-row select {
        width: 100%;
    }

    /* iOS セレクト暴走防止 */
    select {
        -webkit-appearance: none;
        appearance: none;
        background-color: #fff;
    }

    /* 棒グラフ：2×2 レイアウトにして縦長を防ぐ */
    .bar-chart {
        flex-wrap: wrap;
        height: auto;
        justify-content: center;
    }

    .bar-item {
        flex: 0 0 50%;
        max-width: 50%;
        margin-bottom: 24px;
    }

    .bar {
        width: 42px;
    }

    .bar-value {
        font-size: 0.8rem;
        top: -24px;
    }
}
/* ====== グラフ強制横並び（PC） ====== */
.bar-chart {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: space-around !important;
    align-items: flex-end !important;
}

/* ====== スマホだけ 2×2 ====== */
@media (max-width: 480px) {
    .bar-chart {
        flex-wrap: wrap !important;
        justify-content: center !important;
    }
    
    .bar-item {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
}


/* ===============================
   BAR CHART LAYOUT FIX
================================*/

.chart-container {
    margin-top:30px;
    overflow-x:auto;
}

.bar-chart {
    display:flex;
    align-items:flex-end;
    gap:20px;
    min-width:max-content;
    padding-bottom:10px;
}

.bar-item {
    display:flex;
    flex-direction:column;
    align-items:center;
    font-size:12px;
    color:#333;
}

.bar {
    width:40px;
    background:linear-gradient(180deg, #fc5768 0%, #ff9aa3 100%);
    border-radius:6px 6px 0 0;
    position:relative;
}

.bar-value {
    font-size:11px;
    margin-bottom:4px;
    font-weight:bold;
}

.bar-label {
    margin-top:6px;
    white-space:pre;
    text-align:center;
}

/* スマホ時は縦ならび or 自動で折り返し */
@media (max-width:600px){
    .bar-chart{
        gap:10px;
    }
    .bar{
        width:32px;
    }
    .bar-label{
        font-size:11px;
    }
}
