/* ==================== Variables ==================== */
:root {
    --primary: #d4af37;
    --primary-dark: #b8960c;
    --primary-light: #e8d179;
    --secondary: #6b7280;
    --accent: #c41e3a;
    --accent-light: #dc3545;
    --danger: #c41e3a;
    --danger-light: #dc3545;
    --success: #22c55e;
    --success-light: #4ade80;
    --warning: #d97706;
    
    --bg-gradient: linear-gradient(135deg, #0d3328 0%, #0a281f 100%);
    --bg-dark: #0d1f1a;
    --bg-medium: #1a2f28;
    --bg-light: #243c32;
    --bg-card: #1e332b;
    --bg-card-hover: #263d34;
    
    --text-primary: #f5f5dc;
    --text-secondary: #c9c9b8;
    --text-muted: #a5a595;
    
    --border-color: #3d5a4f;
    --border-radius: 8px;
    --border-radius-sm: 6px;
    --border-radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);
    --transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    
    --glass: rgba(30, 51, 43, 0.95);
    --glass-border: rgba(212, 175, 55, 0.2);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

#app {
    min-height: 100vh;
    background: var(--bg-gradient);
}

/* ==================== Screens ==================== */
.screen {
    display: none;
    min-height: 100vh;
    padding: 24px;
}

.screen.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== Buttons ==================== */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
}

.btn-primary:hover {
    box-shadow: 0 6px 25px rgba(212, 175, 55, 0.5);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary-light);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white;
}

.btn-small {
    padding: 10px 18px;
    font-size: 13px;
    border-radius: var(--border-radius-sm);
}

.btn-large {
    padding: 18px 40px;
    font-size: 18px;
}

.btn-forbidden {
    background: var(--danger);
    opacity: 0.4;
    cursor: not-allowed;
    text-decoration: line-through;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.card:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

/* ==================== Inputs ==================== */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 15px;
    transition: var(--transition);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

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

/* ======================== HOME SCREEN ======================== */
.home-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 40px;
    gap: 60px;
    max-width: 1100px;
    margin: 0 auto;
}

.home-brand {
    flex: 1;
    max-width: 480px;
    text-align: left;
}

.home-logo {
    display: block;
    width: 140px;
    height: auto;
    margin-bottom: 20px;
}

.home-title {
    font-size: 3.5rem;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 36px;
    font-size: 1.15rem;
    font-style: italic;
}

.home-features {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 32px;
}

.home-feature {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.home-feature:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.home-feature-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
}

.home-feature strong {
    display: block;
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.home-feature p {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin: 0;
}

.home-rules-btn {
    width: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.home-panel {
    flex: 0 0 400px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.button-row {
    display: flex;
    gap: 10px;
}

.button-row .btn {
    flex: 1;
}

.btn-lg {
    padding: 16px 24px;
    font-size: 1.1rem;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.btn-ghost:hover {
    color: var(--text-primary);
}

/* Mobile: single column */
@media (max-width: 768px) {
    .home-hero {
        flex-direction: column;
        padding: 24px 20px;
        gap: 32px;
        min-height: auto;
    }
    
    .home-brand {
        text-align: center;
        max-width: 100%;
    }
    
    .home-logo {
        margin: 0 auto 16px;
        width: 180px;
    }
    
    .home-title {
        font-size: 2.5rem;
    }
    
    .home-features {
        gap: 10px;
        margin-bottom: 24px;
    }
    
    .home-feature {
        padding: 10px 14px;
    }
    
    .home-panel {
        flex: none;
        width: 100%;
        max-width: 400px;
        padding: 24px;
        border-radius: 12px;
    }
    
    .home-rules-btn {
        width: 100%;
        justify-content: center;
    }

    .button-row {
        flex-direction: column;
    }
}

/* ==================== Rules Screen ==================== */
.rules-container {
    max-width: 680px;
    margin: 0 auto;
    padding: 32px 20px;
}

.rules-container h2 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.8rem;
    color: var(--primary);
}

.rules-content {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--border-radius);
    margin: 20px 0;
    line-height: 1.7;
    border: 1px solid var(--border-color);
}

.rules-content h3 {
    color: var(--primary);
    margin: 24px 0 10px;
    font-size: 1rem;
}

.rules-content h3:first-child {
    margin-top: 0;
}

.rules-content ul {
    margin-left: 20px;
}

.rules-content li {
    margin: 8px 0;
    color: var(--text-secondary);
}

.rules-content p {
    color: var(--text-secondary);
}

/* ==================== Lobby Screen ==================== */
.lobby-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.lobby-header h2 {
    font-size: 1.8rem;
}

.player-badge {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.lobby-actions {
    display: flex;
    gap: 14px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    flex: 1;
    min-width: 220px;
}

.search-box input {
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    border-right: none;
}

.search-box .btn {
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

/* Rooms List */
.rooms-list {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    min-height: 320px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.empty-message {
    color: var(--text-muted);
    text-align: center;
    padding: 60px 20px;
    font-size: 1.1rem;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    background: var(--bg-medium);
    border-radius: var(--border-radius);
    margin-bottom: 12px;
    transition: var(--transition);
    border: 1px solid transparent;
}

.room-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary-light);
    transform: translateX(4px);
}

.room-info h4 {
    margin-bottom: 6px;
    font-size: 1.1rem;
}

.room-info span {
    color: var(--text-secondary);
    font-size: 14px;
}

.room-meta {
    display: flex;
    align-items: center;
    gap: 18px;
}

.status-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.status-waiting {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent);
    border: 1px solid var(--accent);
}

.status-playing {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.status-finished {
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-muted);
    border: 1px solid var(--text-muted);
}

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

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    padding: 28px;
    border-radius: var(--border-radius);
    max-width: 400px;
    width: 90%;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 20px;
    font-size: 1.2rem;
    color: var(--primary);
}

.modal-content .button-group {
    flex-direction: row;
    justify-content: flex-end;
    gap: 10px;
}

/* Checkbox label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.hint-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Private rooms */
.room-item.private {
    border: 1px solid var(--primary);
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(212, 175, 55, 0.05) 100%);
}

.room-code-display {
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid var(--primary);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    margin-top: 12px;
    text-align: center;
}

.invite-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.room-code-display span {
    font-size: 14px;
    color: var(--text-primary);
}

.room-code-display strong {
    color: var(--primary);
    font-size: 18px;
    letter-spacing: 2px;
}

/* Banner */
.banner {
    background: var(--accent);
    color: white;
    padding: 12px 20px;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-weight: 500;
    font-size: 14px;
}

.banner-actions {
    display: flex;
    gap: 8px;
}

.banner.hidden {
    display: none;
}

/* ==================== Waiting Room ==================== */
.waiting-container {
    max-width: 860px;
    margin: 0 auto;
    padding: 20px;
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.room-header h2 {
    font-size: 1.6rem;
    color: var(--primary);
}

.players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.player-card {
    background: var(--bg-card);
    padding: 18px;
    border-radius: var(--border-radius);
    text-align: center;
    position: relative;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.player-card:hover {
    border-color: var(--primary);
}

.player-card.admin {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(212, 175, 55, 0.1) 100%);
}

.player-card.admin::before {
    content: '👑';
    position: absolute;
    top: -10px;
    right: -6px;
    font-size: 22px;
}

.player-card.offline {
    opacity: 0.5;
}

.player-card.away {
    opacity: 0.7;
}

.player-card.away .player-name {
    color: var(--warning);
}

.player-card .player-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.player-card .player-status {
    color: var(--text-secondary);
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.online-dot.online {
    background: var(--success);
    box-shadow: 0 0 4px var(--success);
}

.online-dot.offline {
    background: var(--danger);
    box-shadow: 0 0 4px var(--danger);
}

.online-dot.away {
    background: var(--warning);
    box-shadow: 0 0 4px var(--warning);
    animation: pulse 2s infinite;
}

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

.admin-controls {
    text-align: center;
    margin-bottom: 28px;
}

.admin-controls .hint {
    color: var(--text-muted);
    margin-top: 10px;
    font-size: 13px;
}

.admin-controls .btn {
    margin: 0 6px;
}

.waiting-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 28px;
}

.kick-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--danger);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kick-btn:hover {
    transform: scale(1.1);
    background: #a01830;
}

/* Waiting Chat */
.waiting-chat {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 14px;
    max-height: 280px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

/* ==================== Game Screen ==================== */
#game-screen {
    padding: 0; /* Rimuove il padding per occupare tutto lo schermo */
}

.game-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 6px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.game-footer-buttons {
    display: flex;
    gap: 6px;
}

.game-footer .footer-text {
    font-size: 11px;
    color: var(--text-muted);
}

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

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

.game-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-dark);
}

/* Game Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.turn-info {
    display: flex;
    gap: 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.turn-info span {
    color: var(--text-primary);
}

.phase-indicator {
    background: var(--bg-light);
    padding: 6px 14px;
    border-radius: 16px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.phase-betting {
    background: rgba(217, 119, 6, 0.15);
    border-color: var(--warning);
    color: var(--warning);
}

.phase-playing {
    background: rgba(212, 175, 55, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

.phase-results {
    background: rgba(34, 197, 94, 0.15);
    border-color: var(--success);
    color: var(--success);
}

/* Game Main Area */
.game-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Hand Panel */
.hand-panel {
    width: 280px;
    padding: 16px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.hand-panel h3 {
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.hand-area {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.hand-area .card {
    width: 65px;
    height: auto;
    aspect-ratio: 173 / 276;
    border-radius: 6px;
    cursor: pointer;
    object-fit: contain;
    background-color: #0f1110;
    display: block;
    /* GPU acceleration: animate only transform/opacity/border-color */
    transition: transform 0.2s ease, opacity 0.2s ease, border-color 0.15s ease;
    box-shadow: var(--shadow);
    background-size: cover;
    background-position: center;
    border: 1px solid transparent;
    position: relative;
}

.hand-area .card:hover {
    transform: translateY(-6px);
    border-color: var(--primary);
    z-index: 10;
    /* Nessuna animazione box-shadow per fluidità */
}

.hand-area .card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
    transform: translateY(-8px);
}

.hand-area .card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(60%);
}

.card {
    width: 60px;
    height: 90px;
    border-radius: 6px;
    cursor: pointer;
    /* GPU acceleration: animate only transform/opacity/border-color */
    transition: transform 0.2s ease, opacity 0.2s ease, border-color 0.15s ease;
    box-shadow: var(--shadow);
    background-size: cover;
    background-position: center;
    border: 1px solid transparent;
    position: relative;
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    /* box-shadow rimane statico per performance */
}

.card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}

.card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(60%);
}

.card-back {
    background: linear-gradient(135deg, #3d5a4f 0%, #2d4037 100%);
    border: 1px solid var(--border-color);
}

.special-note {
    background: rgba(217, 119, 6, 0.15);
    border: 1px solid var(--warning);
    color: var(--warning);
    padding: 12px;
    border-radius: var(--border-radius);
    margin-top: 14px;
    font-size: 12px;
    font-weight: 500;
}

.others-cards {
    margin-top: 14px;
}

.others-cards h4 {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-confirm {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    padding: 24px 32px;
    border-radius: var(--border-radius);
    border: 1px solid var(--primary);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    text-align: center;
    will-change: transform, opacity;
    transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}

.card-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 199;
}

.card-confirm p {
    margin-bottom: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-confirm .button-group {
    flex-direction: row;
    gap: 10px;
}

/* Table Area */
.table-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    min-height: 350px;
    --table-width: min(600px, 100%);
    --table-height: calc(var(--table-width) * 0.733333);
}

.table-center {
    position: relative;
    width: var(--table-width);
    height: var(--table-height);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #1a4d3a 0%, #0d3328 100%);
    border-radius: 50%;
    box-shadow: 
        inset 0 4px 30px rgba(0, 0, 0, 0.5),
        0 8px 30px rgba(0, 0, 0, 0.4),
        0 0 0 8px rgba(60, 40, 20, 0.8),
        0 0 0 12px rgba(80, 55, 30, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.table-center::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 88%;
    height: 82%;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 44% / 41%;
    pointer-events: none;
}

.played-cards {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 2;
    pointer-events: none;
}

.played-card-position {
    position: absolute;
    width: calc(var(--table-width) * 0.12);
    aspect-ratio: 173 / 276;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    transition: none;
    overflow: hidden;
}

.played-card-position .card {
    animation: cardPlay 0.3s ease-out;
}

.played-card-position:hover {
    transform: none;
    z-index: 10;
}

/* Card positions around the table - always upright, positioned in front of each player */
/* Cards are positioned relative to .table-center (600x440) */
/* Position 0: bottom - in front of player at bottom */
.played-card-position.pos-0 { 
    bottom: calc(var(--table-height) * -0.1181818); 
    left: 50%; 
    transform: translateX(-50%);
}
/* Position 1: bottom left - in front of player at bottom left */
.played-card-position.pos-1 { 
    bottom: calc(var(--table-height) * 0.1636364); 
    left: calc(var(--table-width) * 0.04); 
    transform: translateX(-50%);
}
/* Position 2: left - in front of player at left */
.played-card-position.pos-2 { 
    top: 50%; 
    left: calc(var(--table-width) * -0.0533333); 
    transform: translateY(-50%);
}
/* Position 3: top left - in front of player at top left */
.played-card-position.pos-3 { 
    top: calc(var(--table-height) * -0.0227273); 
    left: 22%; 
    transform: translateX(-50%);
}
/* Position 4: top right - in front of player at top right */
.played-card-position.pos-4 { 
    top: calc(var(--table-height) * -0.0227273); 
    right: 22%; 
    transform: translateX(50%);
}
/* Position 5: right - in front of player at right */
.played-card-position.pos-5 { 
    top: 50%; 
    right: calc(var(--table-width) * -0.0533333); 
    transform: translateY(-50%);
}
/* Position 6: bottom right - in front of player at bottom right */
.played-card-position.pos-6 { 
    bottom: calc(var(--table-height) * 0.1636364); 
    right: calc(var(--table-width) * 0.04); 
    transform: translateX(50%);
}
/* Position 7: top center - in front of player at top */
.played-card-position.pos-7 { 
    top: calc(var(--table-height) * -0.1181818); 
    left: 50%; 
    transform: translateX(-50%);
}

@keyframes cardPlay {
    from { 
        transform: scale(0.9) translateY(-18px); 
        opacity: 0; 
    }
    to { 
        transform: scale(1) translateY(0); 
        opacity: 1; 
    }
}

/* Trick info now in header */
.trick-info-header {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

/* Table Positions - same size as table and centered */
.table-positions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: var(--table-width);
    height: var(--table-height);
    pointer-events: none;
}

.table-position {
    position: absolute;
    width: clamp(80px, calc(var(--table-width) * 0.2), 140px);
    text-align: center;
    pointer-events: auto;
}

/* Player positions - positioned relative to the table (600x440) */
.table-position.pos-0 { top: 108%; left: 50%; transform: translate(-50%, -50%); }  /* Bottom center - ME */
.table-position.pos-1 { top: 90%; left: 4%; transform: translate(-50%, -50%); }    /* Bottom left */
.table-position.pos-2 { top: 50%; left: -10%; transform: translate(-50%, -50%); }  /* Left */
.table-position.pos-3 { top: 2%; left: 16%; transform: translate(-50%, -50%); }    /* Top left */
.table-position.pos-4 { top: 2%; left: 84%; transform: translate(-50%, -50%); }    /* Top right */
.table-position.pos-5 { top: 50%; left: 110%; transform: translate(-50%, -50%); }  /* Right */
.table-position.pos-6 { top: 90%; left: 96%; transform: translate(-50%, -50%); }   /* Bottom right */
.table-position.pos-7 { top: -10%; left: 50%; transform: translate(-50%, -50%); }  /* Top center */

.table-position .player-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.turn-timer {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(212, 175, 55, 0.5);
}

.table-position.current-turn .player-name {
    background: rgba(212, 175, 55, 0.2);
    border: 2px solid var(--primary);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.35);
}

.table-position.offline .player-name {
    opacity: 0.5;
}

.table-position.is-bot .player-name {
    background: rgba(147, 51, 234, 0.2);
    border: 2px dashed rgba(147, 51, 234, 0.6);
    opacity: 0.75;
}

.player-info-card.is-bot {
    opacity: 0.75;
    border-left: 3px solid rgba(147, 51, 234, 0.6);
}

.table-position.spectator .player-name {
    background: rgba(100, 116, 139, 0.3);
    border-color: var(--text-muted);
    color: var(--text-muted);
    font-style: italic;
}

.table-position .player-bet {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    background: rgba(0, 0, 0, 0.4);
    padding: 5px 8px;
    border-radius: 4px;
    display: inline-block;
}

.table-position .lives-line {
    display: block;
    margin-top: 4px;
    font-weight: 600;
    color: var(--text-primary);
}

.table-position .player-bet strong {
    color: var(--primary);
    font-weight: 700;
}

/* Table player status colors based on bet vs tricks */
.table-position.status-pending .player-name {
    background: rgba(217, 119, 6, 0.25);
    border-color: var(--warning);
}

.table-position.status-achieved .player-name {
    background: rgba(34, 197, 94, 0.25);
    border-color: var(--success);
}

.table-position.status-exceeded .player-name {
    background: rgba(196, 30, 58, 0.25);
    border-color: var(--danger);
}

.table-position.status-pending .player-bet {
    background: rgba(217, 119, 6, 0.15);
    border: 1px solid var(--warning);
}

.table-position.status-achieved .player-bet {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid var(--success);
}

.table-position.status-exceeded .player-bet {
    background: rgba(196, 30, 58, 0.15);
    border: 1px solid var(--danger);
}

/* Players Panel removed */

.player-info-card {
    background: var(--bg-medium);
    padding: 10px 12px;
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.player-info-card:hover {
    background: var(--bg-card-hover);
}

.player-info-card.current {
    border: 2px solid var(--primary);
    background: rgba(212, 175, 55, 0.15);
}

.player-info-card.me {
    border-color: var(--primary);
}

/* Player status colors based on bet vs tricks - full background fill */
/* Orange: still needs to win tricks */
.player-info-card.status-pending {
    background: rgba(217, 119, 6, 0.25);
    border-color: var(--warning);
}

/* Green: achieved bet */
.player-info-card.status-achieved {
    background: rgba(34, 197, 94, 0.25);
    border-color: var(--success);
}

/* Red: exceeded bet */
.player-info-card.status-exceeded {
    background: rgba(196, 30, 58, 0.25);
    border-color: var(--danger);
}

.player-info-card .name-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-weight: 500;
}

.player-info-card .stats-row {
    display: flex;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 11px;
}

.lives-display {
    color: var(--danger);
    font-weight: 600;
}

/* Betting Area (now in left panel) */
.betting-area {
    padding: 16px;
    background: var(--bg-medium);
    text-align: center;
    border-radius: var(--border-radius);
    margin-top: 16px;
    border: 1px solid var(--primary);
}

.betting-area h4 {
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.betting-area h3 {
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bet-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.bet-btn {
    width: 44px;
    height: 44px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 50%;
    padding: 0;
}

.forbidden-note {
    color: var(--danger);
    margin-top: 10px;
    font-size: 12px;
    font-weight: 500;
}

/* Bets Summary in left panel */
.bets-summary {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-medium);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.bets-summary h4 {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.bets-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bet-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 4px 8px;
    background: var(--bg-card);
    border-radius: 4px;
}

.bet-item .bet-name {
    color: var(--text-primary);
}

.bet-item .bet-value {
    color: var(--primary);
    font-weight: 600;
}

.bet-item.betting .bet-value {
    color: var(--text-muted);
    font-style: italic;
}

/* Table Bets Overlay */
.table-bets-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(13, 31, 26, 0.95);
    padding: 24px 32px;
    border-radius: var(--border-radius-lg);
    border: 2px solid var(--primary);
    text-align: center;
    z-index: 20;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    min-width: 280px;
    will-change: transform, opacity;
    transition: none;
}

.table-bets-overlay h3 {
    color: var(--primary);
    margin-bottom: 16px;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.table-bets-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.table-bet-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    font-size: 14px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
}

.table-bet-item.current {
    border-color: var(--primary);
    background: rgba(212, 175, 55, 0.15);
    animation: none;
}

.table-bet-item .tb-name {
    color: var(--text-primary);
    font-weight: 500;
}

.table-bet-item .tb-value {
    color: var(--primary);
    font-weight: 700;
    font-size: 18px;
}

.table-bet-item .tb-status {
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
}

/* Jolly Choice */
.jolly-choice {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    padding: 28px;
    border-radius: var(--border-radius);
    text-align: center;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--primary);
    will-change: transform, opacity;
    transition: transform 0.25s ease-out, opacity 0.2s ease-out;
}

.jolly-logo {
    display: block;
    width: 140px;
    max-width: 60vw;
    height: auto;
    margin: 0 auto 8px;
}

.jolly-choice .jolly-subtitle {
    color: var(--text-muted);
    margin-bottom: 12px;
    font-size: 13px;
    letter-spacing: 0.2px;
}

.jolly-choice .jolly-instruction {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
}

.jolly-buttons {
    display: flex;
    gap: 14px;
    justify-content: center;
}

/* Trick Winner Popup */
.trick-winner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    /* NO display:none here - use opacity only for smooth animation */
    will-change: opacity;
}

.trick-winner-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}



.trick-winner-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    /* Center using margin - half of typical width */
    margin-left: -188px;
    margin-top: -75px;
    width: 376px;
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    padding: 32px 48px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 2px rgba(34, 197, 94, 0.5);
    border: 1px solid var(--success);
    z-index: 151;
    /* Animation properties */
    transform: scale(0.9);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
    will-change: transform, opacity;
}

.trick-winner-popup.visible {
    transform: scale(1);
    opacity: 1;
    visibility: visible;
}

.trick-winner-popup.loser {
    background: linear-gradient(135deg, #c41e3a 0%, #a01830 100%);
    border-color: var(--danger);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 2px rgba(196, 30, 58, 0.5);
}

.trick-winner-popup.animate-bounce {
    animation: bounceWin 0.4s ease;
}

@keyframes bounceWin {
    0% { transform: scale(1); }
    40% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.trick-winner-content {
    color: white;
}

.trick-winner-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.trick-winner-popup h3 {
    font-size: 1.4rem;
    margin-bottom: 10px;
}

#trick-winner-name {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.trick-winner-card {
    font-size: 14px;
    opacity: 0.9;
}

/* Turn Results */
.turn-results {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    padding: 28px;
    border-radius: var(--border-radius);
    text-align: center;
    z-index: 100;
    min-width: 340px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    will-change: transform, opacity;
    transition: transform 0.3s ease-out, opacity 0.25s ease-out;
}

.turn-results h3 {
    margin-bottom: 20px;
    font-size: 1.2rem;
    color: var(--primary);
}

.results-table-wrap {
    margin-bottom: 20px;
    overflow-x: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 13px;
}

.results-table th,
.results-table td {
    padding: 8px 10px;
}

.results-table th {
    text-align: left;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.results-table td {
    background: var(--bg-medium);
    border-top: 1px solid var(--border-color);
}

.results-table .col-name {
    width: 32%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.results-table .col-bet,
.results-table .col-won {
    width: 12%;
    text-align: center;
}

.results-table .col-result {
    width: 22%;
    text-align: center;
}

.results-table .col-lives {
    width: 22%;
    text-align: right;
    white-space: nowrap;
}

.result-row td:first-child {
    border-left: 3px solid transparent;
}

.result-row.correct td:first-child {
    border-left-color: var(--success);
}

.result-row.wrong td:first-child {
    border-left-color: var(--danger);
}

.life-delta {
    margin-left: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.life-delta.correct {
    color: var(--success);
}

.life-delta.wrong {
    color: var(--danger);
}

.ready-count {
    color: var(--text-secondary);
    margin-top: 14px;
    font-size: 13px;
}

/* Game Messages */
.game-messages {
    position: absolute;
    left: 260px;
    top: 70px;
    width: 240px;
    max-height: 160px;
    overflow-y: auto;
    padding: 10px;
    pointer-events: none;
    z-index: 10;
}

.game-messages .game-message {
    pointer-events: auto;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.game-message {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    font-size: 12px;
    border: 1px solid var(--border-color);
}

.game-message.system {
    border-left: 3px solid var(--accent);
}

.game-message.bet {
    border-left: 3px solid var(--warning);
}

.game-message.play {
    border-left: 3px solid var(--primary);
}

.game-message.trick {
    border-left: 3px solid var(--success);
}

.game-message.result {
    border-left: 3px solid var(--danger);
}

/* Chat */
.game-chat {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 320px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
}

.game-chat.collapsed {
    width: auto;
}

.game-chat.collapsed .chat-body {
    display: none;
}

.chat-header {
    padding: 14px 18px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    transition: var(--transition);
    gap: 12px;
}

.chat-header:hover {
    filter: brightness(1.1);
}

.chat-toggle-icon {
    font-size: 18px;
    transition: transform 0.3s ease;
}

.game-chat.collapsed .chat-toggle-icon {
    transform: rotate(180deg);
}

.chat-badge {
    background: var(--danger);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    animation: pulse-badge 1.5s infinite;
}

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

.chat-body {
    display: flex;
    flex-direction: column;
    height: 280px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
}

.chat-message {
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message .msg-name {
    color: var(--accent);
    font-weight: 700;
}

.chat-message.own .msg-name {
    color: var(--primary-light);
}

.chat-input-area {
    display: flex;
    padding: 12px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-medium);
}

.chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-light);
}

.chat-input-area .btn {
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
    padding: 10px 16px;
}

/* ==================== Game Over Screen ==================== */
.game-over-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 60px 20px;
    text-align: center;
}

.game-over-container h2 {
    font-size: 2.5rem;
    margin-bottom: 28px;
    color: var(--primary);
}

.standings {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 28px;
    border: 1px solid var(--border-color);
}

.standing-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    border-bottom: 1px solid var(--border-color);
}

.standing-item:last-child {
    border-bottom: none;
}

.standing-item.first {
    background: rgba(212, 175, 55, 0.1);
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    border: 1px solid var(--primary);
}

.standing-position {
    font-size: 1.3rem;
    min-width: 50px;
    font-weight: 700;
}

.standing-name {
    flex: 1;
    text-align: left;
    margin-left: 12px;
    font-weight: 500;
}

.standing-lives {
    font-size: 1.1rem;
}

.game-over-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ==================== Spectator Banner ==================== */
#spectator-banner {
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 20px;
    text-align: center;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==================== Hidden ==================== */
.hidden {
    display: none !important;
}

/* ==================== Smooth Scrolling ==================== */
html {
    scroll-behavior: smooth;
}

.chat-messages,
.hand-panel,
.game-history,
.leaderboard {
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==================== Animazioni Extra ==================== */

/* Shake - per errori */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.animate-shake {
    animation: shake 0.5s ease;
}

/* Bounce - per vittoria */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-20px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(-10px); }
}

.animate-bounce {
    animation: bounceWin 0.4s ease;
}

/* Slide-in per popup */
@keyframes slideIn {
    from { 
        opacity: 0; 
        transform: translate(-50%, -60%);
    }
    to { 
        opacity: 1; 
        transform: translate(-50%, -50%);
    }
}

.card-confirm:not(.hidden) {
    animation: slideIn 0.2s ease-out;
}

.jolly-choice:not(.hidden) {
    animation: fadeScale 0.2s ease-out;
}

/* Pulse per turno giocatore */
@keyframes pulse-turn {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.45), 0 0 12px rgba(212, 175, 55, 0.35);
    }
    50% { 
        box-shadow: 0 0 0 10px rgba(212, 175, 55, 0), 0 0 18px rgba(212, 175, 55, 0.6);
    }
}

.current-turn-pulse {
    animation: pulse-turn 2s ease-in-out infinite;
}

.current-turn-pulse .player-name {
    animation: pulse-turn 1.4s ease-in-out infinite;
}

/* Glow per mano vincente */
@keyframes glow {
    0%, 100% { 
        box-shadow: 0 0 5px var(--primary), 0 0 10px var(--primary);
    }
    50% { 
        box-shadow: 0 0 20px var(--primary), 0 0 30px var(--primary);
    }
}

.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

/* Fade scale per notifiche */
@keyframes fadeScale {
    from { 
        opacity: 0; 
        transform: scale(0.8);
    }
    to { 
        opacity: 1; 
        transform: scale(1);
    }
}

/* Trick winner animation handled by .visible class */

.turn-results:not(.hidden) {
    animation: fadeScale 0.3s ease-out;
}

/* ==================== Toast Notifications ==================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 14px;
    max-width: 360px;
    pointer-events: auto;
    cursor: pointer;
    animation: toastIn 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-error {
    background: linear-gradient(135deg, #7f1d1d, #991b1b);
    border-left: 4px solid #ef4444;
}

.toast-success {
    background: linear-gradient(135deg, #14532d, #166534);
    border-left: 4px solid #22c55e;
}

.toast-warning {
    background: linear-gradient(135deg, #78350f, #92400e);
    border-left: 4px solid #f59e0b;
}

.toast-info {
    background: linear-gradient(135deg, var(--bg-medium), var(--bg-light));
    border-left: 4px solid var(--primary);
}

.toast.removing {
    animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ==================== Rules Page ==================== */
.rules-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
}

.rules-title {
    color: var(--primary);
    font-size: 1.8rem;
    margin-bottom: 24px;
    text-align: center;
}

.rules-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 40px;
}

.rules-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
}

.rules-section h3 {
    color: var(--primary);
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.rules-section p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 8px;
}

.rules-section ul {
    color: var(--text-secondary);
    line-height: 1.7;
    padding-left: 20px;
    margin-bottom: 8px;
}

.rules-section li {
    margin-bottom: 4px;
}

.rules-highlight {
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 6px;
    padding: 14px;
    margin-top: 10px;
    color: var(--text-primary);
    line-height: 1.6;
}

/* ==================== Reduced Motion (Accessibility) ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    /* Disabilita animazioni specifiche del gioco */
    .card,
    .played-card-position,
    .btn,
    .room-item,
    .player-card,
    .stat-card {
        transform: none !important;
        transition: none !important;
    }
    
    /* Mantiene visibilità ma senza animazione */
    .current-turn-pulse {
        animation: none !important;
        border: 2px solid var(--primary);
        box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.3);
    }

    .current-turn-pulse .player-name {
        animation: none !important;
        box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.3);
    }
    
    /* Popup appaiono immediatamente */
    .trick-winner-popup,
    .trick-winner-overlay {
        transition: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    
    /* Chat badge senza pulse */
    .chat-badge {
        animation: none !important;
    }
    
    /* Online dot senza animazione */
    .online-dot.away {
        animation: none !important;
        opacity: 0.6;
    }
}

/* ==================== Responsive ==================== */
@media (max-width: 1024px) {
    .game-main {
        flex-direction: column;
    }
    
    .hand-panel {
        width: 100%;
        max-height: 180px;
        border: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .hand-area {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .table-area {
        min-height: 320px;
    }
    
    .game-messages {
        left: 12px;
        width: calc(100% - 24px);
        top: auto;
        bottom: 340px;
        max-height: 120px;
    }
    
    .game-chat {
        width: calc(100% - 48px);
        right: 24px;
    }
    
    .game-chat.collapsed {
        width: auto;
    }
}

@media (max-width: 600px) {
    .screen {
        padding: 16px;
    }
    
    .lobby-actions {
        flex-direction: column;
    }
    
    .search-box {
        width: 100%;
    }
    
    .room-item {
        flex-direction: column;
        gap: 14px;
        text-align: center;
    }
    
    .room-meta {
        flex-direction: column;
        gap: 10px;
    }
    
    .players-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .player-card {
        padding: 18px 14px;
    }
    
    .modal-content {
        padding: 24px;
    }
    
    .btn {
        padding: 12px 20px;
    }
    
    .btn-large {
        padding: 14px 28px;
        font-size: 16px;
    }
}

/* ==================== Reconnect Overlay ==================== */
.reconnect-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}
.reconnect-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.reconnect-content {
    text-align: center;
    color: var(--text-primary);
}
.reconnect-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: reconnect-spin 0.8s linear infinite;
}
@keyframes reconnect-spin {
    to { transform: rotate(360deg); }
}
.reconnect-text {
    font-size: 1rem;
    opacity: 0.9;
}

/* ==================== Accessibility ==================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
