:root {
    --bg: #0e1116;
    --panel: #161b22;
    --panel-2: #1f2630;
    --border: #2d3441;
    --text: #e6edf3;
    --text-dim: #8b949e;
    --accent: #58a6ff;
    --accent-hot: #f0883e;
    --hero-yellow: #fbc02d;
    --hero-purple: #9d6cc1;
    --hero-green: #3fb950;
    --hero-orange: #db8b32;
    --green: #3fb950;
    --red: #f85149;
    --blue: #58a6ff;
    --yellow: #d29922;
    --shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    --radius: 8px;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin-top: 0; }

.site-header {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: baseline;
    gap: 1rem;
}
.site-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}
.subtitle { color: var(--text-dim); font-size: 0.9rem; }

.site-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

.home {
    max-width: 600px;
    margin: 0 auto;
}
.home h1 { font-size: 2rem; }
.lead { color: var(--text-dim); }

.home-form {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin: 1.5rem 0;
}
.home-form label { display: block; margin-bottom: 1rem; }
.home-form label span { display: block; color: var(--text-dim); margin-bottom: 0.25rem; }
.home-form input {
    width: 100%;
    padding: 0.55rem 0.7rem;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    font-size: 1rem;
}
.home-actions {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
    flex-wrap: wrap;
}
.join-group {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    min-width: 250px;
}
.join-group input { flex: 1; letter-spacing: 0.15em; font-weight: 600; }

button.primary, button.secondary, a.primary, a.secondary {
    padding: 0.55rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    cursor: pointer;
    font-size: 0.95rem;
    text-decoration: none;
    display: inline-block;
}
button.primary, a.primary {
    background: var(--accent);
    color: #0a1422;
    border-color: var(--accent);
    font-weight: 600;
}
button.primary:hover, a.primary:hover { filter: brightness(1.05); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.error { color: var(--red); }
.status { color: var(--text-dim); font-style: italic; }

.rules-summary {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
.rules-summary ul { margin: 0 0 1rem 0; padding-left: 1.2rem; }
.rules-summary li { margin-bottom: 0.4rem; }
.rules-summary h2 { font-size: 1.05rem; margin-top: 1rem; }
.rules-summary kbd {
    background: var(--panel-2);
    border: 1px solid var(--border);
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
    font-family: ui-monospace, monospace;
    font-size: 0.78rem;
    margin-right: 0.15rem;
}

.legend {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}
.legend-item {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 0.6rem;
    align-items: start;
    background: var(--panel-2);
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
    font-size: 0.88rem;
}
.legend-icon {
    font-size: 1.5rem;
    line-height: 1;
    text-align: center;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
}
.legend-svg {
    width: 30px;
    height: 30px;
    display: block;
}
.legend-item strong { color: var(--text); }
@media (min-width: 700px) {
    .legend { grid-template-columns: 1fr 1fr; }
}

/* Lobby */
.lobby h1 { font-size: 1.7rem; }
.lobby .code { font-family: ui-monospace, "SF Mono", monospace; letter-spacing: 0.2em; color: var(--accent-hot); }
.lobby .hint { color: var(--text-dim); }
.lobby-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin: 1.5rem 0;
}
.lobby-grid > section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
.player-list { list-style: none; padding: 0; margin: 0; }
.player-list li {
    padding: 0.4rem 0.6rem;
    background: var(--panel-2);
    border-radius: 4px;
    margin-bottom: 0.4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.player-list .badge {
    font-size: 0.75rem;
    background: var(--accent-hot);
    color: #0a1422;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-weight: 600;
}
.player-list .offline { opacity: 0.5; font-style: italic; }
.scenario-picker select {
    width: 100%;
    padding: 0.5rem;
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
}
.scenario-desc { color: var(--text-dim); margin-top: 0.5rem; font-size: 0.9rem; min-height: 3em; }

.lobby-actions { display: flex; gap: 0.75rem; }

@media (max-width: 700px) {
    .lobby-grid { grid-template-columns: 1fr; }
    .home-actions { flex-direction: column; }
    .join-group { min-width: 0; }
}
