:root {
    --bg-body: #121212;
    --bg-card: #1e1e1e;
    --bg-input: #2c2c2c;
    --text-main: #e0e0e0;
    --text-sub: #b0b0b0;
    --accent-gold: #ffd700;
    --accent-red: #ff5252;
    --accent-blue: #448aff;
    --border-color: #333;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 10px;
    padding-bottom: 50px;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    background: var(--bg-card);
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    border: 1px solid #333;
}

.title-area {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
}
h1 {
    font-family: 'Roboto Mono', monospace;
    font-size: 24px;
    margin: 0;
    letter-spacing: 2px;
    background: linear-gradient(45deg, #FFD700, #FFF, #FFD700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}
.subtitle {
    font-size: 11px;
    color: var(--text-sub);
    margin-top: 5px;
    letter-spacing: 1px;
}

.floating-machine-info {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid var(--accent-gold);
    border-radius: 8px;
    padding: 8px 12px;
    text-align: right;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 9999;
    backdrop-filter: blur(5px);
    pointer-events: none;
    line-height: 1.3;
}
.info-main-name {
    font-size: 12px;
    color: var(--accent-gold);
    font-weight: bold;
    display: block;
}
.info-sub-specs {
    font-size: 10px;
    color: #ccc;
    display: block;
    margin-top: 2px;
}

.tab-container {
    display: flex;
    background: #121212;
    border-radius: 8px;
    padding: 5px;
    margin-bottom: 20px;
    gap: 5px;
}
.tab-btn {
    flex: 1;
    padding: 12px;
    cursor: pointer;
    background: transparent;
    border: none;
    color: var(--text-sub);
    font-weight: bold;
    transition: 0.3s;
    border-radius: 6px;
}
.tab-btn.active {
    background: var(--bg-input);
    color: var(--accent-gold);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.4s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.ai-search-details {
    background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
    border: 1px solid #304ffe;
    border-radius: 12px;
    margin-bottom: 20px;
}
.ai-search-details summary {
    background: transparent;
    color: #fff;
    border-bottom: none;
    padding: 15px;
}
.ai-search-content { padding: 20px; }
.ai-title { font-weight: bold; color: #fff; display: flex; align-items: center; gap: 8px; font-size: 16px; margin: 0; }
.ai-input-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ai-input {
    padding: 12px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: white;
    flex: 1;
    min-width: 200px;
    font-size: 16px;
}
.btn-ai-search {
    background: #fff; color: #1a237e; border: none; padding: 12px 25px;
    border-radius: 6px; font-weight: bold; cursor: pointer; transition: 0.2s; white-space: nowrap;
}
.ai-status { font-size: 12px; color: #ff80ab; margin-top: 10px; min-height: 1.5em; word-break: break-all; }

.preset-area {
    text-align: right; margin-bottom: 20px; padding: 10px; background: #252525;
    border-radius: 8px; display: flex; flex-direction: column; gap: 10px;
    border-left: 4px solid var(--accent-gold);
}
@media (min-width: 600px) { .preset-area { flex-direction: row; justify-content: flex-end; align-items: center; } }
.preset-select { padding: 8px; font-size: 14px; border-radius: 4px; border: 1px solid #444; background: var(--bg-body); color: var(--text-main); width: 100%; }
@media (min-width: 600px) { .preset-select { width: auto; min-width: 200px; } }
.preset-load-btn { background: #444; color: #fff; border: 1px solid #555; padding: 8px 15px; border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: bold; width: 100%; }
@media (min-width: 600px) { .preset-load-btn { width: auto; } }

details { background: #252525; border: 1px solid #333; border-radius: 8px; margin-bottom: 15px; overflow: hidden; transition: 0.3s; }
details[open] { border-color: var(--accent-blue); box-shadow: 0 0 10px rgba(68, 138, 255, 0.1); }
summary { padding: 15px; font-weight: bold; cursor: pointer; background: #2a2a2a; color: var(--text-main); display: flex; justify-content: space-between; align-items: center; list-style: none; }
summary::after { content: "▼"; font-size: 10px; margin-left: 10px; transition: transform 0.2s; color: var(--text-sub); }
details[open] summary::after { transform: rotate(180deg); color: var(--accent-blue); }
.section-content { padding: 15px; }
.input-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 15px; margin-bottom: 10px; }
.input-group label { font-size: 12px; font-weight: bold; color: var(--text-sub); display: block; margin-bottom: 5px; }
.input-group input, .input-group select { width: 100%; padding: 10px; border: 1px solid #444; border-radius: 4px; background: var(--bg-body); color: #fff; text-align: right; box-sizing: border-box; font-size: 16px; }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 15px; }
.allocation-table { width: 100%; min-width: 600px; font-size: 13px; border-collapse: collapse; }
.allocation-table th { background: #333; color: var(--text-sub); padding: 10px; text-align: center; border: 1px solid #444; white-space: nowrap; }
.allocation-table td { padding: 8px; border: 1px solid #444; text-align: center; background: #222; }
.allocation-table input, .allocation-table select { width: 90%; border: 1px solid #555; background: #333; color: #fff; padding: 6px; border-radius: 4px; text-align: center; }
.add-row-btn { background: rgba(68, 138, 255, 0.1); color: var(--accent-blue); border: 1px solid var(--accent-blue); border-radius: 4px; cursor: pointer; padding: 10px; width: 100%; font-weight: bold; margin-top: 5px; transition: 0.2s; }
.add-row-btn:hover { background: rgba(68, 138, 255, 0.2); }
.del-row-btn { background: #b71c1c; color: white; border: none; border-radius: 3px; cursor: pointer; padding: 4px 8px; font-size: 11px; }
.total-check { text-align: right; font-size: 12px; margin-top: 5px; font-weight: bold; }
.total-ok { color: #69f0ae; } .total-ng { color: #ff5252; }

.reality-box { border: 1px dashed #555; padding: 15px; border-radius: 8px; margin-top: 15px; background: #222; }
.reality-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    flex-wrap: nowrap;
    gap: 4px;
}
.check-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    color: #e0e0e0;
    margin-bottom: 0;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}
.check-label input[type="checkbox"] { margin-right: 4px; transform: scale(1.1); accent-color: var(--accent-gold); }
.reality-row > div {
    display: flex;
    align-items: center;
    flex-shrink: 1;
    justify-content: flex-end;
    min-width: 0;
}
.unit-text {
    font-size: 10px;
    color: #aaa;
    white-space: nowrap;
    margin-right: 2px;
}
.reality-row select {
    padding: 4px 2px;
    border-radius: 4px;
    border: 1px solid #555;
    background: #333;
    color: #fff;
    font-size: 11px;
    margin-left: 0;
    max-width: 90px;
}

.sub-input-row { display: flex; align-items: center; gap: 5px; margin-top: 5px; padding-left: 20px; display: none; }
.sub-input-row.active { display: flex; }
.sub-input { width: 60px !important; padding: 4px !important; text-align: center; border: 1px solid #666; background: #333; color: #fff; border-radius: 4px; font-size: 12px; }

.summary-container { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.summary-chart-area { width: 180px; height: 180px; position: relative; margin-bottom: 10px; }
.summary-text-area { width: 100%; }

.summary-list { list-style: none; padding: 0; margin: 0; width: 100%; }
.summary-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 10px; border-bottom: 1px solid #333; }
.summary-label { font-size: 14px; color: #ffffff; display: flex; flex-direction: column; }
.summary-desc { font-size: 10px; color: #888; margin-top: 2px; }
.summary-value { font-size: 18px; font-weight: bold; color: var(--text-main); }
.highlight-win { color: var(--accent-red); text-shadow: 0 0 5px rgba(255, 82, 82, 0.3); }
.highlight-draw { color: #69f0ae; }
.highlight-lose { color: #448aff; }
.highlight-median { color: var(--accent-gold); }

.chart-box { width: 100%; min-height: 250px; border: 1px solid #333; padding: 10px; border-radius: 8px; background: #1a1a1a; margin-bottom: 10px; box-sizing: border-box; position: relative; }
.chart-zoom-btn { position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,0.6); color: #fff; border: 1px solid #555; border-radius: 4px; padding: 4px 8px; font-size: 12px; cursor: pointer; z-index: 10; }
.bar-chart-wrapper { position: relative; height: 180px; width: 100%; }
.hist-chart-wrapper { position: relative; height: 300px; width: 100%; }
.transition-chart-wrapper { position: relative; height: 350px; width: 100%; margin-top: 10px; }

.btn-run { width: 100%; padding: 16px; background: linear-gradient(90deg, #b71c1c, #d32f2f, #b71c1c); background-size: 200%; color: white; border: none; border-radius: 8px; font-size: 20px; font-weight: bold; cursor: pointer; box-shadow: 0 4px 15px rgba(211, 47, 47, 0.4); transition: 0.3s; animation: pulse 2s infinite; }
.btn-run:disabled { background: #555; cursor: not-allowed; animation: none; box-shadow: none; color: #888; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.4); } 70% { box-shadow: 0 0 0 10px rgba(211, 47, 47, 0); } 100% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0); } }

.progress-container { width: 100%; background-color: #333; height: 10px; border-radius: 5px; overflow: hidden; margin-top: 15px; display: none; }
.progress-bar { width: 0%; height: 100%; background-color: var(--accent-gold); transition: width 0.1s; }
.loading-text { text-align: center; font-size: 12px; color: var(--accent-gold); margin-top: 5px; }

.legend-guide { font-size: 10px; margin-top: 10px; padding: 8px; background: #222; border-radius: 6px; line-height: 1.2; border: 1px solid #333; color: #ccc; }
.legend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 2px; }
.color-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }

.bin-controls { text-align: center; margin-bottom: 15px; }
.bin-btn { background: #333; border: 1px solid #555; padding: 6px 12px; border-radius: 20px; font-size: 12px; cursor: pointer; margin: 0 4px; color: #ccc; transition: 0.2s; }
.bin-btn.active { background: var(--accent-blue); color: white; border-color: var(--accent-blue); }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: none; justify-content: center; align-items: center; z-index: 1000; backdrop-filter: blur(5px); }
.modal-content { background: #1e1e1e; padding: 20px; border-radius: 12px; width: 95%; max-width: 900px; height: 85vh; display: flex; flex-direction: column; border: 1px solid #444; color: #e0e0e0; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; border-bottom: 1px solid #444; padding-bottom: 10px; flex-shrink: 0; }
.modal-title { font-size: 18px; font-weight: bold; margin: 0; color: var(--accent-gold); }
.modal-controls { margin-bottom: 10px; padding-bottom: 10px; flex-shrink: 0; }
.modal-body { flex: 1; position: relative; min-height: 0; }
.modal-footer { margin-top: 10px; flex-shrink: 0; }

.modal-top-checks { display: flex; flex-wrap: wrap; gap: 15px; font-size: 12px; color: #e0e0e0; margin-bottom: 10px; border-bottom: 1px solid #333; padding-bottom: 10px; }
.check-item { display: flex; align-items: center; cursor: pointer; }
.check-item input { margin-right: 5px; accent-color: var(--accent-blue); }
.modal-filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; background: #252525; border-radius: 6px; }
.filter-item { font-size: 11px; display: flex; align-items: center; color: #ccc; cursor: pointer; user-select: none; }
.filter-item input { margin-right: 5px; accent-color: var(--accent-blue); }

.search-area { background:#252525; padding:10px; border-radius:6px; margin-top:5px; border:1px solid #444; }
.search-inputs { display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-top:5px; }
.search-input-group { display:flex; align-items:center; gap:5px; font-size:12px; }
.search-input-group input, .search-input-group select { padding:6px; border-radius:4px; border:1px solid #555; background:#333; color:white; font-size:12px;}
.btn-search { background:#448aff; color:white; border:none; padding:6px 12px; border-radius:4px; cursor:pointer; font-weight:bold; }

.filter-details summary { padding: 8px; background: #2a2a2a; border-radius: 6px; font-size: 12px; border-bottom: none; cursor:pointer; }
.filter-details[open] summary { border-bottom: 1px solid #333; border-radius: 6px 6px 0 0; }
.filter-details { border: 1px solid #333; border-radius: 6px; margin-top: 5px; }

.btn-sub { width: 100%; padding: 10px; background: #333; color: #fff; border: 1px solid #555; border-radius: 6px; cursor: pointer; }
.btn-transition { margin-top:10px; width:100%; background:linear-gradient(90deg, #1565C0, #42A5F5); border:none; padding:10px; color:white; font-weight:bold; border-radius:6px; cursor:pointer; }

.tool-box { background: #222; border: 1px solid #444; padding: 15px; border-radius: 8px; margin-bottom: 20px; }
.tool-title { font-weight: bold; color: var(--accent-gold); margin-bottom: 15px; display: flex; align-items: center; gap: 5px; font-size: 16px; }
.calc-result { background: #1a1a1a; border: 1px solid #333; padding: 15px; border-radius: 6px; text-align: center; margin-top: 10px; }
.calc-sub { font-size: 12px; color: #aaa; margin-bottom: 5px; }
.calc-val { font-size: 20px; font-weight: bold; color: var(--text-main); }
.tool-btn { width: 100%; padding: 10px; background: #333; color: #fff; border: 1px solid #555; border-radius: 6px; cursor: pointer; margin-bottom: 10px; }
.tool-btn:hover { background: #444; }

h2 { font-size: 18px; margin: 0; }
.result-details { margin-bottom: 20px; }
.result-summary-header { border-left: 4px solid var(--accent-gold); padding-left: 10px; color: var(--text-main); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; color: #121212; font-size: 10px; margin-right: 8px; font-weight: bold; }
.badge-normal { background: #b0bec5; }
.badge-rush { background: #448aff; }
.badge-lt { background: #ff5252; color: white; }
