:root {
    --bg-color: #0f172a;
    --field-color: #1a2c42;
    --accent-color: #38bdf8;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --card-bg: #1e293b;
    --card-border: #334155;
    --gold: #f59e0b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 430px;
    background: linear-gradient(180deg, var(--bg-color) 0%, var(--field-color) 100%);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    height: 100vh;
}

/* Header */
.game-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    z-index: 10;
    border-bottom: 1px solid var(--card-border);
    flex-shrink: 0;
    flex-direction: column;
    /* Changed to column for title + selector layout */
    gap: 0.5rem;
}

.game-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    background: linear-gradient(to right, #fff, #a5f3fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* DB Selector */
.db-selector {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    backdrop-filter: blur(5px);
}

.db-selector label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: color 0.3s;
}

.db-selector label:hover {
    color: var(--text-primary);
}

.db-selector input[type="radio"] {
    accent-color: var(--gold);
    transform: scale(1.1);
}

.stats-board {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.stat-item .label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.stat-item .value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Field Layout (Flex Based) */
.field-container {
    flex: 1;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.formation-board {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    height: 100%;
    gap: 0.5rem;
    padding: 0 1rem;
}

.line-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

.df-line {
    gap: 0.8rem;
}

/* Chemistry Stats Board */
.chemistry-board {
    min-height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    margin-top: 0.5rem;
    width: 95%;
    align-self: center;
}

.chem-item {
    color: var(--accent-color);
}

.chem-item strong {
    color: var(--gold);
    margin-left: 4px;
}

/* Player Slot Sizing */
.player-slot {
    position: relative;
    width: 22%;
    max-width: 80px;
    aspect-ratio: 3/4;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
}

.player-slot:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

.player-slot.filled {
    border: 1px solid var(--gold);
    background: var(--card-bg);
}

.card-placeholder {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.pos-label {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 4px;
    color: var(--text-secondary);
}

/* Filled Card Content */
.slot-content {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

.slot-bg-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0.6;
    mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

.slot-info {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 4px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    text-align: center;
}

.slot-ovr {
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--gold);
    text-shadow: 1px 1px 2px black;
    z-index: 2;
}

.slot-name {
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    background: var(--card-bg);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--card-border);
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.draft-options {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* Draft Option Card (Vertical List Style) */
.draft-card {
    background: var(--bg-color);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.2s;
}

.draft-card:hover {
    border-color: var(--accent-color);
}

.draft-card:active {
    transform: scale(0.98);
}

.draft-card img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 50%;
    background: #334155;
    flex-shrink: 0;
}

.draft-card .info {
    flex: 1;
    text-align: left;
}

.draft-card .name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-primary);
}

.draft-card .meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.draft-card .ovr {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
    min-width: 40px;
    text-align: right;
}

/* Legal Footer */
.legal-footer {
    margin-top: 1rem;
    padding: 0.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.6rem;
    /* Smaller font adjusted */
    opacity: 0.5;
    line-height: 1.2;
}