/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    background-color: #0d0d10;
    color: #c8c8d4;
    font-family: system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: #8b6f3e;
    text-decoration: none;
}

a:hover {
    color: #a8894e;
    text-decoration: underline;
}

h1, h2, h3 {
    color: #ddd8cc;
    font-weight: 600;
    line-height: 1.2;
}

/* ── Nav ──────────────────────────────────────────── */
.site-nav {
    background-color: #16161c;
    border-bottom: 1px solid #2a2a35;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: #8b6f3e;
    letter-spacing: 0.05em;
    text-decoration: none;
}

.nav-brand:hover {
    color: #a8894e;
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-username {
    color: #9090a8;
    font-size: 0.9rem;
}

.logout-form {
    display: inline;
}

/* ── Flash Messages ───────────────────────────────── */
.flash {
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
}

.flash-success {
    background-color: #2d5a2d;
    color: #c0f0c0;
    border-bottom: 1px solid #3a703a;
}

.flash-error {
    background-color: #5a2d2d;
    color: #f0c0c0;
    border-bottom: 1px solid #703a3a;
}

/* ── Main Content ─────────────────────────────────── */
main {
    flex: 1;
    padding: 2rem 1.5rem;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
}

/* ── Buttons ──────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 0.5rem 1.1rem;
    border-radius: 3px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
    line-height: 1.4;
}

.btn-primary {
    background-color: #8b6f3e;
    color: #0d0d10;
    font-weight: 600;
}

.btn-primary:hover {
    background-color: #a8894e;
    color: #0d0d10;
    text-decoration: none;
}

.btn-ghost {
    background-color: transparent;
    color: #9090a8;
    border: 1px solid #2a2a35;
}

.btn-ghost:hover {
    background-color: #1a1a20;
    color: #c8c8d4;
    text-decoration: none;
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
    background-color: #1e1e28;
    color: #8b6f3e;
    border: 1px solid #2a2a35;
}

.btn-sm:hover {
    background-color: #252530;
    color: #a8894e;
    text-decoration: none;
}

.btn-full {
    width: 100%;
    text-align: center;
}

/* ── Forms ────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    color: #a0a0b8;
}

.label-hint {
    color: #606078;
    font-style: italic;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;
    background-color: #1a1a20;
    border: 1px solid #2a2a35;
    border-radius: 3px;
    color: #c8c8d4;
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.55rem 0.75rem;
    transition: border-color 0.15s;
    outline: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    border-color: #8b6f3e;
}

select option {
    background-color: #1a1a20;
    color: #c8c8d4;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.has-error input,
.has-error select,
.has-error textarea {
    border-color: #8b3030;
}

.field-error {
    display: block;
    margin-top: 0.3rem;
    padding: 0.3rem 0.6rem;
    background-color: #8b3030;
    color: #f0c0c0;
    font-size: 0.85rem;
    border-radius: 2px;
}

/* ── Auth Pages ───────────────────────────────────── */
.auth-container {
    max-width: 420px;
    margin: 2rem auto;
}

.auth-container h1 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.auth-form {
    background-color: #13131a;
    border: 1px solid #2a2a35;
    border-radius: 4px;
    padding: 1.75rem;
    margin-bottom: 1rem;
}

.auth-switch {
    text-align: center;
    font-size: 0.9rem;
    color: #7070888;
}

/* ── Dashboard ────────────────────────────────────── */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.empty-state {
    background-color: #13131a;
    border: 1px solid #2a2a35;
    border-radius: 4px;
    padding: 3rem 2rem;
    text-align: center;
    color: #7070888;
}

.empty-state p {
    margin-bottom: 0.5rem;
    color: #707088;
}

.run-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.run-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid #2a2a35;
    color: #8b8b9e;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.run-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid #1e1e28;
    vertical-align: middle;
}

.run-table tr:hover td {
    background-color: #13131a;
}

.status-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.status-active {
    background-color: #1e3a1e;
    color: #80c880;
}

.status-dead {
    background-color: #3a1e1e;
    color: #c88080;
}

.status-abandoned {
    background-color: #2a2a35;
    color: #808090;
}

/* ── New Run ──────────────────────────────────────── */
.new-run-container {
    max-width: 540px;
    margin: 1rem auto;
}

.new-run-container h1 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.new-run-form {
    background-color: #13131a;
    border: 1px solid #2a2a35;
    border-radius: 4px;
    padding: 1.75rem;
}

/* ── Play Page ────────────────────────────────────── */
.play-container {
    max-width: 860px;
    margin: 0 auto;
}

.play-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.play-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.play-character {
    color: #ddd8cc;
    font-weight: 600;
}

.play-sep {
    color: #2a2a35;
}

.play-race {
    color: #9090a8;
}

.play-floor {
    color: #8b6f3e;
}

.canvas-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

#game-canvas {
    display: block;
    border: 1px solid #2a2a35;
    background-color: #080810;
    max-width: 100%;
}

.dungeon-awaits {
    color: #505068;
    font-style: italic;
    font-size: 0.9rem;
}

/* ── Dividers ─────────────────────────────────────── */
hr {
    border: none;
    border-top: 1px solid #2a2a35;
    margin: 1.5rem 0;
}
