/* ===== 큐브 시뮬레이터 ===== */

.cube-sim-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 20px 80px;
}

.cube-sim-header {
    text-align: center;
    margin-bottom: 26px;
}
.cube-sim-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: #3C3744;
    margin: 0 0 8px;
}
.sim-sub {
    color: #555;
    font-size: 14px;
    margin: 0;
}

/* ===== 설정 카드 ===== */
.setup-card {
    background: #fff;
    border: 1px solid #e6e8ef;
    border-radius: 12px;
    padding: 22px 24px;
    margin-bottom: 20px;
}
.field-group {
    margin-bottom: 16px;
}
.field-group:last-child { margin-bottom: 0; }
.field-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #3C3744;
    margin-bottom: 8px;
}
.field-hint {
    font-size: 11px;
    color: #888;
    margin: 4px 0 0;
}
.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
}
.setup-card select,
.setup-card input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccd3e0;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    color: #3C3744;
    box-sizing: border-box;
}
.setup-card select:focus,
.setup-card input:focus {
    outline: none;
    border-color: #3C3744;
}

.cube-select-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: stretch;
}
.select-area {
    background: #f7f8fb;
    border: 1px solid #e6e8ef;
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.select-area-label {
    font-size: 10px;
    font-weight: 700;
    color: #aab0c0;
    letter-spacing: 0.5px;
}
.meso-area { /* 메소 재설정 영역 — 큐브 영역과 동일한 톤 */ }
.cube-area { /* 큐브 영역 */ }
.meso-btn-row {
    display: flex;
    gap: 6px;
}
.meso-btn {
    padding: 7px 14px;
    border: 1px solid #ccd3e0;
    border-radius: 6px;
    background: #fff;
    font-size: 12px;
    font-weight: 700;
    color: #5a536b;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.meso-btn:hover {
    border-color: #3C3744;
    color: #3C3744;
    background: #fff;
}
.meso-btn.active {
    background: #3C3744;
    color: #fff;
    border-color: #3C3744;
}
.meso-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.cube-tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-content: flex-start;
}
.cube-tab {
    padding: 8px 16px;
    border: 2px solid #e6e8ef;
    border-radius: 10px;
    background: #fff;
    font-size: 13px;
    font-weight: 700;
    color: #555;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.cube-tab .cube-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--cube-color, #aaa);
}
.cube-tab:hover {
    border-color: #3C3744;
    color: #3C3744;
}
.cube-tab.active {
    border-color: var(--cube-color, #3C3744);
    background: var(--cube-color, #3C3744);
    color: #fff;
}
.cube-tab.active .cube-dot { background: #fff; }

.price-input-wrap {
    position: relative;
}
.price-input-wrap input {
    padding-right: 48px;
}
.price-input-wrap .price-unit {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #aab0c0;
    font-weight: 600;
    pointer-events: none;
}

.apply-btn {
    width: 100%;
    margin-top: 18px;
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #3C3744 0%, #5a536b 100%);
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
}
.apply-btn:hover { opacity: 0.92; }
.apply-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.load-status {
    margin-top: 10px;
    font-size: 12px;
    text-align: center;
}
.load-status.ok    { color: #27ae60; }
.load-status.error { color: #e53935; }

/* ===== 시뮬레이션 영역 ===== */
.sim-area {
    margin-top: 8px;
}

/* 현재 잠재능력 */
.potential-display {
    background: #fff;
    border: 1px solid #e6e8ef;
    border-radius: 12px;
    padding: 18px 22px;
    margin-bottom: 16px;
}
.potential-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.grade-badge {
    background: #f1c40f;
    color: #3C3744;
    font-size: 12px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 14px;
}
.grade-badge.grade-레어     { background: #3498db; color: #fff; }
.grade-badge.grade-에픽     { background: #9b59b6; color: #fff; }
.grade-badge.grade-유니크   { background: #f1c40f; color: #3C3744; }
.grade-badge.grade-레전드리 { background: #27ae60; color: #fff; }
.potential-title {
    font-size: 14px;
    font-weight: 700;
    color: #3C3744;
}
.potential-lines {
    list-style: none;
    counter-reset: opt;
    padding: 0;
    margin: 0;
}
.potential-lines li {
    counter-increment: opt;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: #f7f8fb;
    border-left: 3px solid #ccd3e0;
    border-radius: 6px;
    font-size: 13px;
    color: #3C3744;
}
.potential-lines li::before {
    content: counter(opt) ". ";
    color: #aab0c0;
    font-weight: 700;
    margin-right: 6px;
}
.potential-lines li.empty {
    color: #aab0c0;
    text-align: center;
    border-left: 0;
}
.potential-lines li.empty::before { content: ""; }

/* 통계 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stat-card {
    background: #fff;
    border: 1px solid #e6e8ef;
    border-radius: 12px;
    padding: 14px 16px;
}
.stat-card .stat-label {
    font-size: 12px;
    color: #888;
    font-weight: 600;
    margin-bottom: 6px;
}
.stat-card .stat-value {
    font-size: 22px;
    font-weight: 800;
    color: #3C3744;
    font-variant-numeric: tabular-nums;
}
.stat-card .stat-sub {
    font-size: 11px;
    color: #aab0c0;
    margin-top: 2px;
}

/* 액션 버튼 */
.action-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.action-btn {
    flex: 1;
    min-width: 130px;
    padding: 12px 18px;
    border: 1px solid #ccd3e0;
    border-radius: 10px;
    background: #fff;
    color: #3C3744;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.action-btn:hover { border-color: #3C3744; }
.action-btn.primary {
    background: linear-gradient(135deg, #3C3744 0%, #5a536b 100%);
    color: #fff;
    border-color: #3C3744;
}
.action-btn.primary:hover { opacity: 0.92; }
.action-btn.warn {
    color: #e53935;
    border-color: #fcbcbc;
}
.action-btn.warn:hover { border-color: #e53935; background: #fef2f2; }
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* 자동 굴리기 패널 */
.auto-panel {
    background: #fff;
    border: 1px solid #e6e8ef;
    border-radius: 12px;
    padding: 18px 22px;
    margin-bottom: 16px;
}
.auto-panel h3 {
    margin: 0 0 4px;
    font-size: 15px;
    color: #3C3744;
}
.auto-panel .hint {
    font-size: 12px;
    color: #888;
    margin: 0 0 12px;
}
.auto-targets {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}
.target-row {
    display: grid;
    grid-template-columns: 80px 1fr 100px 110px 36px;
    gap: 8px;
    align-items: center;
}
.target-row select,
.target-row input {
    padding: 6px 10px;
    border: 1px solid #ccd3e0;
    border-radius: 6px;
    font-size: 12px;
}
.target-row .remove-btn {
    background: #fff;
    border: 1px solid #e6e8ef;
    color: #999;
    border-radius: 6px;
    height: 30px;
    cursor: pointer;
    font-size: 14px;
}
.target-row .remove-btn:hover { color: #e53935; border-color: #e53935; }
.add-target-btn {
    background: #f4f5f9;
    border: 1px dashed #ccd3e0;
    border-radius: 8px;
    padding: 8px;
    color: #666;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-top: 4px;
}
.add-target-btn:hover { background: #ebedf4; color: #3C3744; border-color: #3C3744; }
.add-target-btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    background: #f4f5f9;
    color: #aab0c0;
    border-color: #ccd3e0;
}
.add-target-btn:disabled:hover { background: #f4f5f9; color: #aab0c0; border-color: #ccd3e0; }
.add-target-btn #addTargetCount { font-size: 11px; color: #aab0c0; font-weight: 400; margin-left: 4px; }

/* OR/AND 조건 결합 토글 */
.auto-mode-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    flex-wrap: wrap;
}
.auto-mode-label {
    font-size: 12px;
    font-weight: 600;
    color: #3C3744;
}
.auto-mode-toggle {
    display: inline-flex;
    border: 1px solid #ccd3e0;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}
.auto-mode-toggle .mode-btn {
    background: #fff;
    border: 0;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.auto-mode-toggle .mode-btn + .mode-btn { border-left: 1px solid #e6e8ef; }
.auto-mode-toggle .mode-btn:hover { background: #f4f5f9; color: #3C3744; }
.auto-mode-toggle .mode-btn.active {
    background: #3C3744;
    color: #fff;
}
.auto-mode-row .hint { margin: 0; font-size: 11px; color: #888; }

.auto-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.auto-progress {
    margin-top: 14px;
}
.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: #3C3744;
    margin-bottom: 6px;
}
.progress-bar {
    width: 100%;
    height: 8px;
    background: #f0f1f5;
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #B4C5E4, #3C3744);
    transition: width 0.1s linear;
}

/* 히스토리 */
.history-section {
    background: #fff;
    border: 1px solid #e6e8ef;
    border-radius: 12px;
    padding: 16px 20px;
}
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.history-header h3 {
    margin: 0;
    font-size: 14px;
    color: #3C3744;
}
.clear-history-btn {
    background: none;
    border: 1px solid #e6e8ef;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    color: #888;
    cursor: pointer;
}
.clear-history-btn:hover { color: #e53935; border-color: #e53935; }

.history-list {
    max-height: 400px;
    overflow-y: auto;
}
.history-list .empty-hint {
    text-align: center;
    color: #aab0c0;
    font-size: 13px;
    padding: 20px 0;
    margin: 0;
}
.history-row {
    display: grid;
    grid-template-columns: 50px 1fr 100px;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px dashed #f0f1f5;
    font-size: 12px;
    align-items: center;
}
.history-row:last-child { border-bottom: none; }
.history-row:hover { background: #fafbfd; }
.history-row .h-idx {
    font-weight: 700;
    color: #aab0c0;
    text-align: right;
}
.history-row .h-opts { color: #3C3744; }
.history-row .h-opts .line-sep { color: #ccd3e0; margin: 0 5px; }
.history-row .h-meso {
    text-align: right;
    color: #888;
    font-variant-numeric: tabular-nums;
}
.history-row.is-target {
    background: linear-gradient(90deg, rgba(39,174,96,0.08), transparent);
    border-left: 3px solid #27ae60;
}
.history-row.is-meso-reset {
    background: linear-gradient(90deg, rgba(212,167,46,0.08), transparent);
    border-left: 3px solid #d4a72e;
}
.history-row.is-meso-reset.is-meso-레어 {
    background: linear-gradient(90deg, rgba(52,152,219,0.10), transparent);
    border-left-color: #3498db;
}
.history-row.is-meso-reset.is-meso-레어 .h-idx.is-meso { color: #3498db; }
.history-row.is-meso-reset.is-meso-에픽 {
    background: linear-gradient(90deg, rgba(155,89,182,0.10), transparent);
    border-left-color: #9b59b6;
}
.history-row.is-meso-reset.is-meso-에픽 .h-idx.is-meso { color: #9b59b6; }
.history-row.is-meso-reset.is-meso-유니크 {
    background: linear-gradient(90deg, rgba(241,196,15,0.12), transparent);
    border-left-color: #f1c40f;
}
.history-row.is-meso-reset.is-meso-유니크 .h-idx.is-meso { color: #c9a008; }
.history-row.is-meso-reset.is-meso-레전드리 {
    background: linear-gradient(90deg, rgba(39,174,96,0.10), transparent);
    border-left-color: #27ae60;
}
.history-row.is-meso-reset.is-meso-레전드리 .h-idx.is-meso { color: #27ae60; }
.history-row .h-idx.is-meso {
    color: #d4a72e;
    font-size: 14px;
}

@media (max-width: 720px) {
    .cube-sim-container { padding: 22px 12px 60px; }
    .field-row { grid-template-columns: 1fr; gap: 12px; }
    .cube-select-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .action-row .action-btn { min-width: 0; }
    .target-row { grid-template-columns: 1fr 1fr; gap: 6px; }
    .history-row { grid-template-columns: 32px 1fr; }
    .history-row .h-meso { grid-column: 2; text-align: left; font-size: 11px; }
}
