/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #1a1a1a;
    color: #ffffff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

#app {
    height: 100vh;
    height: 100dvh;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow-y: auto;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    min-height: calc(100% - 40px);
}

/* Welcome Screen */
.logo {
    text-align: center;
    margin: 60px 0 80px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 20px;
    letter-spacing: 2px;
}

.logo::before {
    content: '🕵️';
    font-size: 4rem;
    margin-bottom: 20px;
    display: block;
}

.tagline {
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.subtitle {
    color: #999999;
    font-size: 0.9rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.welcome-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 40px;
}

.feature-box {
    background: #2a2a2a;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #333333;
    margin-bottom: 12px;
}

.feature-box h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.feature-box p {
    color: #999999;
    line-height: 1.4;
    font-size: 0.9rem;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-back, .btn-warning, .btn-info {
    display: block;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: #dc3545;
    color: white;
}

.btn-primary:hover:not(.disabled) {
    background: #c82333;
}

.btn-secondary {
    background: #2a2a2a;
    color: #ffffff;
    border: 1px solid #444444;
}

.btn-secondary:hover {
    background: #333333;
}

.btn-warning {
    background: #dc3545;
    color: white;
}

.btn-info {
    background: #2a2a2a;
    color: #ffffff;
    border: 1px solid #444444;
}

.btn-back {
    background: transparent;
    color: #dc3545;
    width: auto;
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 1rem;
    margin-bottom: 20px;
    border: 1px solid #dc3545;
    text-transform: none;
}

.btn-primary.disabled, .btn-secondary.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Header */
.header {
    margin-bottom: 30px;
}

.header h2 {
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Setup Form */
.setup-form {
    background: #2a2a2a;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 30px;
    border: 1px solid #333333;
}

/* Setup Screen Scrolling */
#setup-screen .container,
#welcome-screen .container {
    min-height: 100vh;
    min-height: 100dvh;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    color: #ffffff;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.number-input {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: #1a1a1a;
    border-radius: 8px;
    padding: 12px 16px;
    border: 1px solid #444444;
}

.number-input button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    background: #dc3545;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.number-input button:hover {
    background: #c82333;
}

.number-input span {
    font-size: 1.5rem;
    font-weight: 600;
    color: #ffffff;
    min-width: 30px;
    text-align: center;
}

select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #444444;
    border-radius: 8px;
    font-size: 1rem;
    background: #1a1a1a;
    color: #ffffff;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dc3545' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Player Names */
.player-name-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #444444;
    border-radius: 8px;
    font-size: 1rem;
    background: #1a1a1a;
    color: #ffffff;
    margin-bottom: 8px;
    transition: border-color 0.2s ease;
}

.player-name-input:focus {
    outline: none;
    border-color: #dc3545;
}

.player-name-input::placeholder {
    color: #666666;
}

/* Toggle Switches */
.toggle-group {
    margin-top: 20px;
}

.toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.toggle-item label {
    margin: 0;
    color: #ffffff;
    font-weight: 500;
}

.toggle-item input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 50px;
    height: 26px;
    background: #444444;
    border-radius: 26px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
}

.toggle-item input[type="checkbox"]:checked + .toggle-slider {
    background: #dc3545;
}

.toggle-item input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(24px);
}

/* Rules Screen */
.rules-content {
    flex: 1;
    margin-bottom: 30px;
}

/* Rules Screen Scrolling */
#rules-screen .container {
    min-height: 100vh;
    min-height: 100dvh;
}

.rule-step {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    background: #2a2a2a;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #333333;
}

.step-number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.step-content h3 {
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.step-content p {
    color: #999999;
    line-height: 1.5;
    font-size: 0.95rem;
}

.good-luck {
    text-align: center;
    background: #2a2a2a;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #333333;
    margin-top: 20px;
}

.good-luck h3 {
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 600;
}

/* Role Distribution */
.role-distribution {
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
}

.role-distribution h2 {
    color: #ffffff;
    font-size: 1.5rem;
    margin-bottom: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.instruction {
    color: #999999;
    font-size: 1rem;
    margin-bottom: 40px;
}

.role-reveal-area {
    position: relative;
    height: 280px;
    margin-bottom: 40px;
}

.role-card {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 300px;
    height: 280px;
    border-radius: 20px;
    transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.role-card.hidden {
    opacity: 1;
    transform: translateX(-50%) rotateY(0deg);
}

.role-card.revealed {
    opacity: 0;
    transform: translateX(-50%) rotateY(180deg);
}

.role-card.show-revealed {
    opacity: 1;
    transform: translateX(-50%) rotateY(0deg);
}

.role-card.hide-hidden {
    opacity: 0;
    transform: translateX(-50%) rotateY(-180deg);
}

.card-back, .card-front {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    border: 2px solid #333333;
}

.card-back {
    background: #2a2a2a;
    color: #ffffff;
}

.card-back h3 {
    font-size: 3rem;
    margin-bottom: 20px;
}

.card-back p {
    font-size: 1rem;
    text-align: center;
    color: #999999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-front {
    background: #2a2a2a;
    color: #ffffff;
}

.role-spy {
    background: #2a2a2a;
    color: #ffffff;
    border-color: #dc3545;
}

.role-local {
    background: #2a2a2a;
    color: #ffffff;
    border-color: #28a745;
}

.role-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.role-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.role-location {
    font-size: 1.1rem;
    font-weight: 500;
    text-align: center;
    opacity: 0.9;
    line-height: 1.4;
}

.role-actions {
    margin-top: auto;
    padding-bottom: 40px;
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

.hidden {
    display: none !important;
}

/* Game Screen */
.game-header {
    background: #2a2a2a;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #333333;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.location-info {
    display: flex;
    flex-direction: column;
}

#game-location {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ffffff;
}

.category {
    font-size: 0.85rem;
    color: #999999;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timer-display {
    text-align: right;
}

#timer-display {
    font-size: 2rem;
    font-weight: 700;
    color: #dc3545;
}

.game-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.players-list {
    background: #2a2a2a;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #333333;
    flex: 1;
}

.players-list h3 {
    color: #ffffff;
    margin-bottom: 16px;
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.player-card {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    transition: all 0.2s ease;
    border: 1px solid #444444;
}

.player-card.eliminated {
    opacity: 0.5;
    background: #2a1a1a;
    border-color: #dc3545;
}

.player-name {
    font-weight: 600;
    color: #ffffff;
    font-size: 0.9rem;
}

.game-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Explanation Screen */
.explanation-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding: 40px 0;
}

.explanation-content h2 {
    color: #ffffff;
    font-size: 1.5rem;
    margin-bottom: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.explanation-text {
    color: #999999;
    font-size: 1rem;
    margin-bottom: 40px;
    line-height: 1.5;
}

.explanation-steps {
    margin-bottom: 40px;
}

.explanation-step {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #2a2a2a;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 12px;
    border: 1px solid #333333;
    text-align: left;
}

.step-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.explanation-step p {
    color: #ffffff;
    font-size: 0.95rem;
    line-height: 1.4;
    margin: 0;
}

.explanation-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Results Screen */
.results-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.results-icon {
    font-size: 5rem;
    margin-bottom: 20px;
}

.results-content h2 {
    color: #ffffff;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.results-content p {
    color: #999999;
    font-size: 1rem;
    margin-bottom: 40px;
}

.results-details {
    background: #2a2a2a;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 40px;
    border: 1px solid #333333;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.detail-item:last-child {
    margin-bottom: 0;
}

.label {
    color: #999999;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.value {
    color: #ffffff;
    font-weight: 600;
}

.results-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Responsive Design */
@media (max-width: 375px) {
    .container {
        padding: 16px;
    }
    
    .logo h1 {
        font-size: 3rem;
    }
    
    .feature-box {
        padding: 20px;
    }
    
    .players-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .voting-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 481px) {
    .container {
        padding: 30px;
    }
    
    .game-actions {
        flex-direction: row;
        gap: 12px;
    }
    
    .game-actions button {
        flex: 1;
    }
    
    .results-actions {
        flex-direction: row;
        gap: 12px;
    }
    
    .results-actions button {
        flex: 1;
    }
    
    .voting-actions {
        flex-direction: row;
        gap: 12px;
    }
    
    .voting-actions button {
        flex: 1;
    }
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

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

.pulse {
    animation: pulse 1s ease-in-out infinite;
}

/* Timer Warning */
.timer-warning {
    color: #ff6b6b !important;
    animation: pulse 1s ease-in-out infinite;
}

.timer-critical {
    color: #ff3333 !important;
    animation: shake 0.5s ease-in-out infinite;
}

/* Prevent overscroll and bounce effect */
.no-scroll {
    position: fixed;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

/* Additional mobile scroll fixes */
@media (max-width: 768px) {
    body {
        -webkit-overflow-scrolling: auto;
        touch-action: pan-y;
        overscroll-behavior-y: contain;
    }
    
    .container {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
        touch-action: pan-y;
    }
    
    /* Ensure setup and rules screens have proper spacing on mobile */
    #setup-screen .container,
    #rules-screen .container {
        padding-bottom: calc(60px + env(safe-area-inset-bottom));
    }
    
    /* Give setup form more space on mobile */
    #setup-screen .setup-form {
        margin-bottom: 40px;
    }
    
    /* iOS Safari specific fixes for role screen */
    #role-screen .container {
        padding-bottom: calc(40px + env(safe-area-inset-bottom));
    }
    
    .role-actions {
        margin-bottom: 20px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
    
    /* Ensure buttons are always visible above iOS browser UI */
    .btn-primary, .btn-secondary {
        margin-bottom: 16px;
    }
} 