:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --text-color: #333;
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --team-a: #3498db;
    --team-b: #e74c3c;
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #ecf0f1;
        --text-color: #ecf0f1;
        --bg-color: #1a1a1a;
        --card-bg: #2c2c2c;
    }
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-main);
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
}

.fd-header {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
}

.fd-header h1 {
    margin: 0;
    font-size: 2.5rem;
    letter-spacing: 2px;
}

.subtitle { font-size: 1rem; opacity: 0.8; font-weight: normal; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem;
}

.card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 8px 16px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
}

.hidden { display: none !important; }

label { display: block; margin: 0.5rem 0; }
input[type="text"], input[type="number"] {
    padding: 0.5rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    width: 100%;
    max-width: 240px;
    background: var(--card-bg);
    color: var(--text-color);
}

.btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.7rem 1.4rem;
    font-size: 1rem;
    border-radius: 6px;
    cursor: pointer;
    margin: 0.5rem 0.5rem 0.5rem 0;
    transition: background-color 0.15s, transform 0.1s;
    text-decoration: none;
    display: inline-block;
}

.btn:hover:not(:disabled) { background-color: #2980b9; transform: translateY(-1px); }
.btn:disabled { background-color: #95a5a6; cursor: not-allowed; }

.btn-secondary { background-color: #7f8c8d; }
.btn-secondary:hover:not(:disabled) { background-color: #6c7a7d; }

.error { color: var(--accent-color); margin-top: 0.5rem; }

.error-box {
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    background: rgba(231, 76, 60, 0.12);
    border: 1px solid var(--accent-color);
    border-radius: 6px;
    color: var(--accent-color);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    max-height: 400px;
    overflow: auto;
}

.code-display {
    font-size: 1.3rem;
    text-align: center;
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 8px;
}
.code-display strong {
    font-size: 2.5rem;
    letter-spacing: 8px;
    color: var(--secondary-color);
    font-family: 'Courier New', monospace;
}

.player-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}
.player-chip {
    background: rgba(52, 152, 219, 0.15);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.95rem;
}

.teams-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin: 1rem 0;
}

.team-a { color: var(--team-a); }
.team-b { color: var(--team-b); }

.team-list .pending { opacity: 0.6; font-style: italic; }

.team-label {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    color: white;
    background: #888;
}
.team-label.team-a { background: var(--team-a); color: white; }
.team-label.team-b { background: var(--team-b); color: white; }

.status-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 0.8rem 1rem;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.forts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin: 1rem 0;
}

.fort-wrap h3 { margin-top: 0; }

.fort {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.6rem;
    padding: 0.8rem;
    background: rgba(0,0,0,0.04);
    border-radius: 8px;
    min-height: 90px;
}

.fort-spot {
    background: var(--card-bg);
    border: 2px solid #ccc;
    border-radius: 8px;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}
.fort-spot.team-a { border-color: var(--team-a); }
.fort-spot.team-b { border-color: var(--team-b); }

.fort-spot.destroyed {
    opacity: 0.4;
    background: repeating-linear-gradient(45deg, rgba(231,76,60,0.15), rgba(231,76,60,0.15) 5px, transparent 5px, transparent 10px);
    text-decoration: line-through;
}

.fort-spot .spot-name { font-weight: bold; margin-bottom: 0.3rem; }
.fort-spot .spot-bar {
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    margin: 0.3rem 0;
}
.fort-spot .spot-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #f39c12, #e74c3c);
    transition: width 0.3s;
}
.fort-spot .spot-dmg { font-size: 0.8rem; opacity: 0.8; }
.fort-spot .spot-sub { font-size: 0.75rem; opacity: 0.7; }

.picker-spot { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.picker-spot:hover:not(.taken):not(.destroyed) {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
.picker-spot.mine { background: rgba(46, 204, 113, 0.2); border-color: #27ae60; }
.picker-spot.taken { opacity: 0.5; cursor: not-allowed; }

.action-choices {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0;
}

.attack-wrap { flex: 1; }

.event-log {
    max-height: 200px;
    overflow-y: auto;
    background: rgba(0,0,0,0.04);
    border-radius: 6px;
    padding: 0.6rem;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
}
.event-log .event { margin: 0.2rem 0; }

.banner {
    background: var(--accent-color);
    color: white;
    padding: 0.8rem 1rem;
    border-radius: 6px;
    text-align: center;
    margin: 1rem 0;
    font-weight: bold;
}

#quiz-panel {
    text-align: center;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.12), rgba(46, 204, 113, 0.12));
    padding: 2rem 1rem;
    border-radius: 12px;
    margin: 1rem 0;
}
.question { font-size: 3rem; font-weight: bold; margin: 1rem 0; font-family: 'Courier New', monospace; }
#quiz-answer {
    font-size: 2rem;
    text-align: center;
    max-width: 180px;
    padding: 0.5rem;
}
#quiz-feedback {
    font-size: 2rem;
    min-height: 2.5rem;
    font-weight: bold;
}
#quiz-time { color: var(--accent-color); font-weight: bold; }

#winner-banner {
    font-size: 2.5rem;
    text-align: center;
    color: var(--secondary-color);
}

.fd-footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.9rem;
    opacity: 0.8;
}
.fd-footer a { color: var(--secondary-color); text-decoration: none; }
.fd-footer a:hover { text-decoration: underline; }

@media (max-width: 700px) {
    .teams-wrap, .forts { grid-template-columns: 1fr; }
    .fd-header h1 { font-size: 1.8rem; }
    .question { font-size: 2.2rem; }
    .status-bar { gap: 0.8rem; font-size: 0.85rem; }
}
