/* ============================================================
   スターフォースシミュレーター - スタイルシート
   syasta-planner 準拠のダークテーマUI
   ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;700&display=swap');

/* --- CSS Variables (syasta-planner統一カラー) --- */
:root {
    --bg-color: #1a1a1d;
    --panel-bg: #2d2d30;
    --text-main: #e0e0e0;
    --accent-red: #8a0000;
    --accent-red-light: #c53030;
    --accent-gold: #c5a059;
    --accent-silver: #a0a0a0;
    --input-bg: #121212;
    --border-radius: 8px;
    --star-gold: #FFD700;
    --success-green: #4ade80;
    --danger-red: #f87171;
    --info-blue: #60a5fa;
}

/* --- Reset & Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', 'Hiragino Mincho ProN', 'Yu Mincho', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 10px 20px;
    background-image: radial-gradient(circle at 50% 50%, #2a2a2e 0%, #1a1a1d 100%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* --- Star Background Animation --- */
.star-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.star-bg .star {
    position: absolute;
    background: var(--star-gold);
    border-radius: 50%;
    animation: twinkle var(--duration) ease-in-out infinite;
    opacity: 0;
}

@keyframes twinkle {
    0%, 100% { opacity: 0; }
    50% { opacity: var(--max-opacity); }
}

/* --- Container --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* --- Typography --- */
h1, h2, h3 {
    color: var(--accent-gold);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    font-weight: 400;
}

h1 {
    text-align: center;
    border-bottom: 2px solid var(--accent-red);
    padding-bottom: 5px;
    margin-bottom: 10px;
    font-size: 1.8rem;
    font-family: 'Noto Serif JP', serif;
    letter-spacing: 0.05em;
}

/* --- Header --- */
.header-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
}

.header-controls {
    display: flex;
    flex-direction: row;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.header-lang-row {
    display: flex;
    justify-content: center;
    margin-bottom: 2px;
}

.lang-toggle-btn {
    background: transparent;
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    padding: 4px 16px;
    border-radius: 4px;
    font-family: 'Noto Serif JP', serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.05em;
}

.lang-toggle-btn:hover {
    background: rgba(197, 160, 89, 0.15);
    box-shadow: 0 0 8px rgba(197, 160, 89, 0.2);
}

/* --- External Link Buttons --- */
.external-link-btn {
    background: #222;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #ddd;
    white-space: nowrap;
    gap: 5px;
}

.external-link-btn:hover {
    background: #333;
    transform: scale(1.05);
    border-color: var(--accent-gold);
    color: white;
}

.external-link-btn.gold-text {
    color: var(--accent-gold);
}

.external-link-btn.gold-text:hover {
    color: #ffda75;
    border-color: #ffda75;
}

.ofuse-btn {
    background: transparent;
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.ofuse-btn:hover {
    background: rgba(197, 160, 89, 0.1);
    color: #ffda75;
}

/* --- Panel Style (syasta-planner準拠) --- */
.panel {
    background-color: var(--panel-bg);
    border: 1px solid var(--accent-silver);
    border-radius: var(--border-radius);
    padding: 20px 15px 15px;
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    position: relative;
}

.panel::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    border: 1px dashed #444;
    border-radius: 6px;
    pointer-events: none;
}

.panel-title {
    position: absolute;
    top: -10px;
    left: 15px;
    background-color: var(--panel-bg);
    padding: 0 8px;
    color: var(--accent-red-light);
    font-size: 1rem;
    font-weight: bold;
    border: 1px solid var(--accent-silver);
    border-radius: 4px;
    z-index: 2;
}

/* --- Tab Navigation --- */
.tab-nav {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--accent-red);
    padding-bottom: 5px;
}

.tab-nav-left {
    display: flex;
    gap: 5px;
}

.tab-nav-right {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 2px;
}

.tab-btn {
    padding: 8px 20px;
    cursor: pointer;
    background: linear-gradient(to bottom, #333, #222);
    color: var(--accent-silver);
    border: 1px solid #555;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    font-family: inherit;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: bold;
}

.tab-btn:hover {
    background: linear-gradient(to bottom, #444, #333);
    color: white;
}

.tab-btn.active {
    background: linear-gradient(to bottom, var(--accent-red), #600);
    color: var(--accent-gold);
    border-color: var(--accent-red);
    box-shadow: 0 -2px 8px rgba(138, 0, 0, 0.5);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* --- Tooltip Icon --- */
.tooltip-icon {
    display: inline-block;
    font-size: 0.7rem;
    cursor: help;
    opacity: 0.6;
    transition: opacity 0.2s;
    vertical-align: middle;
}

.tooltip-icon:hover {
    opacity: 1.0;
}


.notation-label {
    font-size: 0.8rem;
    color: var(--accent-silver);
}

.notation-btn {
    padding: 4px 12px;
    cursor: pointer;
    background: #222;
    color: #999;
    border: 1px solid #555;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: bold;
    transition: all 0.2s;
}

.notation-btn:hover {
    background: #333;
    color: #ccc;
}

.notation-btn.active {
    background: linear-gradient(to bottom, var(--accent-red), #600);
    color: var(--accent-gold);
    border-color: var(--accent-red);
}

/* --- Grid Layouts --- */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

@media (max-width: 768px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
    h1 {
        font-size: 1.3rem;
    }
    .tab-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}

/* --- Inputs --- */
label {
    display: block;
    margin-bottom: 3px;
    font-size: 0.85rem;
    color: var(--accent-silver);
}

input, select {
    width: 100%;
    padding: 6px;
    background-color: var(--input-bg);
    border: 1px solid #555;
    color: var(--text-main);
    border-radius: 4px;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.3s;
    font-size: 0.9rem;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent-gold);
}

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

.helper-text {
    font-size: 0.8rem;
    color: var(--accent-gold);
    text-align: right;
    margin-top: 2px;
    font-family: monospace;
}

/* --- Buff / Event Option Groups --- */
.buff-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
}

.buff-group {
    border: 1px solid #444;
    background: rgba(0, 0, 0, 0.2);
    padding: 5px 8px;
    border-radius: 6px;
    flex: 1 1 auto;
    min-width: 180px;
}

.buff-group-title {
    font-size: 0.75rem;
    color: var(--accent-gold);
    margin-bottom: 3px;
    border-bottom: 1px solid #444;
    padding-bottom: 1px;
    display: block;
    width: 100%;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.checkbox-item {
    background: #222;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid #444;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: border-color 0.2s, background 0.2s;
    user-select: none;
}

.checkbox-item:hover {
    border-color: #666;
}

.checkbox-item input {
    width: auto;
    margin-right: 5px;
    cursor: pointer;
}

.checkbox-item:has(input:checked) {
    border-color: var(--accent-red);
    background: rgba(138, 0, 0, 0.15);
}

/* --- Result Display --- */
.result-box {
    text-align: center;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    margin-top: 5px;
}

.result-value {
    font-size: 1.3rem;
    color: var(--accent-gold);
    font-weight: bold;
}

/* --- Cost Breakdown (費用内訳) --- */
.cost-breakdown {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 12px 15px;
    margin-top: 5px;
}

.cost-breakdown-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.cost-breakdown-row .cost-label {
    font-size: 0.85rem;
    color: #aaa;
}

.cost-breakdown-row .cost-value {
    font-size: 1.1rem;
    color: var(--accent-gold);
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

.cost-breakdown-row .cost-value.item-cost {
    color: #a78bfa;
}

.cost-breakdown-divider {
    border-top: 1px dashed #555;
    margin: 4px 0;
}

.cost-breakdown-row.total .cost-label {
    color: var(--accent-gold);
    font-weight: bold;
    font-size: 0.9rem;
}

.cost-breakdown-row.total .cost-value {
    font-size: 1.4rem;
    color: #FFD700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
    margin-top: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead th {
    background: linear-gradient(to bottom, #3a3a3a, #2a2a2a);
    color: var(--accent-gold);
    padding: 8px 6px;
    border: 1px solid #555;
    position: sticky;
    top: 0;
    z-index: 1;
    white-space: nowrap;
    font-weight: bold;
}

tbody td {
    padding: 6px;
    border: 1px solid #444;
    text-align: center;
    transition: background 0.2s;
}

tbody tr:hover {
    background: rgba(197, 160, 89, 0.08);
}

/* 破壊率があるセル */
td.has-destroy {
    color: var(--danger-red);
    font-weight: bold;
}

/* 成功率が高いセル */
td.high-success {
    color: var(--success-green);
}

/* 星数ラベル */
td.star-label {
    color: var(--star-gold);
    font-weight: bold;
    text-align: left;
    white-space: nowrap;
}

/* 費用テーブルのメソ列 */
td.meso-cell {
    text-align: right;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

/* 行区切り (15★境界) */
tr.zone-boundary td {
    border-top: 2px solid var(--accent-red) !important;
}

/* --- Simulation --- */
.sim-btn {
    width: 100%;
    padding: 12px;
    cursor: pointer;
    background: linear-gradient(to bottom, var(--accent-red), #600);
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s;
    margin-top: 10px;
}

.sim-btn:hover {
    background: linear-gradient(to bottom, var(--accent-red-light), var(--accent-red));
    box-shadow: 0 0 15px rgba(138, 0, 0, 0.5);
    transform: translateY(-1px);
}

.sim-btn:active {
    transform: translateY(1px);
}

.sim-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.sim-placeholder {
    text-align: center;
    color: #666;
    padding: 40px;
    font-size: 0.9rem;
    line-height: 1.8;
}

/* --- Progress Bar --- */
.progress-bar-container {
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 3px;
    margin-top: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--accent-red), var(--accent-gold));
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

/* --- Histogram --- */
.histogram-container {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 200px;
    padding: 10px 0;
}

.histogram-bar {
    flex: 1;
    background: linear-gradient(to top, var(--accent-red), var(--accent-gold));
    border-radius: 2px 2px 0 0;
    min-width: 8px;
    transition: height 0.3s ease;
    position: relative;
    cursor: pointer;
}

.histogram-bar:hover {
    background: linear-gradient(to top, var(--accent-red-light), #ffda75);
}

.histogram-bar .tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #222;
    border: 1px solid var(--accent-gold);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-main);
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
}

.histogram-bar:hover .tooltip {
    display: block;
}

.histogram-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #888;
    margin-top: 5px;
}

/* --- Note / Footer --- */
.note {
    font-size: 0.75rem;
    color: #888;
    margin-top: 2px;
}

.footer {
    text-align: center;
    margin-top: 30px;
    padding: 15px;
    border-top: 1px solid #444;
    font-size: 0.8rem;
    color: #666;
}

.footer a {
    color: var(--accent-gold);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1d;
}

::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-gold);
}

/* ============================================================
   仮想機 (Virtual Enhancer)
   ============================================================ */

.vm-star-display {
    text-align: center;
    padding: 15px 0;
    margin: 10px 0;
    background: rgba(0,0,0,0.4);
    border-radius: 8px;
    border: 1px solid #333;
}

.vm-star-label {
    font-size: 0.85rem;
    color: #aaa;
    margin-bottom: 5px;
}

.vm-star-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent-gold);
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    transition: all 0.3s;
}

.vm-enhance-btn {
    display: block;
    width: 100%;
    padding: 14px;
    font-size: 1.2rem;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    border: 2px solid var(--accent-gold);
    border-radius: 8px;
    background: linear-gradient(to bottom, #2a1a00, #1a0f00);
    color: var(--accent-gold);
    transition: all 0.2s;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
    margin-bottom: 12px;
}

.vm-enhance-btn:hover {
    background: linear-gradient(to bottom, #3a2500, #2a1500);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
    transform: translateY(-1px);
}

.vm-enhance-btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

/* 確率バー表示 */
.vm-rate-bars {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 10px;
    padding: 0 15px;
}

.vm-rate-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.vm-rate-name {
    font-size: 0.75rem;
    font-weight: bold;
    width: 28px;
    text-align: right;
}

.vm-rate-bar-bg {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
}

.vm-rate-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
    min-width: 0;
}

.vm-rate-pct {
    font-size: 0.75rem;
    color: #aaa;
    width: 55px;
    text-align: right;
    font-family: 'Courier New', monospace;
}

.vm-auto-section {
    background: rgba(0,0,0,0.3);
    border: 1px solid #333;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 10px;
}

.vm-auto-title {
    font-size: 0.8rem;
    color: var(--accent-gold);
    font-weight: bold;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #333;
}

.vm-auto-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.85rem;
    color: #ccc;
    padding: 4px 0;
}

.vm-auto-label {
    font-size: 0.8rem;
    color: #aaa;
    white-space: nowrap;
}

.vm-auto-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.vm-auto-divider {
    height: 1px;
    background: #333;
    margin: 6px 0;
}

.vm-auto-row input, .vm-auto-row select {
    background: #111;
    border: 1px solid #555;
    color: #fff;
    padding: 4px 6px;
    border-radius: 4px;
    font-family: inherit;
}

.vm-auto-btn {
    padding: 4px 12px;
    cursor: pointer;
    background: linear-gradient(to bottom, #1a3a1a, #0a200a);
    color: #4ade80;
    border: 1px solid #4ade80;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: bold;
    transition: all 0.2s;
    white-space: nowrap;
}

.vm-auto-btn:hover {
    background: linear-gradient(to bottom, #2a4a2a, #1a301a);
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.3);
}

.vm-reset-btn {
    display: block;
    width: 100%;
    padding: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid #666;
    border-radius: 6px;
    background: #222;
    color: #ccc;
    transition: all 0.2s;
}

.vm-reset-btn:hover {
    background: #333;
    border-color: #f87171;
    color: #f87171;
}

/* ログ */
.vm-log-container {
    margin-top: 12px;
}

.vm-log-title {
    font-size: 0.85rem;
    color: #aaa;
    margin-bottom: 6px;
}

.vm-log {
    background: rgba(0,0,0,0.5);
    border: 1px solid #333;
    border-radius: 6px;
    padding: 8px;
    max-height: 250px;
    overflow-y: auto;
    font-size: 0.8rem;
    font-family: 'Courier New', monospace;
    line-height: 1.6;
}

.vm-log-success { color: #4ade80; }
.vm-log-maintain { color: #aaa; }
.vm-log-destroy { color: #f87171; font-weight: bold; }

/* エフェクトオーバーレイ */
.vm-effect-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.1s;
}

.vm-effect-overlay.show {
    opacity: 1;
}

.vm-effect-text {
    font-size: 4rem;
    font-weight: bold;
    text-shadow: 0 0 30px currentColor, 0 0 60px currentColor;
    animation: effectPulse 0.6s ease-out;
}

.vm-effect-success { color: #4ade80; }
.vm-effect-maintain { color: #fbbf24; }
.vm-effect-destroy { color: #f87171; }

@keyframes effectPulse {
    0% { transform: scale(0.5); opacity: 0; }
    30% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(1); opacity: 0; }
}
