/* Arcade/Games Common Styles */

.arcade-main {
    display: flex;
    flex-direction: column;
}

.arcade-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
}

/* Arcade Hero */
.arcade-hero {
    text-align: center;
    margin-bottom: 40px;
}

.arcade-title {
    font-family: var(--font-display);
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #06b6d4, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.arcade-subtitle {
    color: var(--secondary);
    font-size: 16px;
}

/* Game Grid */
.game-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

@media (min-width: 600px) {
    .game-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 900px) {
    .game-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1200px) {
    .game-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.game-grid.hidden {
    display: none;
}

/* Game Cards */
.game-card {
    position: relative;
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.9) 0%, rgba(20, 20, 30, 0.95) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.game-card:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: rgba(6, 182, 212, 0.4);
    box-shadow: 0 12px 40px rgba(6, 182, 212, 0.15), 0 0 0 1px rgba(6, 182, 212, 0.2);
}

.game-card-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(6, 182, 212, 0.6), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.game-card:hover .game-card-glow {
    opacity: 1;
}

.game-card-icon {
    font-size: 48px;
    margin-bottom: 16px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.game-card-content h3 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 6px;
}

.game-card-content p {
    font-size: 14px;
    color: var(--secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.game-card-reward {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.game-card-reward .reward-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);
}

.game-card-reward .reward-value {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.game-card-play {
    display: inline-flex;
    align-items: center;
    padding: 10px 20px;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(6, 182, 212, 0.08));
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 12px;
    color: #06b6d4;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.game-card:hover .game-card-play {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.25), rgba(6, 182, 212, 0.15));
    border-color: rgba(6, 182, 212, 0.5);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.2);
}



/* Game Stage Toolbar (Back Button Container) */
.game-stage-toolbar {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
}

/* Back to Arcade Button */
.back-to-arcade {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: var(--secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.back-to-arcade:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Legacy game-tabs (for compatibility) */
.game-tabs {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.game-tabs.single {
    justify-content: center;
}

.game-tab {
    padding: 14px 24px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--secondary);
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.game-tab:hover {
    border-color: var(--border-highlight);
    color: #fff;
    transform: scale(1.02);
}

.game-tab.active {
    background: rgba(6, 182, 212, 0.12);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.15);
}

/* Mobile responsive */
@media (max-width: 820px) {
    .arcade-container {
        padding: 0;
    }

    .arcade-title {
        font-size: 28px;
    }

    .game-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .game-card {
        padding: 16px 20px;
        display: grid;
        grid-template-columns: 48px 1fr auto;
        grid-template-areas: "icon content play";
        align-items: center;
        gap: 16px;
    }

    .game-card-icon {
        grid-area: icon;
        font-size: 32px;
        margin-bottom: 0 !important;
    }

    .game-card-content {
        grid-area: content;
        text-align: left;
    }

    .game-card-content h3 {
        font-size: 18px;
        margin-bottom: 2px;
    }

    .game-card-content p {
        font-size: 13px;
        margin-bottom: 0;
        opacity: 0.8;
    }

    .game-card-play {
        grid-area: play;
        padding: 8px 16px;
        font-size: 13px;
    }
}

.game-stage {
    width: 100%;
    opacity: 0;
    transition: opacity 0.4s ease-out;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.game-stage.visible {
    opacity: 1;
}

.game-stage.hidden {
    display: none;
}

.game-stage.hidden+.game-prompt {
    display: block;
}

.game-stage:not(.hidden)+.game-prompt {
    display: none;
}

.stage-header {
    margin-bottom: 16px;
}

.stage-header h3 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
}

.stage-subtitle {
    color: var(--secondary);
    font-size: 14px;
    margin-top: 4px;
    font-weight: 500;
}

.game-community-stats {
    margin-top: 12px;
}

.community-win-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.15);
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 13px;
}

.win-icon {
    font-size: 14px;
}

.win-count {
    color: #ffd700;
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.win-label {
    color: var(--secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.pulse-highlight {
    animation: pulse-gold 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes pulse-gold {

    0%,
    100% {
        transform: scale(1);
        text-shadow: none;
    }

    50% {
        transform: scale(1.4);
        text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    }
}

.game-canvas {
    width: 100%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    position: relative;
}

/* Jigsaw specific styles - fullscreen */
.jigsaw-container {
    width: 100%;
    height: 100vh;
    position: relative;
    margin: 0;
    padding: 0;
}

.jigsaw-controls {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
}

.jigsaw-control-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    margin: 0;
}

.jigsaw-control-btn:hover {
    transform: scale(1.05);
}

.jigsaw-control-btn:active {
    transform: scale(0.98);
}

.jigsaw-generate-btn {
    background: rgba(6, 182, 212, 0.2);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.jigsaw-generate-btn:hover {
    background: rgba(6, 182, 212, 0.3);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.jigsaw-reference-btn {
    background: rgba(139, 92, 246, 0.2);
    border-color: #8b5cf6;
    color: #a78bfa;
}

.jigsaw-reference-btn:hover {
    background: rgba(139, 92, 246, 0.3);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.jigsaw-vote-btn {
    background: rgba(255, 215, 0, 0.15);
    border-color: rgba(255, 215, 0, 0.5);
    color: #ffd700;
}

.jigsaw-vote-btn:hover {
    background: rgba(255, 215, 0, 0.25);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.jigsaw-vacuum-btn {
    background: rgba(100, 200, 255, 0.15);
    border-color: rgba(100, 200, 255, 0.5);
    color: #64c8ff;
}

.jigsaw-vacuum-btn:hover {
    background: rgba(100, 200, 255, 0.25);
    box-shadow: 0 4px 12px rgba(100, 200, 255, 0.3);
}

.jigsaw-progress-indicator {
    background: rgba(74, 222, 128, 0.15);
    border-color: rgba(74, 222, 128, 0.5);
    color: #4ade80;
    cursor: default;
    font-family: var(--font-display);
    font-weight: 800;
    min-width: 50px;
    max-width: 70px;
    text-align: center;
    padding: 12px 16px;
}

.jigsaw-progress-indicator:hover {
    transform: none;
    background: rgba(74, 222, 128, 0.15);
}

/* Responsive jigsaw controls */
@media (max-width: 1199px) {
    .jigsaw-controls {
        top: 76px;
        /* Move below topbar (56px + 20px spacing) */
    }
}

@media (max-width: 768px) {
    .jigsaw-controls {
        gap: 8px;
        top: 76px;
    }

    .jigsaw-control-btn {
        padding: 10px 18px;
        font-size: 13px;
    }

    .jigsaw-progress-indicator {
        padding: 10px 12px;
        font-size: 13px;
        min-width: 45px;
        max-width: 60px;
    }
}

@media (max-width: 480px) {
    .jigsaw-controls {
        gap: 6px;
        top: 76px;
    }

    .jigsaw-control-btn {
        padding: 8px 14px;
        font-size: 12px;
    }

    .jigsaw-progress-indicator {
        padding: 8px 10px;
        font-size: 12px;
        min-width: 40px;
        max-width: 50px;
    }
}

/* Modal styles */
.jigsaw-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.jigsaw-modal.hidden {
    display: none;
    opacity: 0;
}

.jigsaw-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background: #1a1a1c;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--border-highlight);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}



.jigsaw-modal-content img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 6px;
    object-fit: contain;
}

.jigsaw-canvas {
    width: 100%;
    height: 100%;
    position: relative;
    padding: 0;
    overflow: hidden;
    border: none;
    border-radius: 0;
    background: #0a0a0c;
    /* Prevent browser default touch behaviors (zoom, scroll, etc.) */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.jigsaw-canvas canvas {
    display: block;
    width: 100%;
    height: 100%;
    /* Also disable touch actions on the canvas element itself */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.game-prompt {
    padding: 60px 24px;
    text-align: center;
    color: var(--secondary);
    font-size: 15px;
}

/* ====== GAME RESULT ====== */
.game-result {
    text-align: center;
    padding: 48px 32px;
}

.game-result h2 {
    font-family: var(--font-display);
    font-size: 36px;
    margin-bottom: 16px;
}

.game-result.win h2 {
    color: var(--accent-green);
}

.game-result.loss h2 {
    color: #ef4444;
}

.game-result.draw h2 {
    color: #fbbf24;
}

.game-result .pax-earned {
    font-size: 24px;
    color: var(--accent-cyan);
    margin-bottom: 32px;
    font-weight: 600;
}

.game-result .btn {
    min-width: 180px;
}

/* ====== GAME COOLDOWN ====== */
.game-cooldown-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    width: 100%;
    padding: 40px;
    opacity: 0;
    animation: cooldownOverlayFadeIn 1s ease-out forwards;
}

@keyframes cooldownOverlayFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.game-cooldown-content {
    text-align: center;
    padding: 48px 32px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    max-width: 400px;
    width: 100%;
    opacity: 0;
    transform: translateY(-10px);
    animation: cooldownFadeIn 1s ease-out forwards;
}

@keyframes cooldownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-cooldown-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: cooldownPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(6, 182, 212, 0.4));
}

@keyframes cooldownPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.game-cooldown-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #fff;
}

.game-cooldown-message {
    color: var(--secondary);
    font-size: 15px;
    margin-bottom: 32px;
    line-height: 1.5;
}

.game-cooldown-timer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.game-cooldown-seconds {
    font-family: var(--font-display);
    font-size: 72px;
    font-weight: 700;
    color: var(--accent-cyan);
    text-shadow: 0 0 30px rgba(6, 182, 212, 0.6);
    line-height: 1;
    transition: all 0.2s ease;
    animation: cooldownCountdown 1s ease-in-out infinite;
}

@keyframes cooldownCountdown {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.game-cooldown-label {
    color: var(--secondary);
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Start overlay */
.start-overlay {
    text-align: center;
    padding: 20px;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .game-tabs {
        gap: 8px;
    }

    .game-tab {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* ====== RESPONSIVE GAME BOARDS (Match 3 / Word Search) ====== */
.match3-board-wrapper,
.ws-board-wrapper {
    width: 100%;
    max-width: 100vw;
    display: flex;
    justify-content: center;
    overflow: hidden;
    /* Prevent overflow */
    padding: 0 4px;
    /* Tiny padding */
    box-sizing: border-box;
}

.match3-canvas-container,
.ws-canvas-container {
    /* Use 625px on wide screens, scale down on narrow */
    width: min(625px, 100%);
    max-width: 100%;
    margin: 0 auto;
    aspect-ratio: 1 / 1;
    position: relative;
}

.match3-canvas-container canvas,
.ws-canvas-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    border-radius: 12px;
}