:root {
    --bg-deep: #071018;
    --bg-panel: rgba(12, 24, 36, 0.82);
    --bg-panel-solid: #0c1824;
    --line: rgba(0, 229, 212, 0.22);
    --line-strong: rgba(0, 229, 212, 0.55);
    --cyan: #00e5d4;
    --cyan-dim: #00b3a6;
    --amber: #ffb020;
    --coral: #ff6b4a;
    --mint: #5dffb1;
    --text: #e8f4ff;
    --text-muted: #8aa3b8;
    --danger: #ff5d7a;
    --success: #3dffa8;
    --radius: 28px;
    --radius-sm: 16px;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    --font-display: "Orbitron", "Segoe UI", sans-serif;
    --font-body: "Manrope", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg-deep);
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(ellipse 80% 50% at 10% -10%, rgba(0, 229, 212, 0.18), transparent 55%),
        radial-gradient(ellipse 60% 40% at 90% 10%, rgba(255, 176, 32, 0.12), transparent 50%),
        radial-gradient(ellipse 50% 60% at 70% 100%, rgba(76, 201, 240, 0.1), transparent 55%),
        linear-gradient(165deg, #071018 0%, #0a1622 45%, #061018 100%);
}

.curve-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.curve-bg svg {
    position: absolute;
    width: 140%;
    height: 140%;
    left: -20%;
    top: -20%;
    opacity: 0.55;
}

.wrap {
    width: min(1400px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.25rem 0 3rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
    padding: 1rem 1.35rem;
    background: linear-gradient(135deg, rgba(12, 28, 42, 0.9), rgba(8, 18, 28, 0.75));
    border: 1px solid var(--line);
    border-radius: 999px;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: var(--text);
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background:
        conic-gradient(from 210deg, var(--cyan), var(--amber), var(--coral), var(--cyan));
    display: grid;
    place-items: center;
    position: relative;
}

.brand-mark::after {
    content: "EPL";
    font-family: var(--font-display);
    font-size: 0.62rem;
    font-weight: 700;
    color: #041018;
    background: #dffcf8;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
}

.brand-text strong {
    display: block;
    font-family: var(--font-display);
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.brand-text span {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.nav-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

h1, h2, h3 {
    font-family: var(--font-display);
    letter-spacing: 0.04em;
    margin: 0 0 0.5rem;
}

h1 { font-size: clamp(1.5rem, 3vw, 2.2rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }

.muted { color: var(--text-muted); }

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.35rem;
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.panel::before {
    content: "";
    position: absolute;
    inset: auto -20% -40% 40%;
    height: 70%;
    background: radial-gradient(circle, rgba(0, 229, 212, 0.08), transparent 65%);
    pointer-events: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

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

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

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

.stack { display: grid; gap: 1rem; }

.card-list {
    display: grid;
    gap: 0.85rem;
}

.auction-card, .entity-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.15rem;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: linear-gradient(120deg, rgba(255,255,255,0.03), rgba(0,229,212,0.04));
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.auction-card:hover, .entity-card:hover {
    transform: translateY(-2px);
    border-color: var(--line-strong);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border: 1px solid transparent;
}

.badge-draft { background: rgba(138,163,184,0.15); color: #b7c9d8; border-color: rgba(138,163,184,0.35); }
.badge-live { background: rgba(61,255,168,0.12); color: var(--success); border-color: rgba(61,255,168,0.35); animation: pulse 1.8s ease infinite; }
.badge-completed { background: rgba(255,176,32,0.12); color: var(--amber); border-color: rgba(255,176,32,0.35); }
.badge-captain { background: rgba(255,176,32,0.15); color: var(--amber); border-color: rgba(255,176,32,0.4); }
.badge-sold { background: rgba(0,229,212,0.12); color: var(--cyan); border-color: rgba(0,229,212,0.35); }
.badge-available { background: rgba(76,201,240,0.12); color: #4cc9f0; border-color: rgba(76,201,240,0.35); }
.badge-unsold { background: rgba(255,93,122,0.12); color: var(--danger); border-color: rgba(255,93,122,0.35); }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(61,255,168,0.35); }
    50% { box-shadow: 0 0 0 8px rgba(61,255,168,0); }
}

.btn {
    appearance: none;
    border: 1px solid var(--line-strong);
    background: linear-gradient(135deg, rgba(0,229,212,0.18), rgba(0,229,212,0.05));
    color: var(--text);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.88rem;
    padding: 0.65rem 1.1rem;
    border-radius: 999px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); border-color: var(--cyan); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: linear-gradient(135deg, var(--cyan), #009e94);
    color: #042018;
    border-color: transparent;
}

.btn-amber {
    background: linear-gradient(135deg, var(--amber), #e08d00);
    color: #2a1800;
    border-color: transparent;
}

.btn-danger {
    background: linear-gradient(135deg, rgba(255,93,122,0.25), rgba(255,93,122,0.08));
    border-color: rgba(255,93,122,0.5);
    color: #ffd0d9;
}

.btn-ghost {
    background: transparent;
    border-color: var(--line);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.78rem;
}

.btn-lg {
    padding: 0.9rem 1.4rem;
    font-size: 1rem;
}

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

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

label {
    display: grid;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 0.95rem;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(4, 12, 20, 0.65);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(0,229,212,0.15);
}

.table-wrap {
    overflow-x: auto;
    border-radius: 18px;
    border: 1px solid var(--line);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

th, td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(0,229,212,0.1);
}

th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    background: rgba(0,0,0,0.2);
}

tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(0,229,212,0.04); }

.actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.alert {
    padding: 0.9rem 1.1rem;
    border-radius: 16px;
    margin-bottom: 1rem;
    border: 1px solid;
    animation: slideIn 0.35s ease;
}

.alert-success {
    background: rgba(61,255,168,0.1);
    border-color: rgba(61,255,168,0.35);
    color: var(--success);
}

.alert-error {
    background: rgba(255,93,122,0.1);
    border-color: rgba(255,93,122,0.35);
    color: #ffb3c0;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.stat-pill {
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--line);
    font-size: 0.85rem;
}

.stat-pill strong {
    color: var(--cyan);
    font-family: var(--font-display);
}

.login-panel {
    width: min(420px, 100%);
}

.photo-preview img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--cyan);
}

.player-cell {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.table-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    background: linear-gradient(145deg, rgba(0,229,212,0.35), rgba(255,176,32,0.2));
    display: grid;
    place-items: center;
    font-size: 0.7rem;
    font-family: var(--font-display);
    color: #041018;
    overflow: hidden;
    flex-shrink: 0;
}

.table-avatar.has-photo,
.player-avatar.has-photo {
    padding: 0;
    background: transparent;
}

.table-avatar img,
.player-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.team-board {
    border-radius: 22px;
    border: 1px solid color-mix(in srgb, var(--team-color) 45%, transparent);
    background:
        linear-gradient(160deg, color-mix(in srgb, var(--team-color) 18%, transparent), rgba(8,16,24,0.75));
    padding: 0.9rem;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.team-board-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.4rem;
}

.team-board-head h3 {
    font-size: 0.82rem;
    line-height: 1.3;
}

.purse {
    font-family: var(--font-display);
    color: var(--team-color);
    font-size: 0.95rem;
}

.squad-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.4rem;
    flex: 1;
}

.squad-list li {
    font-size: 0.78rem;
    padding: 0.45rem 0.55rem;
    border-radius: 12px;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.06);
    display: flex;
    justify-content: space-between;
    gap: 0.35rem;
}

.squad-list .slot-empty {
    opacity: 0.4;
    border-style: dashed;
    justify-content: center;
}

/* Live auction — single screen: player left, teams right */
.auction-floor-body {
    overflow: hidden;
    height: 100vh;
}

.auction-floor-wrap {
    width: min(1680px, calc(100% - 1.2rem));
    height: 100vh;
    padding: 0.7rem 0 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.auction-floor-topbar {
    margin-bottom: 0;
    padding: 0.55rem 1rem;
    flex-shrink: 0;
}

.auction-floor {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.auction-floor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.7rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: var(--bg-panel);
    backdrop-filter: blur(14px);
    flex-shrink: 0;
}

.auction-floor-header h1 {
    margin: 0;
    font-size: clamp(1.05rem, 2vw, 1.45rem);
}

.auction-meta {
    margin: 0.2rem 0 0;
    font-size: 0.8rem;
}

.draft-banner {
    text-align: center;
    flex-shrink: 0;
}

.live-split {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(340px, 0.95fr) minmax(520px, 1.25fr);
    gap: 0.75rem;
}

.player-stage {
    text-align: center;
    padding: 1.1rem 1rem 1.2rem;
    border-radius: var(--radius);
    border: 1px solid var(--line-strong);
    background:
        radial-gradient(circle at 50% 0%, rgba(0,229,212,0.18), transparent 55%),
        linear-gradient(180deg, rgba(14,28,42,0.95), rgba(6,14,22,0.9));
    position: relative;
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.55rem;
}

.player-stage::before,
.player-stage::after {
    content: "";
    position: absolute;
    border: 1px solid rgba(0,229,212,0.2);
    border-radius: 50%;
    pointer-events: none;
}

.player-stage::before {
    width: 260px;
    height: 260px;
    animation: orbit 12s linear infinite;
}

.player-stage::after {
    width: 360px;
    height: 360px;
    border-color: rgba(255,176,32,0.15);
    animation: orbit 18s linear infinite reverse;
}

@keyframes orbit {
    from { transform: rotate(0deg) scale(1); }
    to { transform: rotate(360deg) scale(1); }
}

.player-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid var(--cyan);
    background:
        linear-gradient(145deg, rgba(0,229,212,0.35), rgba(255,176,32,0.2));
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-size: 2rem;
    color: #041018;
    position: relative;
    z-index: 1;
    box-shadow: 0 0 40px rgba(0,229,212,0.25);
    overflow: hidden;
    flex-shrink: 0;
}

.player-name {
    font-family: var(--font-display);
    font-size: clamp(1.15rem, 2.2vw, 1.7rem);
    position: relative;
    z-index: 1;
}

.base-price {
    font-size: 0.95rem;
    color: var(--amber);
    position: relative;
    z-index: 1;
}

.player-counter {
    position: relative;
    z-index: 1;
    margin: 0;
    font-size: 0.78rem;
}

.bid-console {
    display: grid;
    gap: 0.55rem;
    position: relative;
    z-index: 1;
    width: min(440px, 100%);
}

.bid-display {
    font-family: var(--font-display);
    font-size: clamp(2rem, 4.5vw, 3rem);
    color: var(--cyan);
    letter-spacing: 0.05em;
    line-height: 1;
}

.bid-controls {
    display: flex;
    gap: 0.45rem;
    justify-content: center;
    flex-wrap: wrap;
}

.sell-label {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    text-align: center;
}

.sell-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.4rem;
}

.sell-btn {
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--team-color) 55%, transparent);
    background: color-mix(in srgb, var(--team-color) 18%, rgba(0,0,0,0.35));
    color: var(--text);
    padding: 0.55rem 0.4rem;
    font-weight: 700;
    font-size: 0.72rem;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.sell-purse {
    opacity: 0.75;
    font-weight: 500;
    margin-top: 0.15rem;
}

.sell-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.15);
}

.sell-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.teams-side {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.85rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--bg-panel);
    backdrop-filter: blur(14px);
}

.teams-side-head h2 {
    margin: 0;
    font-size: 1rem;
}

.teams-side-head .muted {
    margin: 0.2rem 0 0;
    font-size: 0.75rem;
}

.teams-side-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.55rem;
}

.team-fill {
    font-size: 0.68rem;
}

.member-line {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.member-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.squad-list li {
    font-size: 0.7rem;
    padding: 0.35rem 0.45rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.inline-form { display: inline; }

/* Custom modal popups */
body.modal-open {
    overflow: hidden;
}

.app-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.app-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.app-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 8, 14, 0.72);
    backdrop-filter: blur(8px);
}

.app-modal-card {
    position: relative;
    width: min(420px, 100%);
    padding: 1.5rem 1.35rem 1.25rem;
    border-radius: 24px;
    border: 1px solid var(--line-strong);
    background: linear-gradient(165deg, rgba(14, 30, 44, 0.98), rgba(8, 16, 26, 0.96));
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    overflow: hidden;
    transform: translateY(10px) scale(0.98);
    transition: transform 0.2s ease;
}

.app-modal.is-open .app-modal-card {
    transform: translateY(0) scale(1);
}

.app-modal-glow {
    position: absolute;
    inset: auto -30% -50% 20%;
    height: 70%;
    background: radial-gradient(circle, rgba(0, 229, 212, 0.18), transparent 65%);
    pointer-events: none;
}

.app-modal-card h2 {
    margin: 0 0 0.55rem;
    font-size: 1.05rem;
    position: relative;
}

.app-modal-message {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.5;
    position: relative;
}

.app-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.55rem;
    margin-top: 1.25rem;
    position: relative;
}

.app-modal-actions .is-hidden,
#appModalCancel[hidden] {
    display: none !important;
}

/* Fullscreen tweaks */
:fullscreen .auction-floor-wrap,
:-webkit-full-screen .auction-floor-wrap {
    width: calc(100% - 1.2rem);
    max-width: none;
}

@media (max-width: 1200px) {
    .teams-side-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .live-split { grid-template-columns: 1fr; overflow: auto; }
    .auction-floor-body { overflow: auto; height: auto; }
    .auction-floor-wrap { height: auto; }
}

@media (max-width: 1100px) {
    .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .grid-2, .grid-3, .form-row { grid-template-columns: 1fr; }
    .grid-5, .teams-side-grid { grid-template-columns: 1fr; }
    .topbar { border-radius: 24px; flex-direction: column; align-items: stretch; }
    .wrap { width: min(100% - 1.2rem, 1400px); }
}
