:root {
    --primary: #ff4757;
    --primary-dark: #ee3f4d;
    --secondary: #ffa502;
    --dark: #1e272e;
    --darker: #0f1419;
    --card-bg: rgba(255,255,255,0.05);
    --white: #fff;
    --green: #2ed573;
    --green-dark: #26b563;
    --red: #ff6b81;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--darker) 0%, var(--dark) 100%);
    color: var(--white);
    min-height: 100vh;
    overflow: hidden;
}

/* ==================== LANDING PAGE (DESKTOP ONLY) ==================== */
#landing-page {
    display: none; /* Caché par défaut sur mobile */
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e22ce 100%);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.landing-content {
    text-align: center;
    animation: fadeInUp 0.8s ease;
}

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

.landing-content h1 {
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 900;
    background: linear-gradient(45deg, #fff, #ffa502);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
    text-shadow: 0 0 60px rgba(255,165,2,0.5);
}

.landing-subtitle {
    font-size: 1.5rem;
    opacity: 0.9;
    margin-bottom: 3rem;
}

.qr-container {
    background: white;
    padding: 20px;
    border-radius: 20px;
    display: inline-block;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    margin-bottom: 2rem;
    transition: transform 0.3s;
}

.qr-container:hover {
    transform: scale(1.05);
}

.qr-container img {
    display: block;
    width: 250px;
    height: 250px;
}

.qr-text {
    margin: 1rem 0;
    font-size: 1.1rem;
    opacity: 0.8;
}

.divider {
    margin: 2rem 0;
    font-size: 1.2rem;
    font-weight: 600;
    opacity: 0.6;
}

.btn-desktop {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-desktop:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

/* ==================== APP CONTAINER ==================== */
#app-container {
    width: 100%;
    height: 100vh;
    background: var(--dark);
    position: relative;
    display: flex;
    flex-direction: column;
}

/* ==================== RESPONSIVE BEHAVIOR ==================== */

/* Mobile: App visible par défaut */
@media (max-width: 1023px) {
    #app-container {
        display: flex;
    }
}

/* Desktop: Landing visible, App cachée */
@media (min-width: 1024px) {
    #landing-page {
        display: flex;
    }
    
    #app-container {
        display: none;
    }

    /* Mode téléphone activé via JS */
    #app-container.phone-mode {
        display: flex;
        width: 390px;
        height: 85vh;
        max-height: 844px;
        margin: auto;
        border-radius: 40px;
        border: 12px solid #1a1a1a;
        box-shadow: 
            0 0 0 2px #333,
            0 30px 80px rgba(0,0,0,0.8);
        position: relative;
    }

    /* Notch iPhone */
    #app-container.phone-mode::before {
        content: '';
        position: absolute;
        top: -12px;
        left: 50%;
        transform: translateX(-50%);
        width: 150px;
        height: 30px;
        background: #1a1a1a;
        border-radius: 0 0 20px 20px;
        z-index: 10;
    }
}

/* ==================== SECTIONS ==================== */
.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    padding: 20px;
    overflow: hidden;
}

.screen.active {
    display: flex;
    animation: slideIn 0.4s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ==================== SETUP SCREEN ==================== */
.main-title {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 900;
    margin-bottom: 1rem;
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.setup-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
}

.setup-scroll::-webkit-scrollbar {
    width: 6px;
}

.setup-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.setup-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}

.setup-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.3s;
}

.setup-card:hover {
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

.setup-card h3 {
    color: var(--primary);
    font-size: 1.2rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Players */
.input-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

input[type="text"],
input[type="number"] {
    flex: 1;
    padding: 12px 15px;
    border-radius: 10px;
    border: 2px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.3);
    color: white;
    font-size: 1rem;
    transition: all 0.3s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0,0,0,0.5);
}

.btn-add {
    background: var(--green);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 60px;
}

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

#players-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    min-height: 40px;
}

.player-chip {
    background: var(--primary);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    animation: chipIn 0.3s ease;
}

@keyframes chipIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.player-chip .remove {
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.player-chip .remove:hover {
    opacity: 1;
}

/* Playlists */
.playlist-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.playlist-actions button {
    flex: 1;
    padding: 8px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.playlist-actions button:active {
    transform: scale(0.95);
}

#playlist-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.pl-tile {
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s;
    user-select: none;
}

.pl-tile:active {
    transform: scale(0.95);
}

.pl-tile.selected {
    background: rgba(255, 71, 87, 0.2);
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(255, 71, 87, 0.3);
}

.pl-tile.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pl-name {
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.pl-count {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Rounds */
.mode-switch {
    margin: 10px 0;
}

.mode-switch label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.mode-switch input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 15px 0;
}

input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 5px;
    background: rgba(255,255,255,0.1);
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(255,71,87,0.5);
}

.slider-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 50px;
    text-align: center;
}

.limit-msg {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.5);
    text-align: center;
    margin-top: 5px;
}

.hidden {
    display: none !important;
}

/* Start Button */
.btn-start {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 18px;
    font-size: 1.3rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 15px;
    cursor: pointer;
    margin-top: 15px;
    box-shadow: 0 10px 30px rgba(255,71,87,0.4);
    transition: all 0.3s;
}

.btn-start:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(255,71,87,0.5);
}

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

/* ==================== GAME SCREEN ==================== */
#game-screen header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.btn-quit {
    background: rgba(231,76,60,0.2);
    border: 2px solid #e74c3c;
    color: #e74c3c;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.btn-quit:hover {
    background: #e74c3c;
    color: white;
}

.player-info {
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--secondary);
}

.round-info {
    font-size: 1.1rem;
    font-weight: 600;
    opacity: 0.8;
}

.scene {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1200px;
}

.card {
    width: 90%;
    max-width: 320px;
    aspect-ratio: 2/3;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

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

.face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.front {
    background: linear-gradient(135deg, #ff6b81, #ff4757);
}

.front .icon {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: pulse 2s ease-in-out infinite;
}

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

.front div:last-child {
    font-size: 1.2rem;
    font-weight: 600;
    opacity: 0.9;
}

.back {
    background: white;
    color: #333;
    transform: rotateY(180deg);
    padding: 25px;
    gap: 15px;
}

.badge-cat {
    background: var(--secondary);
    color: white;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

#card-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.3;
}

#card-artist {
    font-size: 1.2rem;
    color: #666;
    font-weight: 500;
}

.badge-year {
    background: #ecf0f1;
    color: #555;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.9rem;
}

.controls {
    padding: 20px 0;
}

#pre-reveal {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    opacity: 0.8;
    animation: blink 1.5s ease-in-out infinite;
}

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

#post-reveal {
    display: flex;
    gap: 12px;
}

.btn-pass {
    flex: 1;
    background: var(--secondary);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s;
}

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

.btn-win {
    flex: 1;
    background: var(--green);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s;
}

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

/* ==================== MODAL ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

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

.modal-box {
    background: var(--dark);
    border: 1px solid rgba(255,255,255,0.1);
    width: 90%;
    max-width: 400px;
    padding: 25px;
    border-radius: 20px;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-box h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    text-align: center;
}

.modal-row {
    margin-bottom: 20px;
}

.modal-row > span {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    opacity: 0.9;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    background: rgba(255,255,255,0.1);
    padding: 10px 15px;
    border-radius: 20px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    user-select: none;
}

.chip:active {
    transform: scale(0.95);
}

.chip.selected {
    background: var(--green);
    border-color: var(--green-dark);
    color: white;
    font-weight: 600;
}

.modal-footer {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.modal-footer button {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1.05rem;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-cancel {
    background: rgba(231,76,60,0.2);
    color: #e74c3c;
    border: 2px solid #e74c3c;
}

.btn-cancel:hover {
    background: #e74c3c;
    color: white;
}

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

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

/* ==================== RESULT SCREEN ==================== */
#result-screen {
    text-align: center;
}

#result-screen h1 {
    font-size: 2rem;
    margin-bottom: 30px;
}

#leaderboard {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
}

.leaderboard-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 12px;
    border: 2px solid transparent;
    animation: slideIn 0.4s ease backwards;
}

.leaderboard-row:nth-child(1) {
    border-color: gold;
    background: rgba(255, 215, 0, 0.1);
    animation-delay: 0.1s;
}

.leaderboard-row:nth-child(2) {
    border-color: silver;
    background: rgba(192, 192, 192, 0.1);
    animation-delay: 0.2s;
}

.leaderboard-row:nth-child(3) {
    border-color: #cd7f32;
    background: rgba(205, 127, 50, 0.1);
    animation-delay: 0.3s;
}

.leaderboard-row span {
    font-size: 1.1rem;
}

.leaderboard-row strong {
    font-size: 1.3rem;
    color: var(--secondary);
}

/* ==================== LOADER ==================== */
.loader {
    text-align: center;
    padding: 20px;
    opacity: 0.6;
}

/* ==================== UTILITIES ==================== */
@media (hover: hover) {
    .btn-add:hover { background: var(--green-dark); }
    .btn-start:hover { transform: translateY(-3px); }
}