:root {
    --bg-light: #f4f7f9;
    --surface-light: #ffffff;
    --text-light: #2c3e50;
    --text-muted-light: #7f8c8d;
    --border-light: #e6e9ed;
    --accent-light: #3498db;
    --accent-hover-light: #2980b9;

    --bg-dark: #1a1a1a;
    --surface-dark: #2c2c2c;
    --text-dark: #ecf0f1;
    --text-muted-dark: #95a5a6;
    --border-dark: #3e3e3e;
    --accent-dark: #3498db;
    --accent-hover-dark: #5dade2;

    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-dark: 0 4px 12px rgba(0, 0, 0, 0.3);
    --border-radius: 8px;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-light);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    background-color: var(--surface-light);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    max-width: 900px;
    width: 100%;
    transition: background-color 0.3s, box-shadow 0.3s;
}

h1, h2, h3, h4, summary {
    font-family: 'Montserrat', sans-serif;
    color: var(--text-light);
    transition: color 0.3s;
}

h1 { text-align: center; }
.subtitle { text-align: center; margin-top: -15px; color: var(--text-muted-light); }

.input-section, .info-section {
    background-color: var(--bg-light);
    border: 1px solid var(--border-light);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    transition: background-color 0.3s, border-color 0.3s;
}

.info-section summary {
    cursor: pointer;
    font-weight: bold;
}
.info-section div {
    margin-top: 15px;
}

.input-group { margin-bottom: 15px; }
.input-group label { display: block; margin-bottom: 5px; font-weight: bold; }
.input-group select {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 16px;
    background-color: var(--surface-light);
    color: var(--text-light);
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

button {
    display: block;
    width: 100%;
    padding: 12px;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    background-color: var(--accent-light);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-top: 10px;
}
button:hover { background-color: var(--accent-hover-light); }

#results-container {
    margin-top: 30px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
#results-container:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}
.hidden { display: none; }

#results {
    display: grid;
    gap: 15px;
    grid-template-columns: 1fr;
}

.result-card {
    background-color: var(--bg-light);
    border: 1px solid var(--border-light);
    padding: 15px;
    border-radius: var(--border-radius);
    transition: background-color 0.3s, border-color 0.3s;
}
.result-card h4 { margin: 0 0 10px 0; }
.result-card p { margin: 5px 0; }
.result-card .dice-roll {
    font-size: 0.9em;
    font-weight: bold;
    color: var(--text-muted-light);
    margin-right: 8px;
}

.adjacent-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }
.adjacent-direction h3 { margin: 0 0 10px 0; font-size: 1.1em; }

/* Tooltip Styles */
.tooltip-container { position: relative; display: inline-block; margin-left: 8px; }
.info-icon { font-size: 0.8em; cursor: help; border: 1px solid var(--text-muted-light); border-radius: 50%; width: 18px; height: 18px; display: inline-flex; justify-content: center; align-items: center; }
.tooltip-text { visibility: hidden; width: 220px; background-color: #555; color: #fff; text-align: center; border-radius: 6px; padding: 5px; position: absolute; z-index: 1; bottom: 125%; left: 50%; margin-left: -110px; opacity: 0; transition: opacity 0.3s; font-family: 'Roboto', sans-serif; font-size: 0.9em; }
.tooltip-container:hover .tooltip-text { visibility: visible; opacity: 1; }

/* Dark Mode Toggle */
#darkModeToggle {
    position: absolute;
    top: 15px;
    right: 15px;
    width: auto;
    padding: 8px 10px;
    font-size: 16px;
    background: none;
    border: none;
    cursor: pointer;
}

/* --- Dark Mode Styles --- */
body.dark-mode {
    background-color: var(--bg-dark);
    color: var(--text-dark);
}
body.dark-mode .container { background-color: var(--surface-dark); box-shadow: var(--shadow-dark); }
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3, body.dark-mode h4, body.dark-mode summary { color: var(--text-dark); }
body.dark-mode .subtitle { color: var(--text-muted-dark); }
body.dark-mode .input-section, body.dark-mode .info-section, body.dark-mode .result-card { background-color: var(--bg-dark); border-color: var(--border-dark); }
body.dark-mode .input-group select { background-color: var(--surface-dark); color: var(--text-dark); border-color: var(--border-dark); }
body.dark-mode button { background-color: var(--accent-dark); }
body.dark-mode button:hover { background-color: var(--accent-hover-dark); }
body.dark-mode .dice-roll { color: var(--text-muted-dark); }
body.dark-mode .info-icon { border-color: var(--text-muted-dark); }