/* Game Screen CSS - Romantic Valentine's Design with Side-by-Side Layout */

.game-screen {
    display: none;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
}

/* ===== GAME HEADER WITH STRING LIGHTS ===== */
.game-header {
    position: relative;
    padding: 15px 50px 25px 50px;
    flex-shrink: 0;
}

/* Heart-shaped string lights decoration */
.string-lights {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1200px;
    height: 50px;
    background-image:
        radial-gradient(circle at 10% 25px, rgba(255, 200, 100, 0.9) 8px, transparent 8px),
        radial-gradient(circle at 20% 20px, rgba(255, 150, 150, 0.9) 8px, transparent 8px),
        radial-gradient(circle at 30% 25px, rgba(255, 200, 100, 0.9) 8px, transparent 8px),
        radial-gradient(circle at 40% 20px, rgba(255, 100, 100, 0.9) 8px, transparent 8px),
        radial-gradient(circle at 50% 25px, rgba(255, 200, 100, 0.9) 8px, transparent 8px),
        radial-gradient(circle at 60% 20px, rgba(255, 100, 100, 0.9) 8px, transparent 8px),
        radial-gradient(circle at 70% 25px, rgba(255, 200, 100, 0.9) 8px, transparent 8px),
        radial-gradient(circle at 80% 20px, rgba(255, 150, 150, 0.9) 8px, transparent 8px),
        radial-gradient(circle at 90% 25px, rgba(255, 200, 100, 0.9) 8px, transparent 8px);
    filter: blur(0.5px);
    animation: twinkle 2s infinite alternate;
    pointer-events: none;
    z-index: 1;
}

.string-lights::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(139, 69, 19, 0.3) 5%,
            rgba(139, 69, 19, 0.5) 50%,
            rgba(139, 69, 19, 0.3) 95%,
            transparent 100%);
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.8;
    }

    50% {
        opacity: 1;
    }
}

/* Players and timer container */
.players-timer-container {
    direction: 'row';
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    z-index: 2;
    margin-top: 35px;
}

/* ===== PLAYER WRAPPERS WITH CIRCULAR AVATARS ===== */
.player-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    max-width: 200px;
}

/* Left player - avatar on left, name on right */
.player-wrapper.player-left {
    flex-direction: row;
}

/* Right player - name on left, avatar on right */
.player-wrapper.player-right {
    flex-direction: row-reverse;
}

.player-avatar-circle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.3);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 107, 122, 0.1) 100%);
    box-shadow:
        0 6px 24px rgba(255, 107, 122, 0.3),
        inset 0 2px 6px rgba(255, 255, 255, 0.5);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s ease;
}

/* Current player highlighting */
.player-avatar-circle.current-player {
    border-color: #ffd700;
    border-width: 5px;
    /* Combined glow: Red base with Gold outer bloom */
    box-shadow:
        0 0 15px rgba(255, 71, 87, 0.6),
        0 0 30px rgba(255, 215, 0, 0.5),
        inset 0 0 10px rgba(255, 215, 0, 0.3);
    animation: currentPlayerPulse 2s ease-in-out infinite;
    z-index: 3;
}

@keyframes currentPlayerPulse {

    0%,
    100% {
        box-shadow:
            0 0 30px rgba(255, 215, 0, 0.8),
            0 0 50px rgba(255, 215, 0, 0.5),
            0 6px 24px rgba(255, 107, 122, 0.3),
            inset 0 2px 6px rgba(255, 255, 255, 0.5);
    }

    50% {
        box-shadow:
            0 0 40px rgba(255, 215, 0, 1),
            0 0 60px rgba(255, 215, 0, 0.7),
            0 8px 28px rgba(255, 107, 122, 0.4),
            inset 0 2px 6px rgba(255, 255, 255, 0.5);
    }
}

.player-avatar-circle::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.4) 50%, transparent 100%);
    pointer-events: none;
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
}

.player-name-box {
    background: linear-gradient(135deg, #ff6b7a 0%, #ff4757 100%);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    padding: 10px 20px;
    box-shadow:
        0 5px 16px rgba(255, 71, 87, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.3);
    min-width: 120px;
    transition: all 0.3s ease;
}

/* Text alignment based on player position */
.player-left .player-name-box {
    text-align: left;
}

.player-right .player-name-box {
    text-align: right;
}

/* Current player name box highlighting */
.player-name-box.current-player {
    border-color: #ffd700;
    background: linear-gradient(135deg, #ff4757 0%, #ff2e40 100%);
    /* Slightly deeper red when active */
    box-shadow:
        0 0 20px rgba(255, 215, 0, 0.4),
        0 5px 15px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
    /* Subtle lift */
}

.player-name-text {
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    margin-bottom: 2px;
}

.player-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ===== TIMER WITH ROMANTIC STYLING ===== */
.timer-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.timer-label {
    font-size: 1rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow:
        0 0 8px rgba(255, 215, 0, 0.8),
        0 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
}

.timer {
    font-size: 2.2rem;
    font-weight: bold;
    color: #ffd700;
    background: linear-gradient(135deg, rgba(139, 0, 0, 0.85) 0%, rgba(180, 0, 0, 0.85) 100%);
    backdrop-filter: blur(8px);
    border: 3px solid rgba(255, 215, 0, 0.6);
    border-radius: 16px;
    padding: 12px 28px;
    box-shadow:
        0 0 25px rgba(255, 215, 0, 0.5),
        inset 0 2px 6px rgba(255, 215, 0, 0.2),
        0 6px 16px rgba(0, 0, 0, 0.4);
    font-family: 'Courier New', monospace;
    min-width: 150px;
    text-align: center;
    text-shadow:
        0 0 12px rgba(255, 215, 0, 0.8),
        0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ===== GAME BOARD - SIDE-BY-SIDE LAYOUT (DESKTOP) ===== */
.game-board {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px 20px 20px;
    height: calc(100vh - 200px);
    /* Full height minus header */
    max-height: calc(100vh - 200px);
    overflow: hidden;
}

.game-board-flex {
    display: flex;
    flex-direction: row-reverse;
    /* Heart on right, puzzle on left */
    gap: 20px;
    width: 100%;
    flex: 1;
    overflow: hidden;
}

/* Heart Display Area (Right side on desktop) */
.heart-display-area {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.heart-outline-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1 / 0.87;
    /* 600/524 ratio from SVG */
}

/* Complete Heart SVG */
.heart-complete {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* Outline stroke for the complete heart */
.heart-complete::before {
    content: '';
    position: absolute;
    inset: -3px;
    border: 4px solid rgba(139, 0, 0, 0.6);
    border-radius: 50%;
    pointer-events: none;
}

.heart-complete.show {
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
        filter: drop-shadow(0 8px 24px rgba(255, 71, 87, 0.6));
    }

    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 12px 32px rgba(255, 71, 87, 0.8));
    }
}

/* ===== PUZZLE PIECES BOX (Left side on desktop) ===== */
.puzzle-box {
    flex: 0 0 450px;
    background: linear-gradient(135deg,
            rgba(255, 192, 203, 0.35) 0%,
            rgba(255, 182, 193, 0.35) 100%);
    backdrop-filter: blur(15px);
    border: 3px solid rgba(255, 215, 0, 0.5);
    border-radius: 25px;
    padding: 20px;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.3),
        inset 0 2px 8px rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.puzzle-box::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 25px;
    padding: 2px;
    background: linear-gradient(135deg,
            rgba(255, 215, 0, 0.6) 0%,
            rgba(255, 140, 0, 0.6) 50%,
            rgba(255, 215, 0, 0.6) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.puzzle-box-inner {
    background: rgba(255, 192, 203, 0.25);
    border-radius: 18px;
    padding: 15px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* Ensure scrollbar appears when needed */
    max-height: 100%;
}

.puzzle-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    width: 100%;
    padding: 5px;
}

.puzzle-container .puzzle-piece {
    width: 100%;
    aspect-ratio: 1;
    max-width: 140px;
    justify-self: center;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Large Desktop (1400px+) - Optimal layout */
@media (min-width: 1400px) {
    .game-board-flex {
        gap: 40px;
    }

    .puzzle-box {
        flex: 0 0 450px;
    }

    .heart-outline-container {
        max-width: 600px;
    }
}

/* Desktop to Tablet (1024px - 1399px) */
@media (max-width: 1399px) {
    .puzzle-box {
        flex: 0 0 380px;
    }

    .heart-outline-container {
        max-width: 480px;
    }
}

/* Tablet Portrait and below (< 1024px) - Switch to vertical stack */
@media (max-width: 1023px) {
    .game-screen {
        height: auto;
        max-height: none;
        overflow-y: auto;
    }

    .game-board {
        height: auto;
        max-height: none;
        padding-bottom: 30px;
    }

    .game-board-flex {
        flex-direction: column;
        /* Stack vertically */
    }

    .heart-display-area {
        order: 1;
        /* Heart on top */
        min-height: 350px;
        padding: 15px;
    }

    .puzzle-box {
        order: 2;
        /* Puzzle below */
        flex: none;
        width: 100%;
        max-width: 500px;
        margin: 0 auto;
    }

    .heart-outline-container {
        max-width: 400px;
    }

    .timer {
        font-size: 2rem;
        padding: 10px 24px;
        min-width: 130px;
    }
}

/* Mobile Landscape and Tablet (768px - 1023px) */
@media (max-width: 1023px) and (min-width: 768px) {
    .players-timer-container {
        margin-top: 30px;
    }

    /* .player-avatar-circle {
        width: 90px;
        height: 90px;
    } */
}

/* Mobile Portrait (< 768px) */
@media (max-width: 767px) {
    .game-header {
        padding: 12px 15px 20px 15px;
    }

    .players-timer-container {
        flex-direction: column;
        gap: 15px;
        margin-top: 25px;
    }

    /* Keep horizontal layout on mobile too */
    .player-wrapper {
        max-width: 100%;
        width: 100%;
        justify-content: center;
    }

    /* Player 1 stays left-aligned */
    .player-wrapper.player-left {
        flex-direction: row;
    }

    /* Player 2 stays right-aligned */
    .player-wrapper.player-right {
        flex-direction: row-reverse;
    }

    .player-avatar-circle {
        width: 75px;
        height: 75px;
        border-width: 3px;
    }

    .player-name-box {
        min-width: 110px;
        padding: 8px 16px;
        border-width: 2px;
    }

    .player-name-text {
        font-size: 1rem;
    }

    .player-label {
        font-size: 0.75rem;
    }

    .timer-wrapper {
        order: -1;
        margin-bottom: 8px;
    }

    .timer {
        font-size: 1.8rem;
        padding: 8px 20px;
        min-width: 120px;
        border-width: 2px;
    }

    .timer-label {
        font-size: 0.9rem;
    }

    .heart-display-area {
        min-height: 300px;
    }

    .heart-outline-container {
        max-width: 350px;
    }

    .puzzle-box {
        padding: 16px;
        max-height: 400px;
        /* Limit height on mobile */
    }

    .puzzle-box-inner {
        padding: 14px;
    }

    .puzzle-container {
        gap: 12px;
    }

    .string-lights {
        height: 45px;
    }
}

/* Small Mobile (< 480px) */
@media (max-width: 479px) {
    .player-avatar-circle {
        width: 65px;
        height: 65px;
    }

    .player-name-box {
        padding: 6px 14px;
        min-width: 100px;
    }

    .player-name-text {
        font-size: 0.95rem;
    }

    .timer {
        font-size: 1.6rem;
        padding: 7px 18px;
        min-width: 110px;
    }

    .heart-outline-container {
        max-width: 300px;
    }

    .puzzle-box {
        padding: 14px;
        border-radius: 20px;
    }

    .puzzle-box-inner {
        padding: 12px;
    }

    .puzzle-container {
        gap: 10px;
    }

    .string-lights {
        height: 40px;
        background-image:
            radial-gradient(circle at 15% 22px, rgba(255, 200, 100, 0.9) 6px, transparent 6px),
            radial-gradient(circle at 35% 18px, rgba(255, 150, 150, 0.9) 6px, transparent 6px),
            radial-gradient(circle at 50% 22px, rgba(255, 200, 100, 0.9) 6px, transparent 6px),
            radial-gradient(circle at 65% 18px, rgba(255, 100, 100, 0.9) 6px, transparent 6px),
            radial-gradient(circle at 85% 22px, rgba(255, 200, 100, 0.9) 6px, transparent 6px);
    }
}

/* Landscape Orientation on Mobile */
@media (max-height: 600px) and (orientation: landscape) {
    .game-screen {
        height: auto;
        max-height: none;
    }

    .game-header {
        padding: 8px 15px 15px 15px;
    }

    .players-timer-container {
        margin-top: 20px;
    }

    .player-avatar-circle {
        width: 55px;
        height: 55px;
    }

    .timer {
        font-size: 1.4rem;
        padding: 6px 14px;
    }

    .heart-display-area {
        min-height: 250px;
    }

    .puzzle-box-inner {
        max-height: 300px;
    }
}