/* ── Reset & Base ─────────────────────────────────────────────────────── */

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

:root {
    --bg:       #0d1117;
    --surface:  #161b22;
    --border:   #30363d;
    --primary:  #58a6ff;
    --accent:   #f78166;
    --success:  #3fb950;
    --warning:  #d29922;
    --danger:   #f85149;
    --text:     #e6edf3;
    --text-dim: #8b949e;
    --radius:   8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Layout ───────────────────────────────────────────────────────────── */

.container {
    max-width: 800px;
    width: 100%;
    padding: 2rem 1rem;
}

.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.header .subtitle {
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* ── Setup Screen ─────────────────────────────────────────────────────── */

.setup {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
}

.setup h2 {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
}

.mode-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-buttons button {
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.15s;
}

.mode-buttons button:hover {
    border-color: var(--primary);
    background: #1c2333;
}

.mode-buttons button.selected {
    border-color: var(--primary);
    background: #1c2333;
    color: var(--primary);
}

.btn-start {
    margin-top: 1.5rem;
    padding: 0.75rem 2.5rem;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn-start:hover { opacity: 0.85; }

/* ── Game Area ────────────────────────────────────────────────────────── */

.game-area {
    display: none;
}

body.connected .game-area { display: block; }
body.connected .setup { display: none; }
body.game-over .game-area { display: block; }
body.game-over .setup { display: none; }

/* ── Status Bar ───────────────────────────────────────────────────────── */

.status-bar {
    text-align: center;
    padding: 0.75rem;
    margin-bottom: 1.5rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    font-weight: 500;
}

.status-bar.your-turn  { border-color: var(--success); color: var(--success); }
.status-bar.waiting    { border-color: var(--text-dim); color: var(--text-dim); }
.status-bar.won        { border-color: var(--warning); color: var(--warning); }
.status-bar.lost       { border-color: var(--danger); color: var(--danger); }
.status-bar.draw       { border-color: var(--text-dim); color: var(--text-dim); }

/* ── Error Toast ──────────────────────────────────────────────────────── */

.error-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger);
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 100;
}

.error-toast.visible { opacity: 1; pointer-events: auto; }

/* ── Card ─────────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

/* ── HP Bar ────────────────────────────────────────────────────────────── */

.hp-bar-outer {
    width: 100%;
    height: 12px;
    background: #21262d;
    border-radius: 6px;
    overflow: hidden;
}

.hp-bar-inner {
    height: 100%;
    border-radius: 6px;
    transition: width 0.4s ease;
    background: var(--success);
}

.hp-bar-inner.low  { background: var(--warning); }
.hp-bar-inner.crit { background: var(--danger); }

/* ── Game Over ────────────────────────────────────────────────────────── */

.game-over-actions {
    display: none;
    justify-content: center;
    margin-top: 1.5rem;
}

body.game-over .game-over-actions { display: flex; }

/* ── Multiplayer ──────────────────────────────────────────────────────── */

.room-input {
    display: none;
    margin-top: 1rem;
    gap: 0.5rem;
    flex-direction: column;
    align-items: center;
}

.room-input.visible { display: flex; }

.room-input label {
    font-size: 0.9rem;
    color: var(--text-dim);
}

.room-input input {
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    width: 10em;
}

.room-input input::placeholder {
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-dim);
    opacity: 0.6;
}

.room-input input:focus {
    outline: none;
    border-color: var(--primary);
}

.room-code-display {
    font-family: monospace;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--primary);
}

/* ── Utilities ────────────────────────────────────────────────────────── */

.text-dim    { color: var(--text-dim); }
.text-center { text-align: center; }
.mt-1        { margin-top: 0.5rem; }
.mt-2        { margin-top: 1rem; }
.mb-1        { margin-bottom: 0.5rem; }
.gap-1       { gap: 0.5rem; }
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.hidden      { display: none !important; }
