:root {
    --surface: #131313;
    --surface-lowest: #0e0e0e;
    --surface-low: #1c1b1b;
    --surface-container: #20201f;
    --surface-high: #2a2a2a;
    --surface-highest: #353535;
    --text: #e5e2e1;
    --muted: #dfbfbc;
    --outline: #a68a87;
    --outline-dim: #58413f;
    --primary: #ffb4ab;
    --primary-strong: #a83730;
    --primary-deep: #720e0e;
    --primary-black: #410002;
    --gold: #d4c5a1;
    --parchment: #f1e1bc;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    background:
        radial-gradient(circle at 50% 0%, rgba(114, 14, 14, 0.2), transparent 30rem),
        linear-gradient(180deg, var(--surface) 0%, var(--surface-lowest) 100%);
    color: var(--text);
    font-family: "Literata", Georgia, serif;
    margin: 0;
}

body::before {
    background-image: url("data:image/svg+xml;utf8,<svg width='120' height='120' xmlns='http://www.w3.org/2000/svg'><filter id='noise'><feTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/></filter><rect width='120' height='120' filter='url(%23noise)' opacity='0.045'/></svg>");
    content: "";
    inset: 0;
    pointer-events: none;
    position: fixed;
    z-index: 0;
}

a {
    color: var(--primary);
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.material-symbols-outlined {
    font-family: "Material Symbols Outlined";
    font-size: 1.35rem;
    font-style: normal;
    font-weight: normal;
    line-height: 1;
    vertical-align: middle;
}

.draft-page {
    margin: 0 auto;
    max-width: 1600px;
    min-height: 100vh;
    padding: 2rem;
    position: relative;
    width: 100%;
}

.draft-page--center {
    align-items: center;
    display: flex;
    justify-content: center;
}

.draft-page--wide {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.app-nav {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.app-nav a {
    border: 1px solid rgba(166, 138, 135, 0.3);
    color: var(--muted);
    font-family: "EB Garamond", Georgia, serif;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: 0.35rem 0.7rem;
    text-decoration: none;
    text-transform: uppercase;
}

.app-nav a:hover,
.app-nav a.active {
    border-color: var(--primary);
    color: var(--primary);
}

.panel {
    background: linear-gradient(180deg, rgba(42, 42, 42, 0.96), rgba(32, 32, 31, 0.96));
    border: 1px solid var(--outline-dim);
    box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.55), 0 16px 45px rgba(0, 0, 0, 0.5);
    position: relative;
}

.panel::before,
.panel::after {
    border-color: rgba(166, 138, 135, 0.45);
    content: "";
    height: 1.5rem;
    pointer-events: none;
    position: absolute;
    width: 1.5rem;
}

.panel::before {
    border-left: 1px solid;
    border-top: 1px solid;
    left: 0.5rem;
    top: 0.5rem;
}

.panel::after {
    border-bottom: 1px solid;
    border-right: 1px solid;
    bottom: 0.5rem;
    right: 0.5rem;
}

.panel--form {
    max-width: 64rem;
    padding: 2rem;
    width: 100%;
}

.panel--compact {
    max-width: 28rem;
    padding: 2rem;
    width: 100%;
}

.section-panel {
    background: rgba(32, 32, 31, 0.9);
    border: 1px solid rgba(88, 65, 63, 0.65);
    padding: 1.5rem;
}

.page-title {
    color: #fff;
    font-family: "EB Garamond", Georgia, serif;
    font-size: clamp(2.35rem, 8vw, 3.25rem);
    font-weight: 800;
    line-height: 1;
    margin: 0;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.page-subtitle {
    color: var(--muted);
    font-style: italic;
    margin: 0.75rem 0 0;
    text-align: center;
}

.section-title,
.field-label,
.eyebrow {
    color: var(--gold);
    font-family: "EB Garamond", Georgia, serif;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.divider {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0;
}

.divider::before,
.divider::after {
    background: linear-gradient(90deg, transparent, var(--outline-dim), transparent);
    content: "";
    flex: 1;
    height: 1px;
}

.form-grid {
    display: grid;
    gap: 1.25rem;
}

.settings-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    margin-top: 1rem;
}

.field {
    display: grid;
    gap: 0.45rem;
}

.input-frame {
    align-items: center;
    display: grid;
    gap: 0.5rem;
    grid-template-columns: auto 1fr;
}

.input,
.search-input {
    background: rgba(28, 27, 27, 0.85);
    border: 1px solid var(--outline-dim);
    border-radius: 0.25rem;
    color: var(--text);
    min-width: 0;
    outline: none;
    padding: 0.75rem 0.85rem;
    width: 100%;
}

.input-frame .input {
    background: transparent;
    border: 0;
    border-bottom: 2px solid var(--outline-dim);
    border-radius: 0;
}

.input:focus,
.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px rgba(255, 180, 171, 0.2);
}

.btn {
    align-items: center;
    border: 1px solid var(--outline-dim);
    display: inline-flex;
    font-family: "EB Garamond", Georgia, serif;
    font-weight: 800;
    gap: 0.5rem;
    justify-content: center;
    letter-spacing: 0.12em;
    min-height: 2.75rem;
    padding: 0.7rem 1.2rem;
    text-decoration: none;
    text-transform: uppercase;
    transition: transform 160ms ease, border-color 160ms ease, filter 160ms ease;
}

.btn:hover {
    filter: brightness(1.12);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    cursor: not-allowed;
    filter: grayscale(0.75);
    opacity: 0.5;
}

.btn-primary {
    background: linear-gradient(180deg, var(--primary-strong), var(--primary-deep));
    border-color: rgba(255, 180, 171, 0.75);
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

.btn-secondary {
    background: rgba(32, 32, 31, 0.9);
    color: var(--primary);
}

.btn-full {
    width: 100%;
}

.search-row {
    position: relative;
}

.search-row .material-symbols-outlined {
    color: var(--outline);
    left: 0.75rem;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.search-row .search-input {
    padding-left: 2.75rem;
}

.chip-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chip-grid--scroll {
    max-height: min(34rem, 54vh);
    overflow-y: auto;
    padding-right: 0.35rem;
}

.role-chip {
    align-items: center;
    background: rgba(42, 42, 42, 0.8);
    border: 1px solid var(--surface-highest);
    color: var(--muted);
    display: grid;
    gap: 0.35rem;
    justify-items: center;
    min-height: 6rem;
    padding: 0.85rem;
}

.role-chip-token {
    height: 2.75rem;
    object-fit: contain;
    width: 2.75rem;
}

.role-chip.is-selected {
    background: linear-gradient(180deg, rgba(114, 14, 14, 0.9), rgba(65, 0, 2, 0.9));
    border-color: var(--primary);
    color: var(--primary);
}

.toggle-row {
    align-items: center;
    border-top: 1px solid rgba(88, 65, 63, 0.65);
    color: var(--muted);
    display: grid;
    gap: 0.85rem;
    grid-template-columns: auto 1fr;
    margin-top: 1.25rem;
    padding-top: 1rem;
}

.toggle-row input {
    accent-color: var(--primary-deep);
    height: 1.15rem;
    width: 1.15rem;
}

.toggle-help {
    color: var(--muted);
    display: block;
    font-size: 0.86rem;
    margin-top: 0.15rem;
}

.lobby-code {
    background: rgba(32, 32, 31, 0.95);
    border: 1px solid var(--outline-dim);
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.75), 0 0 18px rgba(255, 180, 171, 0.12);
    color: #fff;
    display: inline-flex;
    font-family: "EB Garamond", Georgia, serif;
    font-size: clamp(2rem, 8vw, 3.25rem);
    font-weight: 800;
    letter-spacing: 0.2em;
    padding: 0.85rem 2rem;
    text-align: center;
}

.player-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    margin: 0 auto;
    max-width: 66rem;
    width: 100%;
}

.player-card {
    align-items: center;
    background: rgba(32, 32, 31, 0.92);
    border: 1px solid var(--outline-dim);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.75), 0 4px 12px rgba(0, 0, 0, 0.35);
    display: grid;
    justify-items: center;
    min-height: 12rem;
    padding: 1.5rem;
    text-align: center;
}

.player-card.is-host {
    border-color: var(--outline);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.75), 0 0 18px rgba(255, 180, 171, 0.16);
}

.player-card.is-empty {
    border-style: dashed;
    opacity: 0.4;
}

.avatar {
    align-items: center;
    background: var(--surface-high);
    border: 1px solid var(--outline-dim);
    display: flex;
    height: 4rem;
    justify-content: center;
    margin-bottom: 1rem;
    width: 4rem;
}

.player-name,
.character-name {
    color: #fff;
    font-family: "EB Garamond", Georgia, serif;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.status {
    color: var(--gold);
    font-family: "EB Garamond", Georgia, serif;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.lobby-meta,
.form-error,
.validation-message {
    color: var(--primary);
    font-size: 0.9rem;
    margin: 0;
}

.lobby-meta {
    color: var(--gold);
    margin-top: 0.75rem;
    text-align: center;
}

.settings-summary {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    margin: 0 auto;
    max-width: 80rem;
    width: 100%;
}

.settings-summary article {
    background: rgba(32, 32, 31, 0.9);
    border: 1px solid rgba(88, 65, 63, 0.65);
    display: grid;
    gap: 0.15rem;
    padding: 0.9rem 1rem;
    text-align: center;
}

.settings-summary strong {
    color: #fff;
    font-family: "EB Garamond", Georgia, serif;
    font-size: 1.45rem;
}

.info-bar {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.draft-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
}

.waiting-panel {
    align-items: center;
    background: rgba(19, 19, 19, 0.65);
    border: 1px solid rgba(88, 65, 63, 0.65);
    color: var(--muted);
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
}

.info-bar h1 {
    color: #fff;
    font-family: "EB Garamond", Georgia, serif;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 800;
    margin: 0;
}

.banned-row {
    display: flex;
    gap: 0.8rem;
    overflow-x: auto;
}

.token-slot {
    align-items: center;
    background: rgba(19, 19, 19, 0.85);
    border: 1px solid var(--outline-dim);
    display: flex;
    flex: 0 0 auto;
    height: 4.25rem;
    justify-content: center;
    position: relative;
    width: 4.25rem;
}

.token-slot img {
    height: 3.35rem;
    object-fit: contain;
    width: 3.35rem;
}

.token-button {
    color: inherit;
    padding: 0;
}

.token-button:hover:not(:disabled) {
    border-color: var(--primary);
}

.token-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.token-slot.is-banned img {
    filter: grayscale(1);
    opacity: 0.5;
}

.token-slot.is-banned::after {
    background: var(--primary);
    content: "";
    height: 2px;
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    width: 120%;
}

.filter-row {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.filter-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
}

.filter-tab {
    background: var(--surface-container);
    border: 1px solid var(--outline-dim);
    color: var(--text);
    flex: 0 0 auto;
    font-family: "EB Garamond", Georgia, serif;
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: 0.45rem 0.85rem;
    text-transform: uppercase;
}

.filter-tab.is-active {
    background: linear-gradient(180deg, var(--primary-deep), var(--primary-black));
    border-color: rgba(255, 180, 171, 0.45);
    color: var(--primary);
}

.character-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
}

.reveal-panel {
    display: grid;
    gap: 1rem;
}

.reveal-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
}

.reveal-card {
    align-items: center;
    background: rgba(19, 19, 19, 0.62);
    border: 1px solid rgba(88, 65, 63, 0.65);
    display: grid;
    gap: 0.85rem;
    grid-template-columns: auto 1fr;
    min-height: 6rem;
    padding: 0.9rem;
}

.storyteller-reveal {
    border-top: 1px solid rgba(88, 65, 63, 0.65);
    display: grid;
    gap: 1rem;
    padding-top: 1rem;
}

.player-result-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
}

.player-result-card {
    background: rgba(19, 19, 19, 0.62);
    border: 1px solid rgba(88, 65, 63, 0.65);
    display: grid;
    gap: 0.85rem;
    padding: 1rem;
}

.player-result-header {
    align-items: start;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.player-result-tokens {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.player-result-tokens .token-slot {
    height: 3.75rem;
    width: 3.75rem;
}

.player-result-tokens .token-slot img {
    height: 3rem;
    width: 3rem;
}

.script-output {
    background: rgba(14, 14, 14, 0.9);
    border: 1px solid var(--outline-dim);
    color: var(--text);
    font-family: Consolas, "Liberation Mono", monospace;
    font-size: 0.86rem;
    min-height: 18rem;
    outline: none;
    padding: 1rem;
    resize: vertical;
    width: 100%;
}

.character-card {
    align-items: center;
    background: rgba(32, 32, 31, 0.9);
    border: 1px solid rgba(88, 65, 63, 0.65);
    display: grid;
    gap: 0.9rem;
    justify-items: center;
    min-height: 11.5rem;
    padding: 1.1rem;
    position: relative;
    text-align: center;
    width: 100%;
}

.character-card:hover {
    background: var(--surface-high);
    border-color: var(--primary);
}

.character-card:disabled {
    cursor: not-allowed;
}

.character-card.is-locked {
    opacity: 0.55;
}

.character-token {
    height: 5rem;
    object-fit: contain;
    width: 5rem;
}

.team-label {
    color: var(--outline);
    display: block;
    font-family: "EB Garamond", Georgia, serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.home-actions {
    display: grid;
    gap: 0.75rem;
    margin-top: 2rem;
}

@media (min-width: 42rem) {
    .chip-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .home-actions {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 70rem) {
    .chip-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 46rem) {
    .draft-page {
        padding: 1rem;
    }

    .panel--form,
    .panel--compact {
        padding: 1.5rem;
    }

    .info-bar,
    .filter-row {
        align-items: stretch;
        flex-direction: column;
    }
}
