/* === General Elements === */
html,
body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100%;
    background: #000;
}

canvas {
    display: block;
}

/* === UI Buttons === */
#fullscreen-btn,
#toggle-rules,
#toggle-population,
#explain-rules-btn,
#explain-rules-5yo-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: #222;
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

#fullscreen-btn:hover,
#toggle-rules:hover,
#toggle-population:hover,
#explain-rules-btn:hover,
#explain-rules-5yo-btn:hover {
    background-color: #333;
    transform: scale(1.03);
    border-color: limegreen;
}

#fullscreen-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    padding: 14px 16px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    font-size: 14px;
    border-radius: 4px;
}

/* === Floating Panel === */
#floating-panel {
    position: absolute;
    top: 80px;
    left: 20px;
    max-width: calc(100vw - 40px);
    width: auto;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 12px;
    border: 2px solid limegreen;
    border-radius: 6px;
    cursor: move;
    z-index: 20;
    font-family: sans-serif;
    user-select: none;
}

#floating-panel h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    text-align: center;
}

#fullscreen-btn.inactive-ui,
#floating-panel.inactive-ui {
    opacity: 0.2;
    transition: opacity 2s ease;
}

/* === Utility Classes === */
.hidden-ui {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

body.hide-cursor {
    cursor: none;
}

.add-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: #222;
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    margin-bottom: 10px;
}

.add-btn:hover {
    background-color: #333;
    transform: scale(1.03);
    border-color: limegreen;
}

.trash-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1em;
    margin-left: 8px;
}

/* === Color Box === */
.color-box {
    width: 2em;
    height: 2em;
    border: 1px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
}

/* === Population Editor === */
#population-editor {
    margin-top: 10px;
    padding: 4px;
    font-size: 14px;
}

.pop-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
}

.pop-slider {
    flex-grow: 1;
    appearance: none;
    height: 6px;
    border-radius: 4px;
    background: #ccc;
    outline: none;
}

.pop-slider::-webkit-slider-thumb,
.pop-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 2px solid #666;
}

/* === Rule Table === */
#rule-editor {
    margin-top: 12px;
    max-height: calc(100vh - 220px);
    max-width: calc(100vw - 40px);
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
}

#rule-table {
    width: 100%;
    border-collapse: collapse;
    color: white;
    font-size: 12px;
}

#rule-table th,
#rule-table td {
    border: 1px solid #ccc;
    padding: 4px;
    text-align: center;
}

/* === Explanation Window === */
#explanation-window {
    padding: 2px 20px;
    position: fixed;
    top: 50%;
    left: 50%;
    max-height: calc(100vh - 220px);
    white-space: pre-wrap;
    font-family: sans-serif;
    line-height: 1.5;
    font-size: 14px;
    transform: translate(-50%, -50%);
    background: #222;
    color: white;
    border: 1px solid #888;
    border-radius: 8px;
    box-shadow: 0 0 12px #000;
    z-index: 1000;
    cursor: move;
    user-select: none;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
}

#close-explanation {
    position: absolute;
    top: 4px;
    right: 4px;
    background: none;
    color: white;
    border: none;
    font-size: 16px;
    cursor: pointer;
}

#explanation-window p {
    margin: 6px 0;
}

#explanation-window strong {
    display: block;
    margin-top: 6px;
    color: #fff;
}

#restart-btn {
    display: block;
    margin: 16px auto 4px auto;
    background-color: #16b93f;
    color: white;
    font-size: 16px;
    padding: 6px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

#restart-btn:hover {
    background-color: #e53935;
}

#wtf-window {
    padding: 2px 20px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #222;
    color: #b6b4b4;
    border: 1px solid #888;
    border-radius: 8px;
    box-shadow: 0 0 12px #000;
    z-index: 1000;
    font-family: 'Segoe UI', 'Roboto', 'Helvetica', sans-serif;
    line-height: 1.6;
    letter-spacing: 0.1px;
    font-size: 15px;
    cursor: move;
    user-select: none;
    max-width: 80vw;
    max-height: 80vh;
    overflow-y: auto;
}

#close-wtf {
    position: absolute;
    top: 4px;
    right: 4px;
    background: none;
    color: white;
    border: none;
    font-size: 16px;
    cursor: pointer;
}