:root {
    --bg: #070b22;
    --card: #12183a;
    --card-2: #0e1432;
    --line: rgba(231, 197, 106, 0.28);
    --gold: #e7c56a;
    --gold-deep: #c9a24a;
    --ink: #1c1606;
    --text: #f4f6fb;
    --muted: #aeb6d2;
    --green: #178a4c;
    --green-2: #0e3d28;
    --green-line: #46d98a;
    --danger: #ffb4b4;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    color: var(--text);
    font: 16px/1.55 "IBM Plex Sans", "Segoe UI", sans-serif;
    background:
        radial-gradient(900px 420px at 50% -10%, rgba(201, 162, 74, 0.18), transparent 60%),
        linear-gradient(180deg, #10163a 0%, var(--bg) 280px);
}
a { color: inherit; }
button, input { font: inherit; }
img { max-width: 100%; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 28px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    min-width: 0;
}
.brand img {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    object-fit: cover;
    flex: none;
}
.eyebrow, .label {
    display: block;
    color: var(--gold);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 700;
}
.brand strong { display: block; font-size: 16px; }
.nav-links, .nav-actions { display: flex; align-items: center; gap: 16px; }
.nav-links a { text-decoration: none; color: #d7dced; font-weight: 600; }
.nav-links a:hover { color: var(--gold); }

.wrap { width: min(1180px, calc(100% - 32px)); margin: 0 auto 48px; }
.login-wrap {
    width: min(560px, calc(100% - 32px));
    margin: 24px auto 48px;
}
.panel {
    background: linear-gradient(180deg, #171e42 0%, var(--card) 100%);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
}
.login-card { padding: 28px 26px 22px; }
.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 12px;
    background: #3a3218;
    color: var(--gold);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
h1 { margin: 12px 0 8px; font-size: clamp(28px, 4vw, 40px); line-height: 1.15; letter-spacing: -0.01em; }
h2 { margin: 0 0 6px; font-size: 22px; }
.lede, .hint, .team-copy p, .page-head p, .empty p, .table-head p { color: var(--muted); }
.hint { margin: 14px 0 0; font-size: 14px; }

.stack, .form-grid { display: grid; gap: 14px; }
.stack { margin-top: 18px; }
label { display: grid; gap: 7px; color: #e7ebf8; font-size: 14px; font-weight: 600; }
label span em { color: #ff8d8d; font-style: normal; margin-left: 2px; }
input {
    width: 100%;
    border: 1px solid #33406e;
    background: #0d1330;
    color: white;
    border-radius: 12px;
    padding: 12px 14px;
}
input:focus { outline: 2px solid rgba(231, 197, 106, 0.55); border-color: var(--gold); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 46px; }
.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--gold);
    cursor: pointer;
    transform: translateY(-50%);
}
.password-toggle svg { width: 20px; height: 20px; }
.password-toggle svg[hidden] { display: none !important; }
.password-toggle:hover { background: rgba(231, 197, 106, 0.12); }
.password-toggle:focus-visible { outline: 2px solid rgba(231, 197, 106, 0.55); }
input[readonly] { color: #d5dcf3; background: #101735; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: auto; }
.form-error { margin: 12px 0 0; color: var(--danger); font-weight: 700; }
ul.form-error { padding-left: 18px; }

.btn-gold, .btn-outline {
    border-radius: 999px;
    padding: 10px 16px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}
.btn-gold {
    border: 0;
    background: linear-gradient(180deg, #f3de9a, var(--gold-deep));
    color: var(--ink);
}
.btn-outline {
    border: 1.5px solid var(--gold);
    background: transparent;
    color: #f6e7bf;
}
.nav-actions form { margin: 0; }
.btn-gold:hover { filter: brightness(1.05); }
.btn-outline:hover { background: rgba(231, 197, 106, 0.12); }

.page-head, .table-head, .team-hero, .note-bar, .dialog-head, .dialog-actions {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}
.page-head { margin-bottom: 18px; }
.page-actions, .upload-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.upload-panel { padding: 18px; margin-bottom: 18px; }
.upload-panel h3 { margin: 16px 0 8px; font-size: 16px; }
.upload-form input[type="file"] { max-width: 360px; }
.identity {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0 0 16px;
}
.identity div {
    background: #0d1330;
    border: 1px solid #33406e;
    border-radius: 12px;
    padding: 10px 12px;
}
.identity dt { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.identity dd { margin: 4px 0 0; font-size: 16px; font-weight: 700; }
.team-hero { padding: 22px; margin-bottom: 16px; align-items: center; }
.crest, .team-card img {
    width: 108px;
    height: 108px;
    object-fit: contain;
    background: #f7f4ea;
    border-radius: 18px;
    padding: 8px;
    flex: none;
}
.team-copy { flex: 1; min-width: 0; }
.team-copy h1, .page-head h1 { margin-top: 8px; }
.bar {
    display: block;
    height: 8px;
    margin-top: 10px;
    border-radius: 99px;
    background: #2a335c;
    overflow: hidden;
}
.bar > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #1f9d57, #7dffb2);
}
.lock-note {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #3a2d12;
    border: 1px solid var(--gold);
    color: #ffe7ad;
    font-weight: 700;
}
.lock-bar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 16px 18px;
    margin-bottom: 18px;
}
.lock-bar h2 { margin-bottom: 4px; }
.lock-bar p { margin: 0; }
.lock-actions, .lock-bar form, .team-card form, .team-hero form { margin: 0; }
.lock-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.lock-state {
    display: inline-block;
    margin-top: 6px;
    color: var(--gold);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.team-card.is-locked { border-color: var(--gold); }
.lock-btn {
    width: 100%;
    border-radius: 999px;
    border: 1.5px solid var(--gold);
    background: transparent;
    color: #f6e7bf;
    font-weight: 700;
    padding: 8px 12px;
    cursor: pointer;
}
.team-card.is-locked .lock-btn { background: rgba(231, 197, 106, 0.16); }
.all-done {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #123d28;
    border: 1px solid var(--green-line);
    color: #dcffe9;
    font-weight: 700;
}
.toast {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 50;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: min(360px, calc(100% - 32px));
    margin: 0;
    padding: 14px 10px 14px 16px;
    border-radius: 16px;
    background: #123d28;
    border: 1px solid var(--green-line);
    color: #dcffe9;
    font-weight: 700;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
    animation: toast-in 0.28s ease;
}
.toast p { margin: 0; line-height: 1.35; }
.toast-close {
    flex: none;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #dcffe9;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.toast-close:hover { background: rgba(255, 255, 255, 0.1); }
.toast.is-leaving { animation: toast-out 0.22s ease forwards; }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: none; }
}
@keyframes toast-out {
    to { opacity: 0; transform: translateX(16px); }
}
.note-bar {
    margin: 0 0 18px;
    padding: 14px 16px;
    border-radius: 16px;
    background: linear-gradient(90deg, #24305f, #141b3c 28%);
    border-left: 4px solid var(--gold);
}
.size-chart { margin: 0 0 18px; padding: 0; }
.size-chart summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    list-style: none;
}
.size-chart summary::-webkit-details-marker { display: none; }
.size-chart summary::after {
    content: "";
    width: 10px;
    height: 10px;
    flex: none;
    border-right: 2px solid var(--gold);
    border-bottom: 2px solid var(--gold);
    transform: rotate(45deg);
    margin-right: 4px;
}
.size-chart[open] summary::after { transform: rotate(225deg); margin-top: 6px; }
.size-chart summary strong { display: block; font-size: 18px; }
.size-chart summary small { display: block; margin-top: 2px; color: var(--muted); font-size: 14px; }
.chart-gallery {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 16px 16px;
}
.chart-gallery figure { margin: 0; }
.chart-gallery img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 14px;
    background: #fff;
}
.note-bar strong { font-size: 18px; }
.note-bar p { margin: 4px 0 0; color: var(--gold); font-weight: 700; }
.back-link { display: inline-block; margin-bottom: 12px; color: var(--gold); font-weight: 700; text-decoration: none; }
.empty { padding: 28px; }

.grid, .team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 14px;
}
.team-grid { margin-bottom: 22px; }
.player-card, .team-card {
    position: relative;
    min-height: 210px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #1a2148, #12183a);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}
.player-card.is-complete, .team-card.is-complete {
    background: linear-gradient(180deg, #1c8a4e, var(--green-2));
    border-color: var(--green-line);
}
.card-hit, .team-card-link {
    display: flex;
    width: 100%;
    color: inherit;
    text-align: left;
    text-decoration: none;
}
.card-hit {
    flex-direction: column;
    gap: 4px;
    min-height: 210px;
    padding: 16px 16px 62px;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
}
.team-card { display: flex; flex-direction: column; min-height: 0; padding: 0; overflow: hidden; }
.team-card-link { align-items: center; gap: 12px; padding: 14px; flex: 1; }
.team-card form { padding: 0 14px 14px; }
.team-card div { flex: 1; min-width: 0; }
.team-card strong, .player-name { display: block; font-size: 18px; }
.team-card span, .code, .meta, .pending-copy { color: var(--muted); }
.player-card.is-complete .code,
.player-card.is-complete .meta,
.player-card.is-complete .pending-copy,
.team-card.is-complete span { color: #e7fff1; }
.team-card .lock-state { color: var(--gold); }
.team-card.is-complete .lock-state { color: #fff4c8; }
.card-top, .measures li { display: flex; justify-content: space-between; gap: 8px; }
.role, .state {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.role { color: var(--gold); }
.player-card.is-complete .role { color: #fff4c8; }
.state { color: #d7deef; font-style: normal; }
.measures { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.measures b { font-variant-numeric: tabular-nums; }
.hover-action {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 14px;
}
.hover-action {
    border-radius: 999px;
    padding: 8px 12px;
    text-align: center;
    background: var(--gold);
    color: var(--ink);
    font-weight: 700;
    opacity: 0;
    transform: translateY(6px);
    transition: 0.16s ease;
}
.player-card:hover .hover-action,
.player-card:focus-within .hover-action { opacity: 1; transform: none; }
.player-card.is-complete .hover-action { background: #f4fff8; color: var(--green-2); }
.player-card.is-locked .card-hit { cursor: default; }
.player-card.is-locked .hover-action {
    opacity: 1;
    transform: none;
    background: #2a335c;
    color: #f6e7bf;
}

.squad-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 0 0 14px;
    padding: 8px 8px 8px 14px;
    border-radius: 18px;
    background: linear-gradient(90deg, #24305f, #141b3c 42%);
    border: 1px solid var(--line);
    border-left: 4px solid var(--gold);
}
.squad-search {
    position: relative;
    display: block;
    flex: 1;
    min-width: 0;
    gap: 0;
    font-weight: 600;
}
.squad-search svg {
    position: absolute;
    left: 14px;
    top: 50%;
    width: 16px;
    height: 16px;
    transform: translateY(-50%);
    fill: none;
    stroke: var(--gold);
    stroke-width: 2;
    stroke-linecap: round;
    pointer-events: none;
}
.squad-search input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border-radius: 14px;
    background: #0d1330;
}
.view-switch {
    display: inline-flex;
    flex: none;
    gap: 4px;
    padding: 4px;
    border-radius: 16px;
    background: #0d1330;
    border: 1px solid rgba(231, 197, 106, 0.38);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}
.view-switch button {
    width: 42px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #9aa3c4;
    padding: 0;
    cursor: pointer;
}
.view-switch button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
}
.view-switch button[data-view="cards"] svg { fill: currentColor; stroke: none; }
.view-switch button[aria-pressed="true"] {
    background: linear-gradient(180deg, #f7e7b4, var(--gold));
    color: var(--ink);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
}
.squad-scroll {
    max-height: 70vh;
    overflow: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(231, 197, 106, 0.75) transparent;
}
.squad-scroll::-webkit-scrollbar { width: 10px; }
.squad-scroll::-webkit-scrollbar-thumb {
    border-radius: 99px;
    background: rgba(231, 197, 106, 0.7);
    border: 2px solid transparent;
    background-clip: padding-box;
}
#squad-cards { display: none; }
#squad-rows { display: grid; }
html[data-squad-view="cards"] #squad-cards { display: grid; }
html[data-squad-view="cards"] #squad-rows { display: none; }
.sheet { gap: 12px; }
[data-player][hidden] { display: none !important; }
.sheet-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.3fr) repeat(3, minmax(120px, 1fr)) auto;
    gap: 12px;
    align-items: end;
    margin: 0;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #1a2148, #12183a);
}
.sheet-row.is-complete {
    background: linear-gradient(180deg, #1c8a4e, var(--green-2));
    border-color: var(--green-line);
}
.sheet-row.has-error { border-color: #ff8d8d; }
.sheet-who strong { display: block; font-size: 18px; }
.sheet-who .code { display: block; }
.sheet-row label span {
    color: var(--gold);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.sheet-row.is-complete label span,
.sheet-row.is-complete .role { color: #fff4c8; }
.sheet-row.is-complete .code { color: #e7fff1; }
.sheet-row .btn-gold { white-space: nowrap; margin-bottom: 1px; }
.sheet-error { grid-column: 1 / -1; margin: 0; }
.sheet-measure span {
    display: block;
    color: var(--gold);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.sheet-row.is-complete .sheet-measure span { color: #fff4c8; }
.sheet-measure b { display: block; margin-top: 6px; font-size: 16px; }
.sheet-lock {
    align-self: center;
    border-radius: 999px;
    padding: 8px 12px;
    background: #2a335c;
    color: #f6e7bf;
    font-weight: 700;
    text-align: center;
}

.table-panel { padding: 16px; }
.table-head { margin-bottom: 12px; align-items: end; }
.table-head input { max-width: 280px; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px 10px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
th { color: var(--gold); font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }
.row-complete td { background: rgba(20, 90, 52, 0.55); }

dialog {
    width: min(760px, calc(100% - 24px));
    border: 1px solid var(--line);
    border-radius: 22px;
    background: #121833;
    color: var(--text);
    padding: 22px;
    box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(4, 6, 16, 0.75); }
.dialog-head { align-items: flex-start; margin-bottom: 16px; }
.dialog-head h2 { color: var(--gold); }
.dialog-head p { margin: 4px 0 0; color: var(--muted); }
.step {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    flex: none;
    border-radius: 50%;
    background: var(--gold);
    color: var(--ink);
    font-weight: 700;
}
.form-grid { grid-template-columns: 1fr 1fr; }
.span-2 { grid-column: 1 / -1; }
.dialog-actions { justify-content: flex-end; margin-top: 16px; }

@media (hover: none) {
    .hover-action { opacity: 1; transform: none; }
}
@media (max-width: 800px) {
    .topbar, .page-head, .team-hero, .note-bar, .table-head, .lock-bar { align-items: flex-start; flex-direction: column; }
    .sheet-row { grid-template-columns: 1fr; align-items: stretch; }
    .nav-links { display: none; }
    .form-grid, .identity, .chart-gallery { grid-template-columns: 1fr; }
    .page-actions { width: 100%; }
    .span-2 { grid-column: auto; }
    .team-card { min-height: 0; }
}
