header {
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.25);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 10;
    height: 80px;
}

.score-board {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.score-label { font-size: 0.7rem; opacity: 0.7; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 2px; }
.score-val { font-size: 2.5rem; font-weight: 900; line-height: 1; }

.p1-score { color: var(--accent-p1); text-align: left; }
.p2-score { color: var(--accent-p2); text-align: right; }

.main-game {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    background: radial-gradient(circle, var(--table-pattern) 0%, var(--table-color) 100%);
    box-shadow: inset 0 0 150px rgba(0,0,0,0.6);
    width: 100%;
    padding: 10px;
}

/* --- Feedback Area (Above Timer) --- */
#feedback-area {
    width: 100%;
    text-align: center;
    z-index: 20;
    margin-bottom: 10px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.toast {
    display: inline-block;
    padding: 8px 30px;
    background: rgba(0,0,0,0.9);
    color: white;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: 800;
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 3px solid transparent;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
    max-width: 90%;
}

.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast.p1 { border-left: 6px solid var(--accent-p1); }
.toast.p2 { border-right: 6px solid var(--accent-p2); }
.toast.good { background: #27ae60; border-color: #2ecc71; }
.toast.bad { background: #c0392b; border-color: #e74c3c; }
.toast.neutral { background: #7f8c8d; border-color: #bdc3c7; }

/* --- Timer Bar --- */
.timer-container {
    width: 90%;
    max-width: 600px;
    height: 10px;
    background: rgba(0,0,0,0.6);
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.2);
    position: relative;
}

.timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #f1c40f, #f39c12);
    transform-origin: left;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px #f1c40f;
}

/* --- Cards & Layout --- */
.play-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    position: relative;
    perspective: 1000px;
    width: 100%;
}

/* VS Badge */
.vs-badge {
    font-size: 1.5rem;
    font-weight: 900;
    font-style: italic;
    color: rgba(255,255,255,0.3);
    text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
    z-index: 5;
}

.card {
    /* Desktop Fixed Size */
    width: 240px; 
    height: 340px;
    
    background-color: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-color);
    position: relative;
    transition: transform 0.1s, box-shadow 0.2s;
    border-bottom: 6px solid #dcdcdc;
    
    /* Touch Interaction */
    touch-action: manipulation; /* Improves touch response */
    cursor: pointer;
    
    font-family: var(--font-main);
    font-weight: 700;
    line-height: 1;
    overflow: hidden;
}

.card:active {
    transform: scale(0.98);
    border-bottom-width: 2px;
}

/* Label inside card */
.card::before {
    content: attr(data-type);
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: #bdc3c7;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 800;
    pointer-events: none;
}

/* Sizing Strategies */

/* Desktop Standard */
.card .char-content {
    font-size: 10rem; 
    letter-spacing: -0.05em; 
    transform-origin: center;
    display: block;
    pointer-events: none; /* Prevents selection */
}

/* Desktop Compact */
.card.compact .char-content {
    font-size: 6.5rem; 
    letter-spacing: 0.05em; 
}

/* Card States */
.card.match {
    box-shadow: 0 0 60px var(--success-color);
    border: 5px solid var(--success-color);
    background: #fff;
    transform: translateY(-5px);
}

.card.fail {
    box-shadow: 0 0 60px var(--fail-color);
    border: 5px solid var(--fail-color);
    background: #f0f0f0;
    opacity: 0.9;
    transform: translateY(2px);
}

/* Animations */
@keyframes popIn {
    0% { transform: scale(0.9) translateY(30px); opacity: 0; }
    70% { transform: scale(1.02) translateY(-5px); opacity: 1; }
    100% { transform: scale(1) translateY(0); }
}

.pop-anim {
    animation: popIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes shakeHard {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px) rotate(-3deg); }
    40% { transform: translateX(10px) rotate(3deg); }
    60% { transform: translateX(-8px) rotate(-2deg); }
    80% { transform: translateX(8px) rotate(2deg); }
}

.shake-anim {
    animation: shakeHard 0.4s ease-in-out;
    border-bottom-color: #e74c3c !important;
}

footer {
    padding: 10px;
    text-align: center;
    background: rgba(0,0,0,0.2);
    font-size: 0.7rem;
    color: #bdc3c7;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.control-hint {
    display: flex;
    align-items: center;
    gap: 8px;
}

.divider { width: 2px; height: 20px; background: rgba(255,255,255,0.2); }

.single-player-mode #board-p2, 
.single-player-mode #vs-icon, 
.single-player-mode #footer-divider, 
.single-player-mode #hint-p2 {
    display: none !important;
}

.single-player-mode footer {
    display: none;
}

.single-player-mode .play-area {
    justify-content: center;
    gap: 30px;
}

/* Adjust Player 1 hint for Single Player */
.single-player-mode #hint-p1 {
    width: 100%;
    text-align: center;
}

#live-timer {
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(241, 196, 15, 0.3);
    min-width: 80px; /* Prevents layout shifting */
}

/* Make the target indicator area more prominent in single player */
.single-player-mode .target-indicator {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--success-color);
    padding: 5px 15px;
}

/* Hidden by default */
.swipe-bar {
    display: none;
    margin-top: 20px;
    user-select: none;
}

/* Desktop + single-player only */
body.single-player-mode.desktop .swipe-bar {
    display: block;
}

.swipe-track {
    position: relative;
    width: 320px;
    height: 48px;
    margin: 0 auto;
    background: #222;
    border-radius: 24px;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.6);
}

.swipe-label {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    line-height: 48px;
    text-align: center;
    font-weight: bold;
    opacity: 0.5;
    cursor: pointer;
    z-index: 2;
    user-select: none;
}

.swipe-label.left {
    left: 0;
    color: #e74c3c;
    pointer-events: auto;
}

.swipe-label.right {
    right: 0;
    color: #2ecc71;
    pointer-events: auto;
}

.swipe-handle {
    position: absolute;
    top: 4px;
    left: 50%;                 /* ✅ ADD */
    width: 40px;
    height: 40px;
    background: #f1c40f;
    border-radius: 50%;
    cursor: grab;
    z-index: 3;
    transition: left 0.2s ease, transform 0.2s ease;
}

.swipe-handle:hover {
    box-shadow: 0 0 10px rgba(241,196,15,0.6);
}

/* --- Mobile Responsive Tweaks --- */
@media (max-width: 768px) {
    h1 { font-size: 2.5rem; }
    .score-val { font-size: 2rem; }
    .score-label { font-size: 0.6rem; }
    .toast { font-size: 1rem; }
    
    /* Use Viewport Widths to scale cards to fit side-by-side */
    .card {
        width: 42vw; 
        height: 55vw; /* Maintain aspect roughly */
        border-bottom-width: 4px;
    }

    .card:active {
        transform: scale(0.96);
    }

    /* Font scaling based on screen width */
    .card .char-content {
        font-size: 15vw;
        letter-spacing: 0;
    }

    .card.compact .char-content {
        font-size: 11vw;
        letter-spacing: 0.05em;
    }

    .vs-badge {
        font-size: 1.2rem;
        margin: 0 5px;
    }

    .timer-container {
        margin-bottom: 15px;
    }
}