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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 1rem;
}

/* ---------- Screens ---------- */
.screen { display: none; max-width: 600px; width: 100%; flex-direction: column; gap: 1rem; }
.screen.active { display: flex; }

/* ---------- Lobby ---------- */
#screen-lobby h1 { font-size: 2rem; text-align: center; }
.subtitle { text-align: center; color: #888; margin-bottom: 0.5rem; }

.lobby-actions { display: flex; flex-direction: column; gap: 1.5rem; }
.lobby-section { background: #16213e; border-radius: 8px; padding: 1.5rem; }
.lobby-section h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.lobby-section label { display: block; margin-bottom: 0.75rem; font-size: 0.9rem; color: #aaa; }
.lobby-section input,
.lobby-section select {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.5rem;
    background: #0f3460;
    border: 1px solid #333;
    color: #fff;
    border-radius: 4px;
    font-size: 1rem;
}
.lobby-section select option { background: #0f3460; color: #fff; }
.lobby-divider { text-align: center; color: #555; font-size: 0.9rem; }

/* ---------- Buttons ---------- */
button {
    padding: 0.6rem 1.2rem;
    background: #e94560;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}
button:hover { background: #c73850; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Waiting ---------- */
#screen-waiting { align-items: center; }
#screen-waiting h2 { font-size: 1.2rem; }
#player-list { list-style: none; }
#player-list li { padding: 0.25rem 0; color: #aaa; }
.dim { color: #666; font-size: 0.9rem; }

/* ---------- Game ---------- */
#screen-game { height: 100vh; max-height: 100vh; gap: 0; }

#game-header {
    background: #16213e;
    padding: 0.75rem 1rem;
    border-radius: 8px 8px 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex-shrink: 0;
}
#header-top { display: flex; gap: 0.75rem; align-items: center; }
#role-badge {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-weight: bold;
}
#role-badge.mafia { background: #e94560; color: white; }
#role-badge.townfolk { background: #0f3460; color: white; }
#phase-indicator { font-size: 0.9rem; color: #53a8b6; }
#stats-bar { font-size: 0.8rem; color: #888; }

#timer-bar {
    height: 4px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
}
#timer-fill {
    height: 100%;
    background: #e94560;
    width: 100%;
    transition: width 0.25s linear;
}

/* ---------- Game log ---------- */
#game-log {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: #111;
}

.log-entry { padding: 0.4rem 0.6rem; border-radius: 4px; font-size: 0.9rem; }
.log-phase { background: #16213e; text-align: center; font-weight: bold; padding: 0.6rem; color: #53a8b6; }
.log-statement { border-left: 3px solid #0f3460; padding-left: 0.6rem; }
.log-statement .speaker { color: #53a8b6; font-weight: bold; }
.log-statement.is-teammate .speaker { color: #e94560; }
.log-death { background: #2d1b2e; color: #e94560; font-weight: bold; }
.log-vote { color: #777; font-size: 0.85rem; }
.log-system { color: #666; font-style: italic; }

/* ---------- Turn banner ---------- */
#turn-banner {
    background: #e94560;
    color: white;
    text-align: center;
    padding: 0.6rem;
    font-weight: bold;
    font-size: 1rem;
    letter-spacing: 0.05em;
    animation: pulse-banner 1.2s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes pulse-banner {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ---------- Game input ---------- */
#game-input {
    background: #16213e;
    padding: 0.75rem;
    border-radius: 0 0 8px 8px;
    flex-shrink: 0;
}
#statement-wrapper { position: relative; }
#statement-text {
    width: 100%;
    padding: 0.5rem;
    background: #0f3460;
    border: 1px solid #333;
    color: #fff;
    border-radius: 4px;
    font-size: 0.95rem;
    resize: none;
    font-family: inherit;
}
.input-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 0.4rem; }
#char-count { font-size: 0.8rem; color: #666; }

/* ---------- @mention dropdown ---------- */
#mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 4px;
    margin-bottom: 4px;
    max-height: 180px;
    overflow-y: auto;
    z-index: 10;
}
.mention-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: #e0e0e0;
}
.mention-item:hover, .mention-item.active {
    background: #0f3460;
    color: #53a8b6;
}

/* ---------- @mention highlight in messages ---------- */
.mention { color: #53a8b6; font-weight: bold; }

/* ---------- Clickable player names in log ---------- */
.log-statement .speaker { color: #53a8b6; font-weight: bold; cursor: pointer; }
.log-statement .speaker:hover { text-decoration: underline; }

#vote-prompt { font-size: 0.9rem; color: #aaa; margin-bottom: 0.5rem; }
#vote-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
#vote-buttons button { background: #0f3460; font-size: 0.9rem; }
#vote-buttons button:hover { background: #1a4a8a; }

/* ---------- Game over ---------- */
#screen-gameover { align-items: center; justify-content: center; min-height: 60vh; }
#gameover-title { font-size: 2rem; }
#gameover-subtitle { color: #aaa; margin-bottom: 1rem; }

#game-summary {
    width: 100%;
    max-width: 400px;
    text-align: left;
    margin-bottom: 1rem;
}
#game-summary h3 {
    font-size: 1rem;
    color: #53a8b6;
    margin-bottom: 0.5rem;
}
.summary-entry {
    padding: 0.3rem 0;
    font-size: 0.85rem;
    color: #aaa;
    border-bottom: 1px solid #222;
}
.summary-entry .summary-death { color: #e94560; }
.summary-entry .summary-role { color: #666; }
.summary-roles {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
}
.summary-roles h3 { margin-bottom: 0.4rem; }
.role-reveal {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    margin: 0.15rem;
    border-radius: 3px;
    font-size: 0.8rem;
}
.role-reveal.mafia { background: #e94560; color: white; }
.role-reveal.townfolk { background: #0f3460; color: white; }

/* ---------- Error ---------- */
.error { color: #e94560; font-size: 0.9rem; }

/* ---------- Version stamp ---------- */
#version-stamp {
    position: fixed;
    bottom: 4px;
    right: 6px;
    font-size: 0.65rem;
    color: #444;
    pointer-events: none;
    z-index: 100;
}

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
    body { padding: 0.5rem; }
    .lobby-section { padding: 1rem; }
    #game-log { padding: 0.5rem; }
}
