/* ============================================
   Back to Menu Button
   ============================================ */

.back-to-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.85);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 6px 12px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.back-to-menu-btn:hover,
.back-to-menu-btn:active {
    color: rgba(255, 255, 255, 1.0);
    background: rgba(0, 0, 0, 0.45);
}

.back-to-menu-btn .back-arrow {
    font-size: 1.1rem;
    line-height: 1;
}

/* ============================================
   Leave Game Confirmation Modal
   ============================================ */

.leave-game-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.leave-game-modal.hidden {
    display: none;
}

.leave-game-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.leave-game-dialog {
    position: relative;
    background: var(--dark-brown);
    border: 4px solid var(--primary-orange);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 320px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.leave-game-dialog h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: white;
    margin: 0 0 0.5rem;
}

.leave-game-dialog p {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 1.25rem;
    line-height: 1.4;
}

.leave-game-actions {
    display: flex;
    gap: 0.75rem;
}

.leave-game-actions .btn {
    flex: 1;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    font-weight: 700;
}

/* ============================================
   Scoreboard - Arcade Style
   ============================================ */

.scoreboard {
    display: grid;
    grid-template-columns: 1fr 80px 1fr;
    background: var(--dark-brown);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--space-sm);
    border: 4px solid var(--dark-brown);
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    position: relative;
}

.game-info {
    /* sized by grid */
}

.player-score {
    background: linear-gradient(180deg, var(--primary-orange) 0%, var(--primary-orange-dark) 100%);
    /* NO border-radius - parent overflow:hidden clips corners */
}

.opponent-score {
    background: linear-gradient(180deg, var(--accent-cyan) 0%, var(--accent-cyan-dark) 100%);
    /* NO border-radius - parent overflow:hidden clips corners */
}

.player-label {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.05em;
    /* Truncate long names to prevent score box size differences */
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score {
    font-family: var(--font-display);
    font-size: 2.75rem;
    color: white;
    line-height: 1;
    text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
    position: relative;
}

/* Floating score change animation - positioned to be visible */
.score-change {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 900;
    color: #FFD700;
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(255, 215, 0, 0.6);
    animation: scoreFloat 1.4s ease-out forwards;
    pointer-events: none;
    z-index: 100;
}

@keyframes scoreFloat {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.5);
    }
    30% {
        opacity: 1;
        transform: translate(-50%, -80%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -120%) scale(0.9);
    }
}

/* Score box effects on score change */
.score-box.just-scored {
    animation: scorePulse 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.score-box.just-scored .score-value {
    animation: scoreNumberPop 0.4s ease-out 0.3s;
}

@keyframes scorePulse {
    0%, 100% { transform: scale(1); }
    40% { transform: scale(1.08); }
}

@keyframes scoreNumberPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Glow ring effect when scoring */
.score-box.just-scored::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    border: 3px solid currentColor;
    animation: scoreRing 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes scoreRing {
    0% {
        transform: scale(0.9);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

/* Cards Counter - Center */
.game-info {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    background: var(--dark-brown);
    /* Width is fixed at 80px by grid-template-columns */
}

.cards-counter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.cards-label {
    font-family: var(--font-body);
    font-size: 0.55rem;
    font-weight: 800;
    color: var(--pop-yellow);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.cards-value {
    font-family: var(--font-display);
    font-size: 2.25rem;
    color: white;
    line-height: 1;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
}

.half-indicator {
    font-family: var(--font-body);
    font-size: 0.55rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Low cards warning */
.cards-counter.low-cards .cards-label,
.cards-counter.low-cards .half-indicator {
    color: var(--danger-red);
}

.cards-counter.low-cards .cards-value {
    color: var(--danger-red);
    animation: pulse-urgent 0.5s ease-in-out infinite;
}

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

/* ============================================
   Game Board
   ============================================ */

.game-board {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Possession Bar - combined with ball position */
.possession-bar {
    background: linear-gradient(90deg, var(--primary-orange) 0%, var(--pop-yellow) 50%, var(--primary-orange) 100%);
    background-size: 200% 100%;
    animation: shimmer 3s ease-in-out infinite;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    text-align: center;
    border: 3px solid var(--primary-orange-dark);
    box-shadow: var(--shadow-md);
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.possession-bar span {
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 1rem;
    color: var(--dark-brown);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.possession-bar.opponent-turn {
    background: linear-gradient(90deg, var(--accent-cyan) 0%, #80DEEA 50%, var(--accent-cyan) 100%);
    background-size: 200% 100%;
    border-color: var(--accent-cyan-dark);
}

.possession-bar.waiting {
    background: linear-gradient(90deg, #9E9E9E 0%, #BDBDBD 50%, #9E9E9E 100%);
    background-size: 200% 100%;
    border-color: #757575;
}

/* Ball Position Indicator */
.ball-position-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark-brown);
    padding: var(--space-xs) var(--space-md);
    background: rgba(255, 107, 0, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 0;
}

.ball-icon {
    font-size: 1.25rem;
    animation: bounce-ball 1s ease-in-out infinite;
}

@keyframes bounce-ball {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.ball-separator {
    color: var(--court-wood-dark);
}

/* ============================================
   Play Area
   ============================================ */

.play-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: white;
    border: 4px solid var(--court-wood);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    min-height: 180px;
    background-image:
        linear-gradient(180deg, transparent 0%, transparent 90%, rgba(255, 107, 0, 0.1) 100%);
}

.played-card-label,
.slot-label {
    display: none;
}

/* Card Display (played card area) - SAME SIZE as hand cards */
.card-display {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: var(--radius-card);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px dashed var(--court-wood);
    background: var(--bg-tan);
    position: relative;
}

.card-display::before {
    content: '🏀';
    font-size: 2rem;
    opacity: 0.5;
    animation: slot-pulse 2s ease-in-out infinite;
}

@keyframes slot-pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.7; }
}

.card-display.has-card::before {
    display: none;
}

.card-display.has-card {
    border: none;
    background: transparent;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Text displayed in card area */
.played-card-name {
    font-family: var(--font-display);
    font-size: 1.1rem;
    text-transform: uppercase;
    color: var(--text-dark);
    text-align: center;
    opacity: 0;
    animation: fade-in-text 0.4s ease-out 0.6s forwards;
}

.played-card-points {
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-orange);
    opacity: 0;
    animation: fade-in-text 0.4s ease-out 0.8s forwards;
}

@keyframes fade-in-text {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* Counter card animation */
.card-display.counter-card {
    animation: counter-pulse 0.5s ease-in-out 2;
}

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

/* Counter card text - white text, immediately visible on purple background */
.card-display.counter-card .played-card-name,
.card-display.counter-card .played-card-points {
    color: white;
    opacity: 1;
    animation: none;
}

/* ============================================
   Dice - Arcade Style
   ============================================ */

.dice-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.dice-container {
    display: flex;
    gap: 1rem;
}

.die {
    width: 55px;
    height: 55px;
    background: linear-gradient(145deg, #FFFFFF 0%, #E0E0E0 100%);
    border: 4px solid var(--dark-brown);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--dark-brown);
    box-shadow: 4px 4px 0 var(--dark-brown);
}

.die.rolling {
    animation: dice-roll 0.1s ease-in-out infinite;
}

@keyframes dice-roll {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(10deg) scale(1.05); }
    75% { transform: rotate(-10deg) scale(1.05); }
}

.dice-result {
    font-family: var(--font-display);
    font-size: 1.5rem;
    text-align: center;
}

.dice-result.success {
    color: var(--success-green);
    animation: result-pop 0.3s ease-out;
}

.dice-result.miss {
    color: var(--danger-red);
}

@keyframes result-pop {
    0% { transform: scale(0.5); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ============================================
   Foul Shots, Counter, Defense Areas
   ============================================ */

.foul-shot-area {
    text-align: center;
}

#foul-shot-btn {
    animation: btn-glow-pulse 1.2s ease-in-out infinite;
    background: linear-gradient(180deg, var(--success-green) 0%, #1B5E20 100%);
    border-color: #1B5E20;
    box-shadow: 6px 6px 0 #1B5E20, 0 0 8px rgba(76, 175, 80, 0.6), 0 0 16px rgba(76, 175, 80, 0.4);
}

#foul-shot-btn:disabled {
    animation: none;
    filter: none;
    opacity: 0.5;
}

@keyframes btn-glow-pulse {
    0%, 100% {
        box-shadow: 6px 6px 0 #1B5E20, 0 0 3px rgba(76, 175, 80, 0.4), 0 0 6px rgba(76, 175, 80, 0.2);
        filter: brightness(1);
    }
    50% {
        box-shadow: 6px 6px 0 #1B5E20, 0 0 10px rgba(76, 175, 80, 0.7), 0 0 20px rgba(76, 175, 80, 0.5), 0 0 28px rgba(76, 175, 80, 0.3);
        filter: brightness(1.1);
    }
}

.foul-shot-info {
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--pop-purple);
}

.counter-area {
    text-align: center;
}

.counter-area p {
    font-weight: 700;
    margin-bottom: 1rem;
}

.counter-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.defense-area {
    text-align: center;
}

.defense-area p {
    font-weight: 700;
    margin-bottom: 1rem;
}

/* ============================================
   Action Log
   ============================================ */

.action-log {
    background: white;
    border: 3px solid var(--court-wood);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    overflow: hidden;
    max-height: 100px;
    transition: max-height 0.3s ease;
}

.action-log.expanded {
    max-height: 50vh;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    min-height: 48px;
    background: var(--bg-tan);
    cursor: pointer;
    border-bottom: 2px solid var(--court-wood);
    /* Better touch target */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    user-select: none;
    transition: background-color 0.15s ease;
}

.log-header:hover {
    background: var(--bg-cream);
}

.log-header:active {
    background: var(--court-wood-light);
}

.log-header h3 {
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-medium);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: none;
}

.log-toggle-icon {
    color: var(--text-medium);
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.action-log.expanded .log-toggle-icon {
    transform: rotate(180deg);
}

.log-content {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    max-height: calc(50vh - 40px);
    overflow-y: auto;
}

.log-entry {
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--bg-tan);
    color: var(--text-medium);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.highlight {
    color: var(--primary-orange);
    font-weight: 700;
}

.log-entry.score {
    color: var(--success-green);
    font-weight: 700;
}

/* ============================================
   Decision Mode - Dim distractions during choices
   ============================================ */

.game-screen.decision-mode .hand-area {
    opacity: 0.3;
    pointer-events: none;
    filter: blur(1px);
    transition: opacity 0.3s, filter 0.3s;
}

.game-screen.decision-mode .play-area {
    position: relative;
    z-index: 10;
}

/* ============================================
   Active Turn Indicator
   Uses filter only - no box-shadow that would affect visual size
   ============================================ */

.score-box.active-turn {
    animation: turn-pulse 1.5s ease-in-out infinite;
}

@keyframes turn-pulse {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.15);
    }
}
