* {
    box-sizing: border-box;
}

body {
    background-color: #1a1a2e;
    color: #e0e0e0;
    font-family: 'Segoe UI', system-ui, sans-serif;
    margin: 0;
    padding: 8px;
}

h1 {
    color: #a0c4ff;
    border-bottom: 1px solid #333;
    padding-bottom: 4px;
}

h3 {
    color: #c0d8ff;
}

p, li {
    color: #ccc;
    line-height: 1.6;
}

/* ── Header bar ── */
#header {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

#newGame, .collapsible {
    border: 1px solid #444;
    border-radius: 8px;
    padding: 8px 12px;
    background: #16213e;
}

#newGame {
    flex: 1 1 220px;
    max-width: 320px;
}

.collapsible {
    flex: 0 1 auto;
}

.collapsible summary {
    cursor: pointer;
    font-size: 14px;
    color: #aaa;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.collapsible summary::before {
    content: '▶';
    font-size: 10px;
    transition: transform 0.2s;
}

.collapsible[open] summary::before {
    transform: rotate(90deg);
}

#settings {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

/* New game button */
#newGameButton {
    width: 100%;
    max-width: 220px;
    padding: 8px;
    margin-bottom: 8px;
    background: #0f3460;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

#newGameButton:hover {
    background: #1a5276;
}

#newGameButton.btn-action-win {
    background: #1a6b3a;
    box-shadow: 0 0 8px #2ecc71;
}

#newGameButton.btn-action-win:hover {
    background: #27ae60;
}

#newGameButton.btn-action-lose {
    background: #7b1c1c;
    box-shadow: 0 0 8px #e74c3c;
}

#newGameButton.btn-action-lose:hover {
    background: #c0392b;
}

/* Sliders */
.wrapper.flex-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
}

.wrapper.flex-row p {
    margin: 0;
    white-space: nowrap;
    font-size: 14px;
    color: #aaa;
}

.slider {
    flex: 1;
    accent-color: #4a9eff;
    min-width: 0;
}

/* Settings checkboxes */
#settings label {
    font-size: 14px;
    color: #ccc;
    cursor: pointer;
}

#settings input[type=checkbox] {
    accent-color: #4a9eff;
    width: 15px;
    height: 15px;
    cursor: pointer;
}

/* Message log */
div.scroll {
    padding: 4px;
    width: 100%;
    height: 90px;
    overflow-x: hidden;
    overflow-y: auto;
    font-size: 13px;
    color: #aaa;
    background: #0d1b2a;
    border-radius: 4px;
}

/* ── Game area ── */
#gameInteractive {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

#gameFields {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1 1 auto;
    align-content: flex-start;
}


/* Roll box */
.rollBox {
    border: 1px solid #444;
    border-radius: 8px;
    padding: 10px 16px;
    background: #16213e;
    font-size: 32px;
    text-align: center;
    flex: 0 0 auto;
    align-self: flex-start;
}

#gameStats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 13px;
    margin-top: 6px;
}

#gameStats p {
    margin: 0;
    color: #aaa;
}

#winProb {
    font-weight: bold;
    color: #a0c4ff;
}

#gameRollButton {
    display: block;
    width: 100%;
    padding: 8px 14px;
    margin-bottom: 8px;
    background: #0f3460;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

#gameRollButton:hover {
    background: #1a5276;
}

#gameRollButton.btn-action {
    background: #1a6b3a;
    box-shadow: 0 0 8px #2ecc71;
}

#gameRollButton.btn-action:hover {
    background: #27ae60;
}

#rollDisplay {
    min-width: 60px;
    color: #e0e0e0;
}

/* ── Field tiles ── */
.fieldButtonContainer {
    display: inline-block;
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: 8px;
    background: #444;
    overflow: hidden;
}

.fieldButton {
    position: absolute;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
    transition: filter 0.15s;
}

.fieldButton:hover {
    filter: brightness(1.15);
}

.topLeft {
    color: rgba(0,0,0,0.5);
    position: absolute;
    left: 6px;
    top: 5px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1;
}

.fieldValue {
    color: #111;
    font-size: 36px;
    font-weight: bold;
    position: absolute;
    width: 100%;
    text-align: center;
    top: 24px;
    pointer-events: none;
    z-index: 1;
}

.probHint {
    color: rgba(0,0,0,0.6);
    font-size: 11px;
    position: absolute;
    left: 6px;
    bottom: 5px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1;
}

/* ── Docs section ── */
.docs {
    max-width: 1400px;
    margin-top: 24px;
}

/* ── Mobile ── */
@media (max-width: 600px) {
    #header {
        flex-direction: column;
    }

    #newGame, #settings, #messageBox {
        flex: 1 1 100%;
    }

    .fieldButtonContainer {
        width: 75px;
        height: 75px;
    }

    .fieldValue {
        font-size: 28px;
        top: 20px;
    }

    .rollBox {
        font-size: 24px;
    }

    #gameInteractive {
        flex-direction: column;
    }
}
