/* ============================================
   CSS Variables
   ============================================ */
:root {
    --color-bg: #1a1a2e;
    --color-surface: #16213e;
    --color-surface-light: #1f2b47;
    --color-primary: #e94560;
    --color-primary-dark: #c73e54;
    --color-secondary: #0f3460;
    --color-text: #ffffff;
    --color-text-muted: #a0a0a0;
    --color-success: #4ade80;
    --color-warning: #fbbf24;
    --color-error: #ef4444;

    --transition-speed: 0.3s;
    --border-radius: 12px;
    --border-radius-lg: 16px;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}

/* ============================================
   Screens
   ============================================ */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: flex;
}

.screen-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
}

.screen-content.centered {
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* ============================================
   Typography
   ============================================ */
h1 {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.1;
    margin: 0;
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

p {
    color: var(--color-text-muted);
}

strong {
    color: var(--color-text);
}

/* ============================================
   Logo (Home Screen)
   ============================================ */
.logo {
    text-align: center;
    margin-bottom: 24px;
}

.logo-emoji {
    font-size: 5rem;
    display: block;
    margin-bottom: 8px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.logo h1 {
    color: var(--color-primary);
    letter-spacing: 2px;
}

.tagline {
    font-size: 1.1rem;
    margin-bottom: 40px;
    line-height: 1.6;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
    min-height: 52px;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
}

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

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

.btn-primary:not(:disabled):active {
    background: var(--color-primary-dark);
    transform: scale(0.98);
}

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

.btn-secondary:not(:disabled):active {
    background: var(--color-secondary);
}

.btn-large {
    padding: 18px 24px;
    font-size: 1.1rem;
    min-height: 56px;
}

.btn-link {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    padding: 12px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.btn-link:active {
    color: var(--color-text);
}

.btn-icon {
    width: 44px;
    height: 44px;
    min-height: 44px;
    min-width: 44px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--color-text);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.btn-icon:active {
    background: var(--color-surface-light);
}

/* ============================================
   Header Bar (Setup Screen)
   ============================================ */
.header-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.header-bar h2 {
    flex: 1;
    text-align: center;
    margin: 0;
}

.header-bar .spacer {
    width: 44px;
}

/* ============================================
   Setup Screen
   ============================================ */
.setup-info {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.1rem;
    color: var(--color-text-muted);
}

.setup-info #player-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
}

.min-badge {
    font-size: 0.85rem;
    color: var(--color-warning);
}

.min-badge.hidden {
    display: none;
}

.players-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
    max-height: 50vh;
    overflow-y: auto;
}

.player-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-surface-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.player-input-row input {
    flex: 1;
    padding: 14px 16px;
    font-size: 1rem;
    background: var(--color-surface);
    border: 2px solid var(--color-surface-light);
    border-radius: var(--border-radius);
    color: var(--color-text);
    outline: none;
    transition: border-color var(--transition-speed);
}

.player-input-row input:focus {
    border-color: var(--color-primary);
}

.player-input-row input::placeholder {
    color: var(--color-text-muted);
}

.player-input-row input.error {
    border-color: var(--color-error);
}

.btn-remove-player {
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--color-error);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity var(--transition-speed);
}

.btn-remove-player:active {
    opacity: 1;
}

.btn-remove-player.hidden {
    visibility: hidden;
}

.setup-actions {
    margin-top: auto;
    padding-top: 20px;
}

/* ============================================
   Pass Device Screens
   ============================================ */
.pass-icon {
    font-size: 5rem;
    margin-bottom: 16px;
    animation: pulse 2s ease-in-out infinite;
}

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

.pass-instruction {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.pass-player-name {
    font-size: 2rem;
    color: var(--color-primary);
    margin-bottom: 16px;
}

.pass-hint {
    font-size: 0.9rem;
    margin-bottom: 32px;
}

/* ============================================
   Role Reveal Screen
   ============================================ */
.role-content {
    display: none;
    flex-direction: column;
    align-items: center;
}

.role-content.active {
    display: flex;
}

.role-content.hidden {
    display: none;
}

.role-icon {
    font-size: 5rem;
    margin-bottom: 16px;
}

.role-label {
    font-size: 1.2rem;
    margin-bottom: 12px;
}

.word-card {
    background: var(--color-surface);
    padding: 24px 40px;
    border-radius: var(--border-radius-lg);
    margin-bottom: 20px;
    text-align: center;
}

.secret-word {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-warning);
    display: block;
    text-transform: uppercase;
}

.word-category {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    display: block;
    margin-top: 4px;
}

.role-hint {
    font-size: 1rem;
    margin-bottom: 32px;
}

.role-title-fake {
    font-size: 1.8rem;
    color: var(--color-error);
    margin-bottom: 12px;
}

.role-desc-fake {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 32px;
}

/* ============================================
   Drawing Screen
   ============================================ */
.drawing-icon {
    font-size: 5rem;
    margin-bottom: 16px;
}

.instructions-card {
    background: var(--color-surface);
    padding: 20px 24px;
    border-radius: var(--border-radius-lg);
    margin: 24px 0;
    text-align: left;
}

.instructions-list {
    list-style: none;
    padding: 0;
}

.instructions-list li {
    position: relative;
    padding-left: 28px;
    margin-bottom: 12px;
    color: var(--color-text-muted);
}

.instructions-list li:last-child {
    margin-bottom: 0;
}

.instructions-list li::before {
    content: '•';
    position: absolute;
    left: 8px;
    color: var(--color-primary);
    font-weight: bold;
}

.drawing-hint {
    font-size: 0.95rem;
    margin-bottom: 16px;
}

/* ============================================
   Voting Screens
   ============================================ */
.voting-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.voting-icon {
    font-size: 4rem;
    margin-bottom: 8px;
}

.voting-icon-small {
    font-size: 1.5rem;
}

.votes-progress {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-bottom: 24px;
}

.voting-header-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--color-surface);
    border-radius: var(--border-radius);
    margin-bottom: 16px;
}

.voting-question {
    text-align: center;
    margin-bottom: 20px;
}

.voting-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.voting-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 12px;
    background: var(--color-surface);
    border: 3px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
    min-height: 80px;
}

.voting-option:active {
    transform: scale(0.98);
}

.voting-option.selected {
    border-color: var(--color-primary);
    background: var(--color-surface-light);
}

.voting-option .player-name {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
}

.voting-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================
   Guess Screen
   ============================================ */
.guess-icon {
    font-size: 5rem;
    margin-bottom: 16px;
}

.guess-desc {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 24px;
}

#fake-name-guess {
    color: var(--color-primary);
    font-weight: 600;
}

.form-group {
    width: 100%;
    margin-bottom: 24px;
}

.form-group input {
    width: 100%;
    padding: 16px 20px;
    font-size: 1.2rem;
    text-align: center;
    background: var(--color-surface);
    border: 2px solid var(--color-surface-light);
    border-radius: var(--border-radius);
    color: var(--color-text);
    outline: none;
    transition: border-color var(--transition-speed);
}

.form-group input:focus {
    border-color: var(--color-primary);
}

.form-group input::placeholder {
    color: var(--color-text-muted);
}

/* ============================================
   Result Screen
   ============================================ */
.result-display {
    padding: 32px 24px;
    border-radius: var(--border-radius-lg);
    margin-bottom: 24px;
    width: 100%;
}

.result-display.artists-win {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

.result-display.fakeartist-win {
    background: linear-gradient(135deg, var(--color-primary) 0%, #dc2626 100%);
}

.result-emoji {
    font-size: 4rem;
    display: block;
    margin-bottom: 8px;
}

.result-title {
    font-size: 1.5rem;
    margin: 0;
}

.result-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
    width: 100%;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--color-surface);
    border-radius: var(--border-radius);
}

.detail-row.hidden {
    display: none;
}

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

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

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

/* ============================================
   Modal
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--color-surface);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    max-width: 400px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    margin: 0;
}

.help-section {
    margin-bottom: 20px;
}

.help-section h3 {
    color: var(--color-primary);
    margin-bottom: 8px;
}

.help-section p {
    font-size: 0.95rem;
    line-height: 1.6;
}

.help-section ul {
    padding-left: 20px;
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.help-section li {
    margin-bottom: 8px;
}

/* ============================================
   Toast
   ============================================ */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--color-surface);
    color: var(--color-text);
    padding: 14px 24px;
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s forwards;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.toast-success {
    background: var(--color-success);
    color: #000;
}

.toast-error {
    background: var(--color-error);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

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

/* ============================================
   Responsive
   ============================================ */
@media (min-width: 400px) {
    .logo h1 {
        font-size: 3.5rem;
    }

    .secret-word {
        font-size: 3rem;
    }
}

@media (min-width: 768px) {
    .screen-content {
        padding: 40px 24px;
    }

    .voting-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
