:root {
    --liberal-color: #3498db;
    --liberal-dark: #2980b9;
    --fascist-color: #e74c3c;
    --fascist-dark: #c0392b;
    --hitler-color: #2c0000;
    --hitler-border: #8b0000;
    --bg-color: #1a1a2e;
    --card-bg: #16213e;
    --card-border: #0f3460;
    --text-color: #ecf0f1;
    --text-muted: #95a5a6;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --error-color: #e74c3c;
}

.error-text {
    color: var(--error-color);
    font-size: 0.9rem;
    margin-top: 10px;
}

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

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, var(--bg-color) 0%, #0f0f1a 100%);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
}

.container {
    width: 100%;
    max-width: 480px;
}

.screen {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 30px 25px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.hidden {
    display: none !important;
}

/* Typography */
h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 0%, #ccc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-bottom: 25px;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.instruction {
    color: var(--text-muted);
    margin-bottom: 25px;
    line-height: 1.5;
}

/* Inputs */
input[type="text"], input[type="password"], select {
    width: 100%;
    padding: 16px 20px;
    font-size: 1rem;
    border: 2px solid var(--card-border);
    border-radius: 12px;
    margin-bottom: 15px;
    background: rgba(15, 52, 96, 0.5);
    color: var(--text-color);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus, input[type="password"]:focus, select:focus {
    outline: none;
    border-color: var(--liberal-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

input[type="text"]::placeholder, input[type="password"]::placeholder {
    color: var(--text-muted);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2395a5a6' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

/* Buttons */
button {
    width: 100%;
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s, box-shadow 0.2s;
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--liberal-color) 0%, var(--liberal-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
}

/* Role Buttons */
.role-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.role-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 22px;
    font-size: 1.3rem;
    font-weight: 700;
    border-radius: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.role-btn .role-icon {
    font-size: 1.8rem;
}

.role-btn.liberal {
    background: linear-gradient(135deg, var(--liberal-color) 0%, var(--liberal-dark) 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(52, 152, 219, 0.4);
}

.role-btn.fascist {
    background: linear-gradient(135deg, var(--fascist-color) 0%, var(--fascist-dark) 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(231, 76, 60, 0.4);
}

.role-btn.hitler {
    background: linear-gradient(135deg, var(--hitler-color) 0%, #1a0000 100%);
    color: white;
    border: 2px solid var(--hitler-border);
    box-shadow: 0 4px 20px rgba(139, 0, 0, 0.4);
}

.role-btn:hover {
    transform: translateY(-2px);
}

/* Player List */
#player-list-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}

#player-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.player-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.player-item.submitted {
    background: rgba(39, 174, 96, 0.3);
    border: 1px solid var(--success-color);
}

.player-item .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
}

/* Game Status */
#game-status {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}

#game-status p {
    margin: 5px 0;
}

#game-status .player-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--liberal-color);
}

/* Create Game Section */
#create-game-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 20px;
    margin-top: 15px;
}

#create-game-section label {
    display: block;
    text-align: left;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Waiting Message */
#waiting-message, #waiting-for-roles {
    margin-top: 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--liberal-color);
    border-radius: 50%;
    margin: 0 auto 15px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#role-progress {
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Reveal Screen */
#reveal-screen.liberal-reveal {
    border: 3px solid var(--liberal-color);
    box-shadow: 0 0 30px rgba(52, 152, 219, 0.3);
}

#reveal-screen.fascist-reveal {
    border: 3px solid var(--fascist-color);
    box-shadow: 0 0 30px rgba(231, 76, 60, 0.3);
}

#reveal-role-container {
    margin-bottom: 25px;
}

#reveal-role {
    font-size: 2.2rem;
    margin-bottom: 10px;
}

#reveal-team {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 8px 16px;
    border-radius: 20px;
    display: inline-block;
}

#reveal-screen.liberal-reveal #reveal-team {
    background: rgba(52, 152, 219, 0.2);
    color: var(--liberal-color);
}

#reveal-screen.fascist-reveal #reveal-team {
    background: rgba(231, 76, 60, 0.2);
    color: var(--fascist-color);
}

#reveal-info {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 25px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

#known-players-container {
    margin-bottom: 25px;
}

#known-players {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.known-player {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid rgba(231, 76, 60, 0.3);
    padding: 12px 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.known-player .player-name {
    font-weight: 600;
}

.known-player .player-role {
    color: var(--fascist-color);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 30px;
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    color: var(--warning-color);
    margin-bottom: 15px;
}

.modal-content p {
    margin-bottom: 25px;
    line-height: 1.5;
}

/* Connection Status */
.connection-status {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--warning-color);
    color: #000;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 999;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Admin Panel */
.admin-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 25px;
}

.admin-badge {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.admin-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
}

.admin-section h3 {
    margin-bottom: 12px;
    font-size: 0.85rem;
}

.admin-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.admin-section-header h3 {
    margin-bottom: 0;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.75rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: 1px solid var(--card-border);
    width: auto;
}

.btn-small:hover {
    background: rgba(255, 255, 255, 0.2);
}

.admin-game-info {
    text-align: left;
}

.admin-info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-info-row:last-child {
    border-bottom: none;
}

.admin-label {
    color: var(--text-muted);
}

.admin-value {
    font-weight: 600;
}

.admin-value.phase-waiting { color: var(--text-muted); }
.admin-value.phase-joining { color: var(--liberal-color); }
.admin-value.phase-role_input { color: var(--warning-color); }
.admin-value.phase-reveal { color: var(--success-color); }

.admin-player-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border-left: 3px solid transparent;
}

.admin-player-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kick-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1;
    border-radius: 4px;
    background: rgba(231, 76, 60, 0.2);
    color: var(--fascist-color);
    border: 1px solid rgba(231, 76, 60, 0.3);
    cursor: pointer;
    transition: background 0.2s;
}

.kick-btn:hover {
    background: rgba(231, 76, 60, 0.4);
}

.admin-player-item.submitted {
    border-left-color: var(--warning-color);
}

.admin-player-item.role-liberal {
    border-left-color: var(--liberal-color);
    background: rgba(52, 152, 219, 0.1);
}

.admin-player-item.role-fascist {
    border-left-color: var(--fascist-color);
    background: rgba(231, 76, 60, 0.1);
}

.admin-player-item.role-hitler {
    border-left-color: var(--hitler-border);
    background: rgba(139, 0, 0, 0.15);
}

.player-role-badge {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
}

.role-liberal .player-role-badge {
    background: rgba(52, 152, 219, 0.3);
    color: var(--liberal-color);
}

.role-fascist .player-role-badge {
    background: rgba(231, 76, 60, 0.3);
    color: var(--fascist-color);
}

.role-hitler .player-role-badge {
    background: rgba(139, 0, 0, 0.4);
    color: #ff6b6b;
}

.no-players {
    color: var(--text-muted);
    text-align: center;
    padding: 15px;
}

.admin-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.btn-danger {
    background: linear-gradient(135deg, var(--fascist-color) 0%, var(--fascist-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.btn-danger:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

/* Responsive */
@media (max-width: 480px) {
    body {
        padding: 10px;
        align-items: flex-start;
        padding-top: 20px;
    }

    .screen {
        padding: 25px 20px;
        border-radius: 16px;
    }

    h1 {
        font-size: 1.7rem;
    }

    .role-btn {
        padding: 18px;
        font-size: 1.1rem;
    }

    .role-btn .role-icon {
        font-size: 1.5rem;
    }
}

/* Safe area for mobile devices */
@supports (padding: max(0px)) {
    body {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }
}
