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

:root {
    --bg-primary: #0d1329;
    --bg-secondary: #1a2140;
    --bg-card: #252b4a;
    --accent-orange: #f59e0b;
    --accent-orange-dark: #d97706;
    --onboarding-accent: var(--accent-orange);
    --onboarding-accent-dark: var(--accent-orange-dark);
    --onboarding-shadow: rgba(245, 158, 11, 0.3);
    --onboarding-shadow-hover: rgba(245, 158, 11, 0.4);
    --accent-pink: #ff3b6f;
    --accent-pink-dark: #cc2f59;
    --text-primary: #ffffff;
    --text-secondary: #8892b0;
    --text-placeholder: #5a6380;
    --success: #4ade80;
    --error: #f87171;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(180deg, var(--bg-primary) 0%, #0a0f1f 100%);
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
    color: var(--text-primary);
    overflow-x: hidden;
}

.app {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
    position: relative;
}

.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
    padding: 40px 24px;
    padding-top: calc(40px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: flex;
}

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

.title {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 30px;
}

/* Back Button */
.btn-back {
    position: absolute;
    top: calc(40px + env(safe-area-inset-top, 0px));
    left: 24px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

/* Players List */
.players-list {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

/* Bottom Section */
.bottom-section {
    padding: 20px 0;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Play Button */
.btn-play {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-orange) 0%, var(--accent-orange-dark) 100%);
    border: none;
    color: white;
    padding: 18px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3);
}

@media (hover: hover) {
    .btn-play:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 25px rgba(245, 158, 11, 0.4);
    }
}

.btn-play:active {
    transform: translateY(0);
}

.btn-play:disabled {
    background: var(--bg-card);
    box-shadow: none;
    cursor: not-allowed;
}

.btn-secondary {
    width: 100%;
    background: transparent;
    border: 2px solid var(--text-secondary);
    color: var(--text-primary);
    padding: 16px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

/* Cards Screen */
#cards-screen {
    justify-content: center;
    align-items: center;
    padding-top: 60px;
}

.card-container {
    perspective: 1000px;
    width: 300px;
    height: 400px;
    margin: 20px 0;
}

.game-card {
    width: 100%;
    height: 100%;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.game-card.swiping {
    transition: transform 0.4s ease;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.game-card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.card-front {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
    border: 2px solid var(--accent-orange);
}

.card-back {
    background: linear-gradient(135deg, var(--accent-orange) 0%, var(--accent-orange-dark) 100%);
    transform: rotateY(180deg);
}

.card-title {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.card-player-name {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-orange);
    margin-bottom: 30px;
}

.card-hint {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
}

.card-location {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.card-location.spy {
    display: none;
}

.card-role {
    font-size: 28px;
    font-weight: 700;
    color: white;
    text-align: center;
    line-height: 1.4;
}

.card-role.spy {
    font-size: 24px;
}

.card-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    width: 300px;
}

.btn-show-role, .btn-next-player {
    flex: 1;
    padding: 14px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.btn-show-role {
    background: var(--accent-orange);
    color: white;
}

.btn-show-role:active {
    transform: scale(0.96);
}

.btn-next-player {
    background: var(--accent-orange);
    color: white;
    display: none;
}

.btn-next-player:active {
    transform: scale(0.96);
}

.swipe-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.swipe-hint.visible {
    opacity: 1;
}

/* Instructions Card */
.instructions-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    margin-bottom: 30px;
}

.instructions-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.instructions-text {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

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

.instructions-text.highlight {
    color: var(--accent-orange);
    font-weight: 600;
}

.instructions-text.small {
    font-size: 14px;
}

/* Player Order */
.player-order {
    flex: 1;
    overflow-y: auto;
}

.order-label {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
}

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

.order-item {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 14px 16px;
    animation: slideIn 0.3s ease;
}

.order-number {
    width: 32px;
    height: 32px;
    background: var(--accent-orange);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    margin-right: 14px;
}

.order-name {
    font-size: 16px;
    color: var(--text-primary);
}

/* Show Locations Button */
.btn-show-locations {
    width: 100%;
    background: var(--bg-card);
    border: 2px solid var(--accent-orange);
    color: var(--accent-orange);
    padding: 16px;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

@media (hover: hover) {
    .btn-show-locations:hover {
        background: var(--accent-orange);
        color: white;
    }
}

/* Locations Overlay */
.locations-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 15, 31, 0.95);
    z-index: 1000;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

.locations-overlay.active {
    display: flex;
}

.overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    flex-shrink: 0;
}

.overlay-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.overlay-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 28px;
    cursor: pointer;
    padding: 8px;
    line-height: 1;
}

.locations-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 0 24px 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.location-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.location-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 12px;
    background: var(--bg-card);
}

.location-card span {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.3;
}


/* Mobile Responsive */
@media (max-width: 480px) {
    .app {
        max-width: 100%;
    }

    .screen {
        padding: 20px 12px;
        padding-top: calc(20px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .title {
        font-size: 22px;
        margin-bottom: 20px;
    }

    .btn-play {
        padding: 16px;
        font-size: 16px;
    }

    .card-container {
        width: 240px;
        height: 320px;
    }

    .card-buttons {
        width: 240px;
    }

    .card-player-name {
        font-size: 22px;
        margin-bottom: 20px;
    }

    .card-location {
        font-size: 14px;
    }

    .card-role {
        font-size: 20px;
        line-height: 1.3;
    }

    .card-hint {
        font-size: 13px;
    }

    .swipe-hint {
        font-size: 12px;
        margin-top: 12px;
    }

    .instructions-card {
        padding: 20px;
        margin-bottom: 20px;
    }

    .instructions-icon {
        font-size: 36px;
        margin-bottom: 12px;
    }

    .instructions-text {
        font-size: 14px;
        line-height: 1.4;
    }

    .instructions-text.small {
        font-size: 12px;
    }

    .order-label {
        font-size: 13px;
        margin-bottom: 12px;
    }

    .order-list {
        gap: 8px;
    }

    .order-item {
        padding: 12px 14px;
    }

    .order-number {
        width: 28px;
        height: 28px;
        font-size: 12px;
        margin-right: 10px;
    }

    .order-name {
        font-size: 14px;
    }

    .locations-grid {
        gap: 8px;
        padding: 0 12px 12px;
    }

    .location-card span {
        font-size: 10px;
    }

    .overlay-header {
        padding: 16px 12px;
    }
}

/* Responsive Height */
@media (max-height: 700px) {
    .screen {
        padding: 20px;
    }

    .title {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .card-container {
        width: 260px;
        height: 340px;
    }

    .card-player-name {
        font-size: 24px;
    }

    .card-role {
        font-size: 24px;
    }

}

/* Tablet and larger */
@media (min-width: 768px) {
    .app {
        max-width: 100%;
    }

    .screen {
        padding: 50px 40px;
    }

    .title {
        font-size: 32px;
        margin-bottom: 40px;
    }

    .card-container {
        width: 320px;
        height: 420px;
    }

    .card-player-name {
        font-size: 32px;
    }

    .card-role {
        font-size: 32px;
    }

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