:root {
    --primary-color: #1e40af;
    --secondary-color: #3b82f6;
    --high-tier-color: #3b82f6;
    --low-tier-color: #6b7280;
    --background: #f9fafb;
    --panel-bg: #ffffff;
    --text-color: #111827;
    --border-color: #d1d5db;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background);
    color: var(--text-color);
    line-height: 1.6;
    padding: 20px;
}

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

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 2px solid #e5e7eb;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: none;
    color: #1e40af;
}

.subtitle {
    font-size: 1.1em;
    opacity: 1;
    color: #4b5563;
}

.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.right-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-panel {
    background: var(--panel-bg);
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 0;
    border: 2px solid var(--border-color);
}

.settings-panel h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.5em;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--secondary-color);
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

#offering-amount {
    flex: 1;
    height: 8px;
    background: var(--border-color);
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
}

#offering-amount::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
}

#offering-amount::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

.amount-input {
    width: 60px;
    padding: 5px 8px;
    background: var(--panel-bg);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1.1em;
    font-weight: bold;
    text-align: center;
}

select {
    width: 100%;
    padding: 10px;
    background: var(--panel-bg);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
}

select:hover {
    border-color: var(--primary-color);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px;
    border-radius: 5px;
    transition: background-color 0.2s;
}

.checkbox-label:hover {
    background-color: rgba(44, 82, 130, 0.05);
}

.checkbox-label input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.calculate-btn {
    width: 100%;
    padding: 18px;
    background: #1e40af;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.3em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    margin-top: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.3);
    background: #1e3a8a;
}

.calculate-btn:active {
    transform: translateY(0);
}

.pool-summary-panel {
    background: var(--panel-bg);
    padding: 20px;
    border-radius: 10px;
    border: 2px solid var(--border-color);
}

.pool-summary-panel h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.2em;
}

.summary-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stacked-bar-title {
    font-size: 0.9em;
    color: #6b7280;
    margin-bottom: 5px;
}

.stacked-bar {
    display: flex;
    width: 100%;
    height: 40px;
    background: var(--background);
    border-radius: 5px;
    overflow: hidden;
}

.stacked-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    font-size: 0.85em;
    font-weight: bold;
    transition: opacity 0.2s;
}

.stacked-segment:hover {
    opacity: 0.8;
}

.stacked-segment.tier-high {
    background: var(--high-tier-color);
}

.stacked-segment.tier-low {
    background: var(--low-tier-color);
}

.segment-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 5px;
}

.summary-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

.item-pool-panel {
    background: var(--panel-bg);
    padding: 25px;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    width: 100%;
    margin-bottom: 0;
}

.probability-panel {
    background: var(--panel-bg);
    padding: 25px;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    width: 100%;
    margin-bottom: 30px;
}

.item-pool-panel h2,
.probability-panel h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.5em;
}

.placeholder {
    color: #888;
    text-align: center;
    padding: 40px 20px;
    font-style: italic;
}

.item-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.85em;
}

.item-table thead {
    background: #1e40af;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.item-table th {
    padding: 8px 6px;
    text-align: left;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.item-table th:hover {
    background: rgba(255, 255, 255, 0.1);
}

.item-table th::after {
    content: '';
    margin-left: 5px;
}

.item-table th.sorted-asc::after {
    content: '▲';
}

.item-table th.sorted-desc::after {
    content: '▼';
}

.item-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    line-height: 1.1;
}

.item-table tbody tr:hover {
    background: rgba(44, 82, 130, 0.05);
}

.item-table td {
    padding: 4px 6px;
}

.item-table th:nth-child(1),
.item-table td:nth-child(1) {
    width: 20%;
}

.item-table th:nth-child(2),
.item-table td:nth-child(2) {
    width: 10%;
}

.item-table th:nth-child(3),
.item-table td:nth-child(3) {
    width: 15%;
}

.item-table th:nth-child(4),
.item-table td:nth-child(4) {
    width: 15%;
}

.item-table th:nth-child(5),
.item-table td:nth-child(5) {
    width: 40%;
}

.tier-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: bold;
}

.tier-high {
    background: var(--high-tier-color);
    color: white;
}

.tier-low {
    background: var(--low-tier-color);
    color: white;
}

.probability-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.probability-bar-container {
    flex: 1;
    height: 20px;
    background: var(--background);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.probability-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.probability-bar.tier-high {
    background: linear-gradient(90deg, var(--high-tier-color), #357abd);
}

.probability-bar.tier-low {
    background: linear-gradient(90deg, var(--low-tier-color), #7f8c8d);
}

.probability-text {
    min-width: 60px;
    text-align: right;
    font-weight: bold;
}

#chart-container {
    position: relative;
    height: 600px;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 2em;
    }
}

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

    header h1 {
        font-size: 1.5em;
    }

    .settings-panel,
    .item-pool-panel,
    .probability-panel {
        padding: 15px;
    }
}

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

.panel-header h2 {
    margin-bottom: 0;
}

.toggle-scale-btn {
    padding: 8px 16px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    /* margin-left: auto; /\* 追加：右寄せ *\/ */
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.header-icon {
    flex-shrink: 0;
}

.header-text {
    text-align: left;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 5px;
    text-shadow: none;
    color: #1e40af;
}

.subtitle {
    font-size: 1.1em;
    opacity: 1;
    color: #4b5563;
    margin: 0;
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 10px;
    }

    .header-text {
        text-align: center;
    }

    .header-icon {
        width: 50px;
        height: 50px;
    }
}

.footer {
    background: var(--panel-bg);
    border-top: 2px solid var(--border-color);
    padding: 20px;
    margin-top: 40px;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 0.9em;
    color: #6b7280;
}

.footer-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.game-version {
    font-family: monospace;
    color: #9ca3af;
}

.twitter-link {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

.twitter-link:hover {
    color: var(--secondary-color);
}

.twitter-link svg {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .footer-section {
        flex-direction: column;
        gap: 10px;
    }
}

.toggle-method-btn {
    width: 100%;
    padding: 12px;
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 10px;
}

.toggle-method-btn:hover {
    background: #4b5563;
}

.run-simulation-btn {
    width: 100%;
    padding: 12px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 10px;
}

.run-simulation-btn:hover {
    background: #059669;
}

#round-stage {
    flex: 1;
    height: 8px;
    background: var(--border-color);
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
}

#round-stage::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
}

#round-stage::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

#round-stage-label {
    min-width: 100px;
    font-weight: bold;
    color: var(--primary-color);
}
