/* ===== BASE & BACKGROUND ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-image:
        linear-gradient(135deg,
            rgba(15, 12, 41, 0.75),
            rgba(48, 43, 99, 0.70),
            rgba(36, 36, 62, 0.75)
        ),
        url("/static/images/background.jpg");
    background-size: cover;
    background-position: center center;
    background-attachment: fixed;
    color: #e8e8e8;
    text-align: center;
    overflow-x: hidden;
}

/* ===== TITLE ===== */
h1 {
    margin-top: 25px;
    font-size: 3.2rem;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #f7971e, #ffd200, #ff6fd8, #3813c2);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 4s ease infinite;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

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

h2 {
    color: #ffffff;
    font-size: 1.6rem;
    text-shadow: 0 0 12px rgba(255, 111, 216, 0.6);
}

h3 {
    color: #c8b6ff;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 0 8px rgba(200, 182, 255, 0.4);
}

/* ===== GAME CONTAINER ===== */
.game-container {
    margin-top: 30px;
    padding-bottom: 40px;
}

/* ===== CHOICE CARDS ===== */
.choices {
    margin-bottom: 35px;
    display: flex;
    justify-content: center;
    gap: 25px;
    flex-wrap: wrap;
}

.choice-card {
    display: inline-block;
    margin: 10px;
    padding: 18px 22px;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.choice-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(
        transparent, rgba(255, 111, 216, 0.3), transparent 30%
    );
    animation: borderSpin 4s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.choice-card:hover::before {
    opacity: 1;
}

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

.choice-card::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 18px;
    background: rgba(20, 15, 50, 0.85);
    z-index: 0;
}

.choice-card > * {
    position: relative;
    z-index: 1;
}

.choice-card:hover {
    transform: translateY(-8px) scale(1.08);
    box-shadow:
        0 15px 40px rgba(255, 111, 216, 0.25),
        0 5px 15px rgba(56, 19, 194, 0.3);
    border-color: rgba(255, 111, 216, 0.5);
}

.choice-card:active {
    transform: translateY(-2px) scale(1.02);
}

.choice {
    width: 110px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    transition: filter 0.3s ease;
}

.choice-card:hover .choice {
    filter: drop-shadow(0 4px 16px rgba(255, 111, 216, 0.5));
}

.choice-label {
    margin-top: 10px;
    font-weight: 700;
    font-size: 1rem;
    color: #e0d7ff;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ===== BATTLE ARENA ===== */
.battle {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin-bottom: 30px;
    padding: 25px 40px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 550px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.battle img {
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
    padding: 10px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.4s ease;
}

.vs-divider {
    font-size: 2.2rem;
    font-weight: 900;
    background: linear-gradient(180deg, #ffd200, #ff6fd8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 12px rgba(255, 111, 216, 0.6));
    animation: vsPulse 1.5s ease-in-out infinite alternate;
}

@keyframes vsPulse {
    from { transform: scale(1); filter: drop-shadow(0 0 8px rgba(255, 111, 216, 0.4)); }
    to   { transform: scale(1.15); filter: drop-shadow(0 0 20px rgba(255, 111, 216, 0.8)); }
}

/* ===== RESULT TEXT ===== */
#result {
    font-size: 1.8rem;
    font-weight: 800;
    margin: 25px auto 20px auto;
    padding: 10px 30px;
    display: block;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    transition: all 0.4s ease;
}

/* ===== ANIMATIONS ===== */
@keyframes shake {
    0%   { transform: rotate(0deg) scale(1); }
    20%  { transform: rotate(20deg) scale(1.05); }
    40%  { transform: rotate(-20deg) scale(1.05); }
    60%  { transform: rotate(15deg) scale(1.02); }
    80%  { transform: rotate(-10deg) scale(1.01); }
    100% { transform: rotate(0deg) scale(1); }
}

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

@keyframes pulse {
    from { transform: scale(1); text-shadow: 0 0 10px rgba(255, 215, 0, 0.4); }
    to   { transform: scale(1.15); text-shadow: 0 0 25px rgba(255, 215, 0, 0.8); }
}

.win {
    animation: pulse 0.6s infinite alternate;
    color: #ffd700 !important;
}

/* ===== SCOREBOARD ===== */
.scoreboard {
    margin-top: 25px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: block;
    margin-left: auto;
    margin-right: auto;
    padding: 18px 30px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    color: #e0d7ff;
    min-width: 200px;
}

.scoreboard h3 {
    margin-bottom: 8px;
    font-size: 1rem;
    background: linear-gradient(90deg, #ffd200, #ff6fd8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.scoreboard p {
    margin: 6px 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.scoreboard span {
    font-weight: 800;
    color: #ffffff;
    font-size: 1.1rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    h1 { font-size: 2rem; }
    .choices { gap: 10px; }
    .choice-card { padding: 12px; }
    .choice { width: 80px; }
    .battle { gap: 20px; padding: 15px 20px; }
    .vs-divider { font-size: 1.5rem; }
    .camera-container { width: 280px; height: 210px; }
    .camera-container video,
    .camera-container canvas { width: 280px; height: 210px; }
}

/* ===== CAMERA SECTION ===== */
.camera-section {
    margin-bottom: 25px;
}

.camera-btn {
    padding: 14px 28px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.camera-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.5);
}

.camera-btn.active {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4);
}

.camera-container {
    position: relative;
    width: 320px;
    height: 240px;
    margin: 20px auto 0;
    border-radius: 16px;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    background: #111;
}

.camera-container.hidden {
    display: none;
}

.camera-container video,
.camera-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 320px;
    height: 240px;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror for natural feel */
}

.camera-container canvas {
    z-index: 2;
}

.gesture-label {
    position: absolute;
    bottom: 45px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    background: rgba(0, 0, 0, 0.7);
    color: #ffd700;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

.camera-instructions {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    z-index: 3;
    font-size: 0.75rem;
    color: #ccc;
    text-align: center;
}

/* Gesture detected animation */
@keyframes gestureFlash {
    0%   { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7); }
    70%  { box-shadow: 0 0 0 15px rgba(255, 215, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
}

.camera-container.detected {
    animation: gestureFlash 0.6s ease-out;
    border-color: #ffd700;
}

/* ===== MODE SELECTION ===== */
.mode-selection {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.mode-btn {
    padding: 20px 40px;
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.mode-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.5);
}

.mode-btn.multiplayer {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    box-shadow: 0 8px 25px rgba(245, 87, 108, 0.4);
}

.mode-btn.multiplayer:hover {
    box-shadow: 0 15px 35px rgba(245, 87, 108, 0.5);
}

/* ===== MULTIPLAYER LOBBY ===== */
.multiplayer-lobby, .waiting-room {
    margin-top: 40px;
    display: flex;
    justify-content: center;
}

.lobby-card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 30px 40px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.lobby-card h2 {
    margin-bottom: 25px;
    font-size: 1.5rem;
}

.lobby-section {
    margin-bottom: 20px;
    text-align: left;
}

.lobby-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #c8b6ff;
}

.lobby-section input, #room-code-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    outline: none;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.lobby-section input:focus, #room-code-input:focus {
    border-color: #ffd200;
}

#room-code-input {
    text-transform: uppercase;
    letter-spacing: 4px;
    text-align: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.lobby-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.lobby-btn {
    padding: 14px 24px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lobby-btn.create {
    background: linear-gradient(135deg, #11998e, #38ef7d);
    box-shadow: 0 6px 20px rgba(56, 239, 125, 0.3);
}

.lobby-btn.create:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(56, 239, 125, 0.4);
}

.lobby-btn.join {
    background: linear-gradient(135deg, #667eea, #764ba2);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.lobby-btn.join:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.lobby-divider {
    text-align: center;
    color: #888;
    font-size: 0.9rem;
    margin: 5px 0;
}

.join-section {
    display: flex;
    gap: 10px;
}

.join-section input {
    flex: 1;
}

.join-section .lobby-btn {
    white-space: nowrap;
}

.back-btn {
    margin-top: 20px;
    padding: 10px 20px;
    font-size: 0.9rem;
    color: #aaa;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-btn:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.5);
}

/* ===== WAITING ROOM ===== */
.share-text {
    color: #ffd200;
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.players-list {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}

.player-slot {
    padding: 10px;
    font-size: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.player-slot:last-child {
    border-bottom: none;
}

.player-slot span {
    color: #38ef7d;
    font-weight: 700;
}

.waiting-status {
    color: #c8b6ff;
    font-style: italic;
    animation: blink 1.5s infinite;
}

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

/* ===== COUNTDOWN OVERLAY ===== */
.countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.countdown-number {
    font-size: 10rem;
    font-weight: 900;
    background: linear-gradient(180deg, #ffd200, #ff6fd8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: countdownPop 1s ease-out;
    text-shadow: none;
    filter: drop-shadow(0 0 30px rgba(255, 111, 216, 0.6));
}

@keyframes countdownPop {
    0% { transform: scale(2); opacity: 0; }
    50% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

.countdown-text {
    font-size: 1.5rem;
    color: #c8b6ff;
    margin-top: 20px;
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* ===== GAME MODE INDICATOR ===== */
.game-mode-indicator {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

#mode-text {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    color: #c8b6ff;
}

.change-mode-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
    color: #aaa;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.change-mode-btn:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.5);
}

/* ===== CHOICE LOCKED ===== */
.choice-locked {
    background: linear-gradient(135deg, #11998e, #38ef7d);
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    margin-bottom: 20px;
    display: inline-block;
    animation: pulse 1s infinite alternate;
}

/* ===== PLAY AGAIN BUTTON ===== */
.play-again-btn {
    margin-top: 25px;
    padding: 16px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #f093fb, #f5576c);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(245, 87, 108, 0.4);
}

.play-again-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 35px rgba(245, 87, 108, 0.5);
}

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