/**
 * Bingo game specific styles
 * Extends base.css for game-specific functionality
 */

* {
    -webkit-tap-highlight-color: transparent;
}

/* Compact header for bingo page */
.site-header--compact {
    padding: var(--spacing-md);
}

/* Main bingo area */
.bingo-main {
    text-align: center;
    padding: var(--spacing-md);
    max-width: 600px;
    margin: 0 auto;
}

/* Bingo card container - looks like a physical bingo card */
.bingo-card-wrapper {
    background: linear-gradient(145deg, var(--color-gray-800), var(--color-gray-900));
    border: 3px solid var(--color-primary);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-md);
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    position: relative;
}

/* Card header strip */
.bingo-card-wrapper::before {
    content: 'B I N G O';
    display: block;
    text-align: center;
    font-size: var(--font-size-xl);
    font-weight: 800;
    letter-spacing: 1.5rem;
    padding: var(--spacing-sm) 0;
    margin-bottom: var(--spacing-sm);
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary), var(--color-primary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    border-bottom: 2px solid var(--color-gray-700);
}

#bingo-card {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: clamp(4px, 1.2vw, 8px);
    perspective: 1000px;
}

.cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
    border: none;
    border-radius: clamp(4px, 1.5vw, 12px);
    cursor: pointer;
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
    aspect-ratio: 1 / 1;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    font-size: clamp(11px, 3.2vw, 14px);
    font-weight: 600;
    color: #1a1a2e;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    touch-action: manipulation;
}

.cell:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

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

.cell.marked:active {
    transform: rotateY(180deg) scale(0.95);
}

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

.cell .front, .cell .back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border-radius: inherit;
    line-height: 1.1;
    word-break: break-word;
    hyphens: auto;
}

.cell .front {
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
}

.cell .back {
    transform: rotateY(180deg);
    background: linear-gradient(145deg, #00d26a, #00b058);
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.cell.free-space .front,
.cell.free-space .back {
    background: linear-gradient(145deg, #ffd700, #ffaa00);
    color: #1a1a2e;
    font-weight: 800;
}

/* Bingo celebration overlay */
#bingo-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

#bingo-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: clamp(4rem, 20vw, 10rem);
    font-weight: 900;
    color: transparent;
    background: linear-gradient(45deg, #ff0000, #ff7700, #ffdd00, #00ff00, #00ddff, #ff00ff);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow:
        0 0 20px rgba(255, 255, 255, 0.5),
        0 0 40px rgba(255, 255, 255, 0.3),
        0 0 60px rgba(255, 255, 255, 0.2);
    z-index: 1001;
    pointer-events: none;
    opacity: 0;
    letter-spacing: 0.1em;
    filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.8));
}

#bingo-message.show {
    animation: bingoAppear 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               bingoGlow 2s ease-in-out infinite 1s,
               bingoRainbow 3s linear infinite;
}

@keyframes bingoAppear {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-20deg);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2) rotate(5deg);
        opacity: 1;
    }
    75% {
        transform: translate(-50%, -50%) scale(0.9) rotate(-2deg);
    }
    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes bingoGlow {
    0%, 100% {
        filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.8)) brightness(1);
    }
    50% {
        filter: drop-shadow(0 0 60px rgba(255, 100, 100, 1)) brightness(1.2);
    }
}

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

.button-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

/* Bingo buttons extend the base .btn class from components.css */
#reset-button, #undo-button {
    padding: clamp(12px, 3vw, 16px) clamp(24px, 6vw, 40px);
    font-size: clamp(14px, 4vw, 18px);
    border-radius: 50px;
    touch-action: manipulation;
}

#reset-button {
    background: linear-gradient(145deg, #ff6b6b, #ee5a5a);
    box-shadow: 0 4px 15px rgba(238, 90, 90, 0.4);
    display: none;
}

#reset-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(238, 90, 90, 0.6);
}

#reset-button:active {
    transform: translateY(0);
}

#reset-button.visible {
    display: inline-block;
    animation: buttonAppear 0.5s ease-out;
}

#undo-button {
    background: linear-gradient(145deg, #6b7fd6, #5a6bc4);
    box-shadow: 0 4px 15px rgba(90, 107, 196, 0.4);
    display: none;
}

#undo-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(90, 107, 196, 0.6);
}

#undo-button:active {
    transform: translateY(0);
}

#undo-button.visible {
    display: inline-block;
    animation: buttonAppear 0.5s ease-out;
}

#undo-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

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


/* Confetti particle */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    pointer-events: none;
    z-index: 999;
    animation: confettiFall linear forwards;
}

.confetti.square {
    border-radius: 2px;
}

.confetti.circle {
    border-radius: 50%;
}

.confetti.ribbon {
    width: 8px;
    height: 20px;
    border-radius: 2px;
}

@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg) scale(0.5);
    }
}

/* Firework burst */
.firework-burst {
    position: fixed;
    pointer-events: none;
    z-index: 998;
}

.firework-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: fireworkExplode 1s ease-out forwards;
}

@keyframes fireworkExplode {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* Star burst */
.star {
    position: fixed;
    pointer-events: none;
    z-index: 997;
    font-size: 30px;
    animation: starBurst 1.5s ease-out forwards;
}

@keyframes starBurst {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.5) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(0) rotate(360deg);
        opacity: 0;
    }
}

/* Screen flash effect */
.screen-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    pointer-events: none;
    z-index: 1002;
    animation: flash 0.3s ease-out forwards;
}

@keyframes flash {
    0% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* Winning line highlight */
.cell.winning-cell {
    animation: winPulse 0.5s ease-in-out infinite alternate;
}

@keyframes winPulse {
    from {
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.5), 0 4px 15px rgba(0, 0, 0, 0.2);
    }
    to {
        box-shadow: 0 0 25px rgba(255, 215, 0, 1), 0 0 40px rgba(255, 215, 0, 0.6);
    }
}

/* Mobile: small gaps */
@media (max-width: 768px) {
    .bingo-main {
        padding: var(--spacing-md) 0;
        max-width: 100%;
    }
}

/* Responsive adjustments */
@media (max-width: 400px) {
    .bingo-main {
        padding: var(--spacing-sm) 0;
    }

    .bingo-card-wrapper {
        padding: var(--spacing-sm);
    }

    .bingo-card-wrapper::before {
        font-size: var(--font-size-base);
        letter-spacing: 1rem;
    }

    #bingo-card {
        gap: 3px;
    }

    .cell {
        font-size: clamp(10px, 3.5vw, 13px);
        border-radius: 3px;
    }

    .cell .front, .cell .back {
        padding: 1px;
    }
}

@media (min-width: 400px) and (max-width: 599px) {
    #bingo-card {
        gap: 4px;
    }

    .cell {
        font-size: clamp(11px, 3.2vw, 14px);
    }
}

@media (min-width: 600px) {
    .cell {
        font-size: 14px;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .site-header--compact {
        padding: var(--spacing-xs);
    }

    .bingo-card-wrapper {
        padding: var(--spacing-sm);
    }

    .bingo-card-wrapper::before {
        padding: var(--spacing-xs) 0;
        margin-bottom: var(--spacing-xs);
    }
}
