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

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-color);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: block;
}

.container {
    max-width: 600px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text-color);
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    transition: border-color 0.3s;
}

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

.btn {
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:active {
    transform: scale(0.98);
}

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

.btn-secondary:active {
    transform: scale(0.98);
}

.btn-small {
    padding: 10px 16px;
    font-size: 0.9rem;
}

.player-count-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.player-count-btn {
    padding: 20px;
    font-size: 1.5rem;
    font-weight: 700;
    border: 3px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s;
}

.player-count-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.player-count-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-color: var(--primary-color);
    color: white;
}

.player-count-btn:active {
    transform: scale(0.95);
}

.dealer-button {
    width: 100%;
    padding: 16px;
    margin-bottom: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.dealer-button:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.dealer-button:active {
    transform: scale(0.98);
}

.current-player-info {
    text-align: center;
    margin-bottom: 24px;
}

.dealer-badge {
    display: inline-block;
    padding: 6px 12px;
    background: var(--bg-color);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.current-player-name {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin: 12px 0;
}

.instruction-text {
    color: var(--text-muted);
    font-size: 1rem;
    margin: 8px 0;
}

.prediction-reminder {
    display: inline-block;
    padding: 8px 16px;
    background: var(--bg-color);
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--warning-color);
    margin-top: 8px;
}

.tricks-info {
    display: inline-block;
    padding: 6px 12px;
    background: var(--bg-color);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.tricks-info .highlight {
    color: var(--primary-color);
    font-weight: 600;
}

.tricks-info .forbidden {
    color: var(--danger-color);
    font-weight: 600;
}

.number-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.number-btn {
    padding: 24px 16px;
    font-size: 1.8rem;
    font-weight: 700;
    border: 3px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s;
}

.number-btn:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
}

.number-btn:active {
    transform: scale(0.95);
}

.number-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: var(--danger-color);
}

.number-btn.disabled:hover {
    border-color: var(--danger-color);
    background: var(--bg-color);
    transform: none;
}

.predictions-list {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

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

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

.prediction-item .name {
    font-weight: 600;
    color: var(--text-color);
}

.prediction-item .value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.prediction-item.correct {
    background: rgba(16, 185, 129, 0.1);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 8px;
}

.prediction-item.wrong {
    background: rgba(239, 68, 68, 0.1);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 8px;
}

.predictions-overview {
    margin-bottom: 20px;
}

.predictions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.prediction-card {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.prediction-card.dealer {
    border-color: var(--warning-color);
}

.prediction-card.done {
    opacity: 0.6;
}

.prediction-card .player-name-small {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 4px;
}

.prediction-card .prediction-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.prediction-card .dealer-icon {
    font-size: 0.75rem;
    color: var(--warning-color);
    margin-left: 4px;
}

.prediction-card .result-value {
    font-size: 0.9rem;
    margin-top: 4px;
    color: var(--text-muted);
}

.prediction-card.correct .result-value {
    color: var(--success-color);
    font-weight: 600;
}

.prediction-card.wrong .result-value {
    color: var(--danger-color);
    font-weight: 600;
}

.player-navigation {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.nav-btn {
    width: 48px;
    height: 48px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    flex-shrink: 0;
}

.nav-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nav-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.number-btn.auto-calculated {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
}

.player-select-btn {
    font-size: 1rem !important;
    padding: 20px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header {
    background: var(--card-bg);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
}

.game-code {
    cursor: pointer;
    padding: 8px 12px;
    background: var(--bg-color);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.3s;
}

.game-code:active {
    background: var(--border-color);
}

.round-info {
    font-weight: 600;
    color: var(--primary-color);
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.player-input,
.prediction-input,
.result-input {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.player-input:last-child,
.prediction-input:last-child,
.result-input:last-child {
    border-bottom: none;
}

.player-name,
.player-label {
    font-weight: 600;
    color: var(--text-color);
    flex: 1;
}

.player-input input {
    flex: 2;
    margin: 0;
}

.prediction-input input,
.result-input input {
    width: 80px;
    margin: 0;
    text-align: center;
}

.scoreboard {
    margin-top: 30px;
}

.table-container {
    overflow-x: auto;
    margin-bottom: 15px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--bg-color);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--primary-color);
    position: sticky;
    top: 0;
}

tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

tbody tr:hover {
    background: rgba(99, 102, 241, 0.1);
}

.total-score {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.actions {
    margin-top: 30px;
    padding-bottom: 30px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s;
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.game-code-display {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    padding: 20px;
    background: var(--bg-color);
    border-radius: 8px;
    margin: 20px 0;
    letter-spacing: 4px;
    color: var(--primary-color);
}

#finalScores {
    margin-bottom: 20px;
}

.final-score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    margin-bottom: 12px;
    background: var(--bg-color);
    border-radius: 8px;
    border: 2px solid transparent;
}

.final-score-item.winner {
    border-color: var(--warning-color);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.05));
}

.final-score-item .rank {
    font-size: 1.5rem;
    margin-right: 16px;
}

.final-score-item .name {
    flex: 1;
    font-weight: 600;
    font-size: 1.1rem;
}

.final-score-item .score {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
}

.prediction-info {
    display: flex;
    gap: 10px;
    align-items: center;
}

.prediction-badge {
    display: inline-block;
    padding: 4px 8px;
    background: var(--bg-color);
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    .card {
        padding: 16px;
    }

    .game-code-display {
        font-size: 1.5rem;
        letter-spacing: 2px;
    }
}

/* Loading spinner */
.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success/Error messages */
.message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 500;
}

.message-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.message-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

/* Touch feedback */
button:active,
.game-code:active {
    opacity: 0.8;
}

/* Prevent zoom on input focus on iOS */
@media screen and (max-width: 768px) {
    input[type="number"],
    input[type="text"] {
        font-size: 16px;
    }
}
