:root {
    --bg: #2a0710;
    --bg-deep: #1a0509;
    --panel: #3a1018;
    --ink: #1a120c;
    --cream: #fff6ea;
    --gold: #e0b04a;
    --line: rgba(255, 246, 234, 0.14);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(1200px 500px at 50% -80px, rgba(224, 176, 74, 0.16), transparent 60%),
        var(--bg);
    color: var(--cream);
    font-family: "Source Sans 3", "Segoe UI", sans-serif;
}

img { max-width: 100%; display: block; }

button, input { font: inherit; color: inherit; }

.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.topbar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.25rem 0.2rem;
}

.topbar-mark {
    color: var(--gold);
    font-family: Oswald, Impact, sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-decoration: none;
    text-transform: uppercase;
}

.topbar-nav {
    display: flex;
    gap: 0.35rem;
    margin-right: auto;
    margin-left: 0.75rem;
}

.topbar-nav a {
    color: var(--cream);
    text-decoration: none;
    font-weight: 700;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
}

.topbar-nav a[aria-current="page"] {
    background: var(--gold);
    color: #2a1604;
}

.topbar-meta {
    margin: 0;
    color: rgba(255, 246, 234, 0.72);
    font-size: 0.92rem;
}

.hero {
    padding: 0.4rem 1rem 0.2rem;
}

.hero img {
    width: min(920px, 100%);
    height: auto;
    margin: 0 auto;
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.game-wrap {
    width: min(920px, calc(100% - 1.5rem));
    margin: 0 auto;
    padding: 0.4rem 0 calc(2.5rem + var(--safe-bottom));
}

.game-kicker {
    margin: 0.8rem 0 0.2rem;
    color: var(--gold);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.game-wrap h1 {
    margin: 0;
    font-family: Oswald, Impact, sans-serif;
    font-size: clamp(2rem, 8vw, 3.4rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 0.95;
    text-transform: uppercase;
}

.game-lede {
    margin: 0.7rem 0 0;
    max-width: 36rem;
    font-size: 1.15rem;
    line-height: 1.4;
    color: rgba(255, 246, 234, 0.86);
}

.facts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin: 1.2rem 0 0;
}

.facts div {
    margin: 0;
    padding: 0.9rem 1rem;
    background: rgba(20, 4, 8, 0.45);
    border: 1px solid var(--line);
    border-radius: 16px;
}

.facts dt {
    color: var(--gold);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.facts dd {
    margin: 0.2rem 0 0;
    font-family: Oswald, Impact, sans-serif;
    font-size: 1.35rem;
    letter-spacing: 0.02em;
    line-height: 1.15;
}

.rules-card {
    margin-top: 0.75rem;
    padding: 0.9rem 1rem;
    border: 1px dashed rgba(224, 176, 74, 0.45);
    border-radius: 16px;
}

.rules-card h2 {
    margin: 0;
    font-family: Oswald, Impact, sans-serif;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.rules-card p {
    margin: 0.35rem 0 0;
    color: rgba(255, 246, 234, 0.78);
}

.signup-call {
    margin-top: 1.35rem;
    padding: 1.15rem 1.15rem 1.25rem;
    border-radius: 18px;
    background:
        radial-gradient(420px 160px at 0% 0%, rgba(224, 176, 74, 0.22), transparent 70%),
        linear-gradient(165deg, #6e2430 0%, #3b0a12 58%, #241018 100%);
    border: 1px solid rgba(224, 176, 74, 0.55);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}

.signup-call .game-kicker { margin-top: 0; }

.signup-call h2 {
    margin: 0.1rem 0 0;
    font-family: Oswald, Impact, sans-serif;
    font-size: clamp(2.1rem, 7vw, 3rem);
    font-weight: 600;
    letter-spacing: 0.03em;
    line-height: 0.95;
    text-transform: uppercase;
}

.signup-call p {
    margin: 0.55rem 0 0;
    max-width: 34rem;
    color: rgba(255, 246, 234, 0.88);
    line-height: 1.4;
}

.game-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    margin: 1rem 0 0;
}

.game-signup {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 0.85rem 1.6rem;
    border-radius: 999px;
    background: var(--gold);
    color: #2a1604;
    font-family: Oswald, Impact, sans-serif;
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-decoration: none;
    text-transform: uppercase;
    box-shadow: 0 5px 0 #8a6a1e;
}

.game-roster {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--gold);
    font-weight: 700;
    text-decoration: none;
}

.empty-roster {
    margin: 0.4rem 0 0;
    padding: 1rem 1.1rem;
    border-radius: 14px;
    background: rgba(20, 4, 8, 0.45);
    border: 1px solid var(--line);
}

.empty-roster a { color: var(--gold); font-weight: 700; }

.admin-note {
    margin: 0 0 0.85rem;
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    background: rgba(224, 176, 74, 0.14);
    border: 1px solid rgba(224, 176, 74, 0.45);
}

.admin-note a, .topbar-meta a { color: var(--gold); font-weight: 700; }

.tile-admin { margin: 0.45rem 0 0; }

.tile-admin a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border-radius: 999px;
    background: var(--gold);
    color: #2a1604;
    font-weight: 700;
    text-decoration: none;
}

.edit-photo {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 50%;
    margin-bottom: 0.45rem;
}

.remove-form {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.remove-form button {
    width: 100%;
    min-height: 48px;
    background: transparent;
    color: #ffd0d0;
    border: 1px solid rgba(255, 180, 180, 0.6);
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
}

.remove-form p {
    margin: 0.45rem 0 0;
    color: rgba(255, 246, 234, 0.72);
}

.board-wrap {
    width: min(1280px, calc(100% - 1.5rem));
    margin: 0 auto;
    padding: 1.1rem 0 2.5rem;
}

.board-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: end;
    margin-bottom: 0.9rem;
}

.board-head h1,
.panel-head h2 {
    margin: 0;
    font-family: Oswald, Impact, sans-serif;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.board-head h1 { font-size: 1.8rem; }

.board-head p {
    margin: 0.25rem 0 0;
    max-width: 42rem;
    color: rgba(255, 246, 234, 0.78);
}

.counts {
    margin: 0;
    color: var(--gold);
    font-weight: 700;
    white-space: nowrap;
}

.board {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 1rem;
    align-items: start;
}

.pool, .team {
    background: rgba(20, 4, 8, 0.45);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0.85rem;
}

.pool { position: sticky; top: 0.6rem; }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.7rem;
}

.panel-head h2 { font-size: 1.15rem; }

.pill {
    min-width: 1.8rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: rgba(224, 176, 74, 0.16);
    color: var(--gold);
    font-weight: 700;
    text-align: center;
}

.search input,
.team-name,
.move select,
#add-team,
.team-delete {
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(255, 246, 234, 0.06);
}

.search input {
    width: 100%;
    margin-bottom: 0.7rem;
    padding: 0.65rem 0.75rem;
    color: var(--cream);
}

.search input::placeholder { color: rgba(255, 246, 234, 0.45); }

.drop {
    min-height: 8rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    border-radius: 12px;
    padding: 0.35rem;
}

.pool .drop { max-height: calc(100vh - 220px); overflow: auto; }

.drop.is-over {
    outline: 2px dashed var(--gold);
    outline-offset: 2px;
    background: rgba(224, 176, 74, 0.08);
}

.hint {
    margin: auto;
    padding: 1.2rem 0.5rem;
    text-align: center;
    color: rgba(255, 246, 234, 0.55);
}

.card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.65rem;
    align-items: center;
    padding: 0.45rem 0.5rem;
    border-radius: 12px;
    background: var(--cream);
    color: var(--ink);
    cursor: grab;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset;
}

.card.is-dragging { opacity: 0.45; }

.card.is-hidden { display: none; }

.mark {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #3b0a12;
    color: var(--gold);
    font-family: Oswald, Impact, sans-serif;
    font-weight: 600;
    letter-spacing: 0.04em;
    overflow: hidden;
}

.mark img { width: 100%; height: 100%; object-fit: cover; }

.meta strong { display: block; line-height: 1.15; }

.meta span {
    color: #7a6556;
    font-size: 0.86rem;
    font-weight: 700;
}

.move select {
    max-width: 7.2rem;
    padding: 0.35rem 0.3rem;
    background: #fff;
    color: var(--ink);
    border-color: rgba(26, 18, 12, 0.15);
}

.teams {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.8rem;
}

.team { border-top: 5px solid var(--team, var(--gold)); }

.team-name {
    width: 100%;
    padding: 0.35rem 0.5rem;
    font-family: Oswald, Impact, sans-serif;
    font-size: 1.15rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    background: transparent;
    border-color: transparent;
}

.team-name:focus { border-color: var(--gold); background: rgba(0, 0, 0, 0.2); }

.team-tools { display: flex; align-items: center; gap: 0.35rem; }

#add-team, .team-delete {
    padding: 0.4rem 0.7rem;
    cursor: pointer;
    color: var(--cream);
}

#add-team { background: var(--gold); color: #2a1604; border-color: transparent; font-weight: 700; }

.team-delete {
    width: 2rem;
    height: 2rem;
    padding: 0;
    line-height: 1;
}

.footnote { margin: 1rem 0 0; font-size: 0.85rem; }
.footnote a { color: rgba(255, 246, 234, 0.55); }

.banner {
    padding: 0.8rem 1rem;
    border-radius: 12px;
    background: #5c1020;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(1rem + var(--safe-bottom));
    transform: translateX(-50%);
    padding: 0.65rem 0.9rem;
    border-radius: 999px;
    background: #1a0509;
    color: var(--cream);
    border: 1px solid var(--gold);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.player-search { min-width: min(100%, 16rem); }
.player-search input { margin-bottom: 0; }

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 168px), 1fr));
    gap: 0.85rem;
}

.tile { min-height: 280px; }
.tile[hidden] { display: none; }

.flip { height: 280px; perspective: 1000px; }

.flip-inner {
    position: relative;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
}

.flip.is-flipped .flip-inner { transform: rotateY(180deg); }
.flip.is-flipped .flip-front { pointer-events: none; }
.flip.is-flipped .flip-back { pointer-events: auto; }

.flip-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.9rem 0.75rem;
    border: 0;
    border-radius: 16px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.flip-front {
    background: var(--cream);
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.flip-front:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 3px;
}

.flip-back {
    pointer-events: none;
    transform: rotateY(180deg);
    background: #3b0a12;
    color: var(--cream);
    border: 1px solid rgba(224, 176, 74, 0.45);
    overflow: hidden;
    cursor: pointer;
    align-items: stretch;
    justify-content: flex-start;
    text-align: left;
}

.mark-lg {
    width: 72px;
    height: 72px;
    font-size: 1.45rem;
}

.tile-name {
    font-family: Oswald, Impact, sans-serif;
    font-size: 1.2rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.1;
}

.tile-jersey {
    color: #7a6556;
    font-weight: 700;
}

.tile-hint {
    margin-top: auto;
    color: #9a7b32;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.flip-back .tile-hint { color: rgba(224, 176, 74, 0.8); }

.back-name {
    margin: 0;
    font-family: Oswald, Impact, sans-serif;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.back-bio {
    margin: 0.35rem 0 0.55rem;
    font-size: 0.9rem;
    line-height: 1.3;
    overflow: auto;
    flex: 0 0 auto;
    max-height: 5.4em;
}

.stat-bits,
.back-empty,
.flip-back .tile-hint { flex: none; }

.back-empty {
    margin: 0.4rem 0 0;
    color: rgba(255, 246, 234, 0.7);
}

.stat-bits {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
    margin: 0;
}

.stat-bits div {
    background: rgba(255, 246, 234, 0.08);
    border-radius: 8px;
    padding: 0.3rem 0.4rem;
}

.stat-bits dt {
    color: var(--gold);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.stat-bits dd {
    margin: 0;
    font-family: Oswald, Impact, sans-serif;
    font-size: 1.15rem;
}

.empty-search { color: rgba(255, 246, 234, 0.75); }

.tile-nick {
    color: #9a7b32;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
}

.flip-back .tile-nick {
    color: var(--gold);
    text-align: left;
    margin: 0;
}

.tile-role {
    color: #7a6556;
    font-size: 0.85rem;
    font-weight: 700;
    text-align: center;
}

.flip-front .tile-role {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.flip-back .tile-role {
    color: var(--gold);
    text-align: left;
    margin: 0;
}

.signup-wrap { max-width: 720px; }

.signup-form {
    display: grid;
    gap: 0.85rem;
    background: rgba(20, 4, 8, 0.45);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1rem;
}

.signup-form label {
    display: grid;
    gap: 0.35rem;
    font-weight: 700;
}

.signup-form label[hidden],
.signup-form [hidden] { display: none; }

.signup-choice {
    margin: 0;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    display: grid;
    gap: 0.45rem;
}

.signup-choice legend {
    padding: 0 0.25rem;
    font-weight: 700;
}

.signup-form label.choice {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 600;
}

.signup-form label.choice input {
    width: auto;
}

.dream-note {
    margin: 0;
    color: var(--gold);
    font-size: 0.92rem;
}

.dream-picks {
    max-height: 16rem;
    overflow: auto;
    display: grid;
    gap: 0.35rem;
    padding: 0.35rem 0.15rem;
}

.dream-label {
    margin: 0.45rem 0 0;
    color: var(--gold);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.dream-list {
    margin: 0.15rem 0 0.3rem;
    padding: 0;
    list-style: none;
    flex: 0 0 auto;
    min-height: 3.4em;
    max-height: 4.8em;
    overflow: auto;
    font-size: 0.85rem;
}

.flip-back:has(.dream-list) .back-bio { max-height: 2.6em; }

.signup-form input,
.signup-form select,
.signup-form textarea {
    width: 100%;
    max-width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(255, 246, 234, 0.08);
    color: var(--cream);
    font-size: 16px;
}

.signup-form select option { color: #1a120c; }

.signup-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.signup-form button {
    justify-self: start;
    background: var(--gold);
    color: #2a1604;
    border: 0;
    border-radius: 10px;
    padding: 0.8rem 1rem;
    font-weight: 700;
    cursor: pointer;
}

.banner-ok { background: #1f4d3a; }
.banner a { color: var(--gold); }

@media (min-width: 700px) {
    .facts { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
    .signup-row { grid-template-columns: 1fr; }
    .game-actions { flex-direction: column; align-items: stretch; }
    .game-signup, .game-roster { width: 100%; justify-content: center; }
    .signup-form button { width: 100%; }
    .topbar { padding-left: 0.85rem; padding-right: 0.85rem; }
    .topbar-nav a { min-height: 44px; display: inline-flex; align-items: center; }
    .hero { padding-left: 0.75rem; padding-right: 0.75rem; }
    .tile-name, .back-name, .facts dd { overflow-wrap: anywhere; }
}

@media (prefers-reduced-motion: reduce) {
    .flip-inner { transition: none; }
}

@media (max-width: 860px) {
    .topbar { flex-wrap: wrap; align-items: center; gap: 0.45rem 0.75rem; }
    .topbar-nav { flex-wrap: wrap; margin-left: 0; }
    .topbar-meta { flex-basis: 100%; }
    .board { grid-template-columns: 1fr; }
    .pool { position: static; }
    .pool .drop { max-height: 28rem; }
    .board-head { flex-direction: column; align-items: flex-start; }
    .card { grid-template-columns: auto 1fr; }
    .move { grid-column: 1 / -1; }
    .move select { max-width: none; width: 100%; }
}
