:root {
    --bg: #111111;
    --card: #1a1a1a;
    --card-border: #333333;
    --los-blue: #2244aa;
    --text: #f1f5f9;
    --text-muted: #999;
    --accent: #00a651;
    --correct: #22c55e;
    --wrong: #ef4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 16px;
}

header {
    text-align: center;
    padding: 12px 0 8px;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

header h1 span { color: var(--accent); }

.tabs {
    display: flex;
    gap: 4px;
    background: var(--card);
    border-radius: 10px;
    padding: 4px;
    margin: 12px auto;
    max-width: 280px;
}

.tab {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab.active {
    background: var(--accent);
    color: white;
}

.controls {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 40px;
    margin: 12px 0;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

select {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.strength-toggle, .tag-toggle {
    display: flex;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    overflow: hidden;
}

.strength-btn, .tag-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.strength-btn.active, .tag-btn.active {
    background: var(--accent);
    color: white;
}

.formation-call {
    text-align: left;
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #e2e8f0;
    margin: 0 0 6px;
}

/* Field */
.field-container {
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--card-border);
    padding: 8px;
    margin: 8px 0;
}

.field-svg {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
    overflow: hidden;
}

.player-group {
    cursor: pointer;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.player-group:hover .player-circle {
    stroke-width: 3;
}

.player-group.selected .player-circle {
    stroke: var(--los-blue);
    stroke-width: 3;
}

.player-circle {
    transition: stroke 0.2s, stroke-width 0.2s;
}

.player-label {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-weight: 700;
    fill: #2a2a2a;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

/* Player Info Panel */
.player-info {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0;
    margin: 8px 0;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
}

.player-info.visible {
    max-height: 300px;
    opacity: 1;
    padding: 16px;
}

.info-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.info-badge {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    color: white;
    background: var(--accent);
}

.info-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.info-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.info-detail {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-muted);
    margin-top: 4px;
}

.info-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 6px;
}

.info-tag.on-line {
    background: rgba(34,197,94,0.2);
    color: #4ade80;
}

.info-tag.off-line {
    background: rgba(251,191,36,0.2);
    color: #fbbf24;
}

/* Legend */
.legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin: 6px 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-circle {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    border: 2px solid #555;
}

.legend-circle.dashed {
    border-style: dashed;
}

.section { display: none; }
.section.active { display: block; }

/* Home page */
.nav-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 24px 0;
}

.nav-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: var(--text);
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.nav-card:hover {
    border-color: var(--accent);
    background: #222;
}

.nav-card-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 12px;
    text-decoration: none;
}

.back-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

/* Quiz */
.quiz-container {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 20px;
    margin: 12px 0;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.quiz-type-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: 8px;
    padding: 3px;
}

.quiz-type-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.quiz-type-btn.active {
    background: var(--accent);
    color: white;
}

.quiz-score {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent);
}

.quiz-question {
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    margin: 16px 0;
}

.quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 16px 0;
}

.quiz-option {
    padding: 14px;
    border: 2px solid var(--card-border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.quiz-option:hover:not(.disabled) {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

.quiz-option.correct {
    border-color: var(--correct);
    background: rgba(34, 197, 94, 0.15);
    color: var(--correct);
}

.quiz-option.wrong {
    border-color: var(--wrong);
    background: rgba(239, 68, 68, 0.15);
    color: var(--wrong);
}

.quiz-option.disabled { cursor: default; opacity: 0.7; }

.quiz-feedback {
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    margin: 12px 0;
    min-height: 28px;
}

.quiz-next {
    display: none;
    margin: 16px auto 0;
    padding: 10px 32px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.quiz-next:hover { background: #008c44; }
.quiz-next.visible { display: block; }

.quiz-summary {
    text-align: center;
    padding: 24px;
}

.quiz-summary h3 {
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.quiz-summary .score-big {
    font-size: 3rem;
    font-weight: 800;
    color: var(--accent);
}

.quiz-summary .score-label {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.quiz-restart {
    padding: 10px 32px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
}

.spot-marker { cursor: pointer; }
.spot-marker:hover .spot-circle {
    fill: rgba(34,100,200,0.15);
    stroke: var(--los-blue);
}
.spot-circle {
    fill: rgba(0,0,0,0.03);
    stroke: #888;
    stroke-width: 2;
    transition: fill 0.2s, stroke 0.2s;
}
.spot-label {
    fill: #333;
    font-size: 15px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}
.spot-marker.correct .spot-circle {
    fill: rgba(34,197,94,0.2);
    stroke: var(--correct);
    stroke-width: 3;
}
.spot-marker.wrong .spot-circle {
    fill: rgba(239,68,68,0.15);
    stroke: var(--wrong);
    stroke-width: 3;
}
.spot-marker.disabled { cursor: default; pointer-events: none; }

/* Glossary */
.glossary-toggle {
    display: block;
    margin: 8px auto;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}
.glossary-toggle:hover {
    border-color: var(--accent);
    color: var(--text);
}
.glossary {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s;
    margin: 4px 0;
}
.glossary.visible {
    max-height: 500px;
    opacity: 1;
    padding: 16px;
}
.glossary dt {
    font-weight: 700;
    color: var(--accent);
    margin-top: 8px;
    font-size: 0.85rem;
}
.glossary dt:first-child { margin-top: 0; }
.glossary dd {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-left: 0;
    margin-bottom: 4px;
}

@media (max-width: 480px) {
    header h1 { font-size: 1.2rem; }
    .formation-call { font-size: 1.3rem; }
    .controls { gap: 8px; }
    .quiz-options { grid-template-columns: 1fr; }
    .container { padding: 10px; }
}

/* Auth gate — hide content until authenticated */
body { visibility: hidden; }
html.authenticated body { visibility: visible; }

#auth-overlay {
    visibility: visible;
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.auth-box {
    text-align: center;
    padding: 40px;
}

.auth-box h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.auth-box p {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.auth-box input {
    display: block;
    width: 260px;
    margin: 0 auto 12px;
    padding: 10px 14px;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    text-align: center;
}

.auth-box input:focus {
    outline: none;
    border-color: var(--accent);
}

.auth-box button {
    padding: 10px 32px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.auth-box button:hover { background: #008c44; }

#auth-error {
    color: var(--wrong);
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 10px;
    min-height: 20px;
}
