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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 800px;
    width: 100%;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 20px;
    font-size: 2.5em;
}

.tally-display {
    background: #f8f9fa;
    border: 2px solid #667eea;
    border-radius: 10px;
    padding: 15px 25px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 15px;
}

.tally-display.hidden {
    display: none;
}

.tally-item {
    text-align: center;
    min-width: 120px;
}

.tally-item.total {
    border-top: 2px solid #667eea;
    padding-top: 10px;
    margin-top: 5px;
    width: 100%;
    font-weight: bold;
    font-size: 1.1em;
}

.tally-label {
    display: block;
    color: #666;
    font-size: 0.85em;
    margin-bottom: 5px;
}

.tally-value {
    display: block;
    font-size: 1.3em;
    font-weight: bold;
    color: #333;
}

.tally-value.positive {
    color: #2ecc71;
}

.tally-value.negative {
    color: #e74c3c;
}

h2 {
    text-align: center;
    color: #555;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.phase {
    display: block;
}

.phase.hidden {
    display: none;
}

.info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
}

.info p {
    margin: 5px 0;
    color: #666;
}

.boxes {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.box-grid {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 6px;
    margin: 20px auto 30px;
    max-width: 520px;
    position: relative;
    z-index: 0;
}

.box-cell {
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f8f9fa;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.2s, box-shadow 0.2s;
}

.box-cell:hover {
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(102, 126, 234, 0.25);
}

.box-grid.reveal .box-cell[data-proportion="0.25"] {
    background: #e5e4e2;
}

.box-grid.reveal .box-cell[data-proportion="0.5"] {
    background: #c0c0c0;
}

.box-grid.reveal .box-cell[data-proportion="0.75"] {
    background: #f1c40f;
}

.box-grid.reveal .box-cell {
    color: #333;
    font-size: 0.7em;
    font-weight: 600;
}

.reveal-toggle {
    text-align: center;
    margin-bottom: 16px;
    color: #555;
    position: relative;
    z-index: 10;
    display: inline-block;
    padding: 6px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    pointer-events: auto;
}

.reveal-toggle label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.reveal-toggle input {
    margin-right: 8px;
    cursor: pointer;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    width: 320px;
    max-width: calc(100vw - 40px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 12px;
    color: #333;
}

#passwordInput {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    margin: 10px 0 16px;
}

#passwordInput:focus {
    outline: none;
    border-color: #667eea;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: nowrap;
}

.modal-actions .btn {
    min-width: 0;
    width: 140px;
    padding: 12px 16px;
}

.box {
    cursor: pointer;
    text-align: center;
    padding: 30px;
    border: 3px solid #ddd;
    border-radius: 15px;
    transition: all 0.3s;
    background: #f8f9fa;
    min-width: 150px;
}

.box:hover {
    border-color: #667eea;
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.box-icon {
    font-size: 4em;
    margin-bottom: 10px;
}

.box-label {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
}

.balls-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
    min-height: 60px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.rolling-ball {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #95a5a6;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    animation: rollAcross 1s ease-in-out;
    z-index: 10;
}

@keyframes rollAcross {
    0% {
        left: -50px;
        top: 50%;
        transform: translateY(-50%) rotate(0deg);
    }
    100% {
        left: calc(100% + 50px);
        top: 50%;
        transform: translateY(-50%) rotate(360deg);
    }
}

.ball {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.ball.red {
    background: #e74c3c;
}

.ball.green {
    background: #2ecc71;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.stat {
    text-align: center;
    padding: 15px 25px;
    background: #f8f9fa;
    border-radius: 10px;
    min-width: 120px;
}

.stat-label {
    display: block;
    color: #666;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
    color: #333;
}

.buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.btn {
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 200px;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #2ecc71;
    color: white;
}

.btn-secondary:hover {
    background: #27ae60;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.4);
}

.guess-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
    align-items: center;
}

.btn-guess {
    background: #f39c12;
    color: white;
    width: 100%;
    max-width: 300px;
}

.btn-guess:hover {
    background: #e67e22;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(243, 156, 18, 0.4);
}

.results {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 10px;
    margin: 20px 0;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid #ddd;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item.total {
    border-top: 2px solid #333;
    margin-top: 10px;
    padding-top: 20px;
    font-size: 1.2em;
    font-weight: bold;
}

.result-label {
    color: #666;
    font-weight: 500;
}

.result-value {
    color: #333;
    font-weight: bold;
}

#resultNet {
    font-size: 1.3em;
}

#resultNet.positive {
    color: #2ecc71;
}

#resultNet.negative {
    color: #e74c3c;
}

.config-section {
    margin: 30px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.config-section h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.3em;
}

.config-section p {
    margin-bottom: 15px;
    color: #666;
}

.config-inputs {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.config-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.config-input label {
    font-weight: 500;
    color: #555;
    font-size: 0.95em;
}

.config-input-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.simulation-settings-row {
    justify-content: center;
    align-items: flex-end;
}

.simulation-settings-row .config-input {
    margin-bottom: 0;
}

.simulation-section {
    margin-top: 20px;
    display: grid;
    gap: 20px;
}

.simulation-section.hidden {
    display: none;
}

.simulation-chart {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
}

.simulation-chart h3 {
    margin-bottom: 10px;
    text-align: center;
    color: #333;
}

.simulation-chart canvas {
    width: 100% !important;
    height: 260px !important;
}

.chart-summary {
    margin-top: 10px;
    display: grid;
    gap: 6px;
}

.chart-summary-row {
    display: flex;
    justify-content: space-between;
    color: #555;
}

.simulation-summary {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
    text-align: left;
}

.simulation-summary h3 {
    margin-bottom: 12px;
    text-align: center;
    color: #333;
}

.simulation-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #e0e0e0;
}

.simulation-summary-row:last-child {
    border-bottom: none;
}

.summary-label {
    color: #555;
}

.config-hint {
    color: #666;
    font-size: 0.85em;
}

.config-input input {
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.config-input input:focus {
    outline: none;
    border-color: #667eea;
}

.config-input input[type="number"] {
    max-width: 200px;
}

