/* ==================== Reset & Basis ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --success-hover: #059669;
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --danger: #ef4444;
    --secondary: #6b7280;
    --secondary-hover: #4b5563;
    
    --bg: #f3f4f6;
    --bg-card: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* ==================== Container & Layout ==================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

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

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}

.footer-link {
    margin-top: 0.5rem;
}

.footer-link a {
    color: var(--primary);
    text-decoration: none;
}

.footer-link a:hover {
    text-decoration: underline;
}

/* ==================== Cards ==================== */
.card-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}

.single-card-container {
    display: flex;
    justify-content: center;
}

.single-card-container .card {
    max-width: 450px;
    width: 100%;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.card > p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* ==================== Forms ==================== */
.form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="file"] {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group small {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.demo-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.demo-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.demo-option:hover {
    border-color: var(--primary);
}

.demo-option input[type="radio"] {
    accent-color: var(--primary);
}

.demo-option input[type="radio"]:checked + .demo-label {
    font-weight: 600;
    color: var(--primary);
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: var(--success-hover);
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: var(--warning-hover);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.2rem;
}

/* ==================== Result & Error ==================== */
.result {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #ecfdf5;
    border-radius: 8px;
    text-align: center;
}

.game-code {
    font-size: 2.5rem;
    font-weight: bold;
    font-family: monospace;
    color: var(--primary);
    letter-spacing: 0.2em;
    margin: 1rem 0;
}

.error {
    margin-top: 1rem;
    padding: 1rem;
    background: #fef2f2;
    border-radius: 8px;
    color: var(--danger);
}

.hidden {
    display: none !important;
}

/* ==================== Game Header ==================== */
.game-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-card);
    box-shadow: var(--shadow);
}

.game-info h1 {
    font-size: 1.5rem;
}

.game-code-display {
    color: var(--text-muted);
    font-family: monospace;
}

.host-badge {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #78350f;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.5rem;
    display: inline-block;
}

.game-controls {
    display: flex;
    gap: 1rem;
}

/* ==================== Lobby ==================== */
.lobby {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.lobby-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
}

.lobby-card h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.player-list {
    list-style: none;
    margin: 1rem 0;
}

.player-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.player-list li.current-player {
    background: #ede9fe;
    border: 2px solid var(--primary);
}

.player-list li.disconnected {
    opacity: 0.5;
}

.player-list li.empty {
    justify-content: center;
    color: var(--text-muted);
    font-style: italic;
}

.player-name {
    font-weight: 500;
}

.player-score {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.you-badge {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.lobby-hint {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #fef3c7;
    border-radius: 8px;
    text-align: center;
}

/* ==================== Game Area ==================== */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem 2rem;
}

.game-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 8px;
}

.turn-indicator {
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: var(--bg);
}

.turn-indicator.your-turn {
    background: #dcfce7;
    color: #166534;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.scoreboard {
    display: flex;
    gap: 1rem;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg);
    border-radius: 8px;
}

.score-item.current {
    background: #ede9fe;
}

.score-item .name {
    font-weight: 500;
}

.score-item .score {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-weight: bold;
}

.game-board {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ==================== Modal ==================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.modal-content #winner-announcement {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.modal-content #final-scores {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
}

.modal-content #final-scores h3 {
    margin-bottom: 0.5rem;
}

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

/* ==================== Error Page ==================== */
.error-page {
    text-align: center;
    padding: 4rem 2rem;
}

.error-page h1 {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.error-message {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .card-container {
        grid-template-columns: 1fr;
    }
    
    .game-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .game-status {
        flex-direction: column;
        gap: 1rem;
    }
    
    .scoreboard {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ==================== Slider (v1.0) ==================== */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

input[type="range"]:hover::-webkit-slider-thumb {
    background: var(--primary-hover);
}

input[type="range"]:hover::-moz-range-thumb {
    background: var(--primary-hover);
}

input[type="number"] {
    padding: 0.5rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

/* ==================== Details/Summary (v1.1) ==================== */
details summary {
    user-select: none;
}

details[open] summary {
    margin-bottom: 1rem;
}

details summary:hover {
    background: var(--primary);
    color: white;
}

details summary::marker {
    display: none;
}

details[open] summary::before {
    content: '▼ ';
}

details:not([open]) summary::before {
    content: '▶️ ';
}

