/* =========================================================
   Fate Tide Simulator — Design System & Custom Components
   紫微命運潮汐模擬器 樣式
   ========================================================= */

/* ---- Color Accents & Neon Badges ---- */
/* Financial chapter, shared between the results page and standalone page. */
.fate-page { background: radial-gradient(ellipse at 75% 0%, #272044 0%, #0c111d 65%); }
.ft-page-shell { max-width: 1220px; margin: auto; padding: 0 28px 80px; }
.fate-experience { color: #e6e9f4; line-height: 1.7; font-size: 14px; text-align: left; }
.fate-experience [hidden] { display: none !important; }
.ft-entry { margin-top: 28px; padding: 30px; text-align: center; background: linear-gradient(125deg,#241c3d,#142b33); }
.ft-entry h3 { font-size: 24px; margin: 12px 0; color: #eee3ff; }
.ft-entry p { margin: 10px 0 20px; line-height: 1.8; color: #bfbed3; }
.ft-entry .ft-toolbar { justify-content: center; }
.ft-entry small { display: block; color: #a6b0c9; margin-top: 16px; }
.life-game-entry { margin-top: 28px; padding: 36px; border-color: #6d775c; background: radial-gradient(ellipse at top right, #57634a36, transparent 65%), linear-gradient(125deg, #132d2d, #111e2a); }
.life-game-entry .ft-eyebrow { color: #c8b983; }
.life-game-entry h3 { margin: 14px 0; color: #f2e5c7; font-size: clamp(23px, 3vw, 30px); line-height: 1.5; }
.life-game-intro { color: #c6d4d3; line-height: 1.9; }
.life-game-snapshot { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin: 24px 0; padding: 20px 0; border-block: 1px solid #bca97530; }
.life-game-snapshot span { display: block; color: #a6bab8; font-size: 13px; margin-bottom: 7px; }
.life-game-snapshot strong { display: block; color: #f1e7cf; font-size: 18px; overflow-wrap: anywhere; }
.life-game-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.life-game-actions .btn-primary { background: #d0bf89; color: #152b29; border: 1px solid #e2d5ad; text-decoration: none; }
.life-game-actions .btn-primary:hover { background: #e2d5ad; }
.life-game-guide { color: #d1dfdd; font-size: 14px; line-height: 1.8; margin: 18px 0 12px; }
.life-game-entry small { display: block; color: #9eafae; line-height: 1.8; }
@media (max-width: 600px) {
    .life-game-entry { padding: 24px 18px; }
    .life-game-snapshot { grid-template-columns: 1fr; gap: 16px; }
    .life-game-actions { flex-direction: column; align-items: stretch; }
    .life-game-actions .btn { white-space: normal; text-align: center; justify-content: center; }
}
.ft-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .17em; color: #b4a2da; }
.ft-source { padding: 24px 4px 16px; }
.ft-source h2 { margin: 12px 0 16px; font-size: clamp(24px, 3vw, 36px); letter-spacing: -.035em; color: #f4efff; }
.ft-source p { margin: 8px 0; }
.ft-card { border: 1px solid #ffffff18; border-radius: 18px; padding: 25px; margin: 18px 0; background: #141a2bdd; box-shadow: 0 12px 35px #00000012; }
.ft-section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.ft-section-title h3 { font-size: 17px; margin: 0; }
.ft-section-title > span { color: #acb4cd; font-size: 12px; }
.ft-form-grid { display: grid; grid-template-columns: 1.3fr 1fr .7fr 1.2fr 1fr; gap: 12px; }
.fate-experience label { display: flex; flex-direction: column; gap: 7px; color: #c2c9dc; font-size: 12px; }
.fate-experience input, .fate-experience select { color: #edf0ff; background: #0d1424; border: 1px solid #3a4258; border-radius: 8px; padding: 10px 11px; min-height: 42px; width: 100%; min-width: 0; font: inherit; color-scheme: dark; }
.fate-experience button { cursor: pointer; padding: 10px 16px; border: 1px solid #4d4564; border-radius: 8px; color: #e9e3f7; background: #29243d; font: inherit; line-height: 1.45; min-height: 42px; }
.fate-experience button:hover { background: #3d3258; border-color: #b69be5; }
.fate-experience button:disabled { opacity: .5; cursor: wait; }
.fate-experience :focus-visible { outline: 2px solid #cbb3ff; outline-offset: 4px; }
.fate-experience .ft-primary { background: #b6a0ef; color: #191226; border-color: #c6b5ed; font-weight: 700; }
.fate-experience .ft-primary:hover { background: #d1bdfc; }
.ft-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 15px; }
.fate-experience .ft-check { flex-direction: row; align-items: center; margin: 0 auto 8px 0; }
.fate-experience .ft-check input { width: 18px; min-height: 18px; accent-color: #b6a0ef; }
.ft-muted { color: #9faec4; font-size: 12px; line-height: 1.8; margin: 12px 0 0; }
.ft-status { color: #b9c8de; min-height: 25px; padding: 0 4px; }
.ft-error, .ft-negative { color: #ffadad !important; }
.ft-kpis { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-top: 16px; }
.ft-kpi { border-top: 2px solid var(--path-color); padding: 17px; background: #0e1424; border-radius: 4px 4px 12px 12px; min-width: 0; }
.ft-kpi span { color: var(--path-color); font-size: 12px; }
.ft-kpi strong { display: block; font-size: clamp(16px,2.2vw,26px); font-variant-numeric: tabular-nums; margin: 6px 0; }
.ft-kpi small { color: #a6b0c9; font-size: 11px; }
.fate-experience .ft-timeline { margin-top: 22px; }
.ft-timeline input { accent-color: #c4a1ff; padding: 0; border: 0; cursor: ew-resize; }
.ft-chart { margin-top: 18px; overflow: hidden; }
.ft-chart svg { display: block; width: 100%; min-height: 140px; }
.ft-chart text { fill: #a6b0c9; font-size: 12px; font-family: inherit; }
.ft-event { margin-top: 20px; background: linear-gradient(115deg,#2a2342,#182d35); border: 1px solid #8870b13d; padding: 24px; border-radius: 14px; }
.ft-event h3 { font-size: 23px; margin: 10px 0; }
.ft-event p { margin: 10px 0; }
.ft-choices { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 12px; margin: 20px 0; }
.fate-experience .ft-choice { text-align: left; padding: 18px; background: #131a29a8; border-color: #ffffff22; }
.ft-choice strong, .ft-choice span, .ft-choice small { display: block; }
.ft-choice span { font-size: 12px; color: #bbc4d7; line-height: 1.8; margin: 10px 0; }
.ft-choice small { color: #ae9dcc; font-size: 11px; }
.fate-experience .ft-choice.is-selected { border: 1px solid #69dfc6; background: #14372faa; }
.ft-policy-bar { padding-top: 5px; }
.fate-experience summary { cursor: pointer; padding: 10px 0; color: #d2c5ea; }
.ft-history article { padding: 15px 0; border-bottom: 1px solid #ffffff10; }
.ft-history p { margin: 8px 0 0; color: #b6c1d4; }
.ft-rates { display: flex; gap: 10px; flex-wrap: wrap; }
.ft-rates span { background: #312b49; border-radius: 20px; padding: 6px 12px; font-size: 12px; color: #d5c7ef; }
.ft-board-scroll, .ft-table-scroll { overflow-x: auto; max-width: 100%; scrollbar-color: #68567e #121626; }
.fate-experience .astrolabe-board { min-width: 660px; margin: 10px 0 0; }
.fate-experience .palace-cell { cursor: default; min-width: 0; padding: 12px; }
.fate-experience .palace-header span { color: #989eb9; font-size: 11px; }
.fate-experience .palace-cell > small { font-size: 11px; color: #b0b7c9; }
.ft-mutation { display: inline-block; font-size: 10px; margin: 2px 6px 0 0; }
.fate-experience .astrolabe-center h3 { font-size: 30px; color: #d9caff; margin: 12px 0; }
.fate-experience .astrolabe-center p { margin: 6px 0; color: #bdc1d3; }
.fate-experience .astrolabe-center small { color: #929eb4; }
.fate-experience table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.fate-experience th, .fate-experience td { padding: 12px 10px; border-bottom: 1px solid #ffffff10; text-align: right; white-space: nowrap; }
.fate-experience th { color: #b9bfd3; font-weight: 500; }
.fate-experience th:first-child { text-align: left; }
.ft-ledger thead th { font-size: 11px; }
.ft-ledger .is-current { background: #b69be519; }
.ft-ledger .ft-networth { color: #6cdec6; }
.fate-experience .ft-ledger button { padding: 4px 8px; min-height: 34px; font-size: 12px; }
.ft-bridge { background: #0d1524; padding: 18px; border-radius: 10px; margin-top: 16px; }
.ft-bridge h4 { margin: 0 0 10px; }
.ft-bridge p { font-size: 12px; margin: 8px 0; }
.ft-assumptions { color: #a5b1c7; font-size: 12px; }
.ft-assumptions p { margin: 12px 0; }
.ft-empty { padding: 48px; margin-top: 60px; }
.ft-empty h1 { font-size: 30px; margin: 15px 0; }
@media (max-width: 850px) {
    .ft-form-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .ft-kpi { padding: 12px; }
    .ft-card { padding: 18px; }
}
@media (max-width: 560px) {
    .ft-page-shell { padding: 0 12px 40px; }
    .ft-kpis { grid-template-columns: 1fr; gap: 8px; }
    .ft-kpi strong { font-size: 23px; display: inline-block; margin: 4px 12px 4px 0; }
    .ft-kpi span { display: block; }
    .ft-card { padding: 14px; border-radius: 12px; }
    .ft-event { padding: 16px; }
    .ft-choices { grid-template-columns: 1fr; }
    .ft-empty { margin-top: 20px; }
    .fate-nav-bar { gap: 12px; flex-wrap: wrap; }
    .ft-entry { padding: 22px 15px; }
}
.text-lu { color: #10b981; }      /* 化祿 - 綠色 */
.text-quan { color: #f59e0b; }    /* 化權 - 橙金 */
.text-ke { color: #06b6d4; }      /* 化科 - 科技青 */
.text-ji { color: #ef4444; }      /* 化忌 - 緋紅 */

.badge-mutagen {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    margin-right: 4px;
}
.badge-lu {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #10b981;
}
.badge-quan {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #f59e0b;
}
.badge-ke {
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid rgba(6, 182, 212, 0.4);
    color: #06b6d4;
}
.badge-ji {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

/* ---- Header & Nav ---- */
.fate-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.back-link {
    color: var(--accent-cyan);
    text-decoration: none;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}
.back-link:hover {
    color: #fff;
    transform: translateX(-4px);
}

.sync-badge {
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.35);
    color: #c084fc;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ---- Astrolabe Grid (紫微十二宮盤) ---- */
.astrolabe-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, minmax(130px, auto));
    gap: 8px;
    margin: 20px 0;
    background: rgba(10, 10, 25, 0.8);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 12px;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.palace-cell {
    background: rgba(20, 20, 48, 0.5);
    border: 1px solid rgba(124, 58, 237, 0.15);
    border-radius: var(--radius-md);
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    transition: var(--transition);
    cursor: pointer;
    min-height: 125px;
}

.palace-cell:hover {
    background: rgba(30, 30, 70, 0.7);
    border-color: var(--accent-purple);
    transform: translateY(-2px);
}

.palace-cell.active-cai {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.08);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

.palace-cell.active-ji {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
}

.palace-cell.active-ming {
    border-color: #7c3aed;
    background: rgba(124, 58, 237, 0.12);
    box-shadow: 0 0 18px rgba(124, 58, 237, 0.3);
}

.palace-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
    padding-bottom: 4px;
}

.palace-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.palace-stem-branch {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.palace-stars {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 6px 0;
}

.star-tag {
    font-size: 0.75rem;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
}

.star-tag.major {
    color: #f1f5f9;
    font-weight: 600;
    background: rgba(124, 58, 237, 0.25);
    border: 1px solid rgba(124, 58, 237, 0.4);
}

.star-tag.tough {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.15);
}

.star-tag.lucky {
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.15);
}

.palace-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* 盤中心 (天盤中宮) */
.astrolabe-center {
    grid-column: 2 / span 2;
    grid-row: 2 / span 2;
    background: radial-gradient(circle at center, rgba(30, 27, 75, 0.85), rgba(10, 10, 25, 0.95));
    border: 1px solid rgba(124, 58, 237, 0.35);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-shadow: inset 0 0 30px rgba(124, 58, 237, 0.15);
    z-index: 2;
}

.center-title {
    font-size: 1.25rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.center-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ---- Talent Matrix (搞笑諾貝爾天賦指數) ---- */
.talent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.talent-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.talent-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-purple);
}

.talent-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent-cyan);
    font-family: var(--font-en);
}

/* ---- Tide Controller (時間軸動態播放器) ---- */
.tide-player-container {
    background: rgba(15, 15, 40, 0.7);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin: 24px 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
}

.tide-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.btn-play {
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    border: none;
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
    transition: var(--transition);
}
.btn-play:hover {
    transform: scale(1.08);
    box-shadow: 0 0 25px rgba(6, 182, 212, 0.7);
}

.speed-selector {
    display: flex;
    gap: 4px;
    background: rgba(20, 20, 50, 0.6);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.speed-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 600;
}
.speed-btn.active {
    background: var(--accent-purple);
    color: white;
}

.current-status-badge {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.year-age-display {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    font-family: var(--font-en);
}

.decadal-tag {
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: var(--accent-cyan);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Scrubber / Range slider */
.tide-scrubber-wrapper {
    position: relative;
    margin: 15px 0 25px;
}

.tide-slider {
    width: 100%;
    -webkit-appearance: none;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, rgba(124, 58, 237, 0.3), rgba(6, 182, 212, 0.3));
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}

.tide-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #06b6d4;
    cursor: pointer;
    border: 3px solid #0d0d1e;
    box-shadow: 0 0 12px #06b6d4;
    transition: transform 0.15s;
}

.tide-slider::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

.scrubber-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 6px;
}

/* ---- Dynamic Live Stats Pill ---- */
.live-stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.live-pill {
    background: rgba(20, 20, 48, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 10px 14px;
}

.live-pill-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 2px;
}

.live-pill-val {
    font-size: 1.15rem;
    font-weight: 700;
    font-family: var(--font-en);
}

/* ---- Interactive Tooltip for Stat Pills ---- */
.fate-tooltip-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(124, 58, 237, 0.25);
    border: 1px solid rgba(124, 58, 237, 0.5);
    color: #c084fc;
    font-size: 0.72rem;
    font-weight: bold;
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    outline: none;
    transition: var(--transition);
}

.fate-tooltip-trigger:hover,
.fate-tooltip-trigger:focus {
    background: var(--accent-purple);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.6);
}

.fate-tooltip-card {
    visibility: hidden;
    opacity: 0;
    width: 300px;
    background: rgba(13, 13, 30, 0.95);
    border: 1px solid rgba(124, 58, 237, 0.4);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7), 0 0 15px rgba(124, 58, 237, 0.25);
    color: #cbd5e1;
    text-align: left;
    border-radius: var(--radius-md);
    padding: 12px 14px;
    position: absolute;
    z-index: 100;
    bottom: 135%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    line-height: 1.5;
    font-weight: normal;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    backdrop-filter: blur(8px);
}

.fate-tooltip-card::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: rgba(13, 13, 30, 0.95) transparent transparent transparent;
}

.fate-tooltip-trigger:hover .fate-tooltip-card,
.fate-tooltip-trigger:focus .fate-tooltip-card {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* ---- Floating Event Notification Banner ---- */
.event-toast-box {
    min-height: 56px;
    padding: 12px 18px;
    background: rgba(124, 58, 237, 0.12);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    transition: var(--transition);
}

.event-toast-icon {
    font-size: 1.5rem;
}

.event-toast-text {
    color: #e2e8f0;
    line-height: 1.4;
}

/* ---- Monthly Table ---- */
.monthly-fate-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 0.9rem;
}

.monthly-fate-table th {
    background: rgba(20, 20, 50, 0.8);
    color: var(--text-secondary);
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 600;
}

.monthly-fate-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.monthly-fate-table tr:hover {
    background: rgba(124, 58, 237, 0.06);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .astrolabe-board {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
    }
    .astrolabe-center {
        grid-column: 1 / span 2;
        grid-row: auto;
        order: -1;
        margin-bottom: 12px;
    }
    .tide-controls {
        flex-direction: column;
        align-items: flex-start;
    }
    .current-status-badge {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }
}
