/* Play 2 Bux - Arcade Kids Edition */
@import url('https://fonts.googleapis.com/css2?family=Luckiest+Guy&family=Space+Grotesk:wght@400;500;600;700&family=Archivo+Black&display=swap');

:root {
    --bg-1: #0b0f2a;
    --bg-2: #101b3d;
    --bg-3: #0b1220;
    --card: rgba(255, 255, 255, 0.96);
    --card-strong: rgba(255, 255, 255, 0.92);
    --ink-1: #0f172a;
    --ink-2: #475569;
    --accent-pink: #ff4d8d;
    --accent-yellow: #ffd338;
    --accent-blue: #3bb6ff;
    --accent-purple: #7c5cff;
    --accent-green: #34d399;
    --ring: 0 0 0 3px rgba(59, 182, 255, 0.35);
    --space-1: clamp(6px, 1.2vw, 12px);
    --space-2: clamp(10px, 2vw, 18px);
    --space-3: clamp(14px, 2.6vw, 24px);
    --radius-card: clamp(16px, 2.2vw, 26px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html,
body {
    width: 100%;
    height: auto;
    min-height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

body {
    color: var(--ink-1);
    font-family: 'Space Grotesk', sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    touch-action: manipulation;
    background: transparent;
    min-height: 100vh;
    padding: var(--space-1);
}

.claim-page {
    align-items: flex-start;
    padding: clamp(16px, 4vw, 32px);
}

/* iOS Redirect Popup */
.ios-popup {
    position: fixed;
    inset: 0;
    z-index: 60000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(14px, 4vw, 28px);
}

.ios-popup-background {
    position: absolute;
    inset: 0;
    background: rgba(8, 10, 24, 0.6);
    backdrop-filter: blur(6px);
}

.ios-popup-content {
    position: relative;
    width: min(92vw, 420px);
    background: rgba(255, 255, 255, 0.98);
    border-radius: 22px;
    padding: clamp(16px, 4vw, 24px);
    box-shadow: 0 18px 40px rgba(7, 10, 24, 0.35);
    border: 2px solid rgba(59, 182, 255, 0.3);
    text-align: center;
}

.ios-gif-container {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.ios-instruction-gif {
    width: min(78vw, 320px);
    border-radius: 18px;
    border: 2px solid rgba(255, 77, 141, 0.35);
    box-shadow: 0 12px 26px rgba(7, 10, 24, 0.2);
}

.ios-instruction-text h3 {
    font-size: clamp(1.1rem, 4vw, 1.35rem);
    margin-bottom: 8px;
    color: var(--ink-1);
}

.ios-instruction-text p {
    font-size: clamp(0.95rem, 3.2vw, 1rem);
    color: var(--ink-2);
    line-height: 1.5;
}


/* Loading Screen */
.loading-screen {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(1200px 600px at 10% 10%, rgba(255, 77, 141, 0.25), transparent 60%),
        radial-gradient(900px 500px at 90% 15%, rgba(59, 182, 255, 0.25), transparent 60%),
        radial-gradient(700px 400px at 25% 85%, rgba(255, 211, 56, 0.2), transparent 60%),
        linear-gradient(180deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50000;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-card {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 24px;
    padding: clamp(18px, 5vw, 32px);
    text-align: center;
    width: min(86vw, 360px);
    box-shadow: 0 20px 45px rgba(7, 10, 24, 0.45);
}

.loading-logo {
    width: clamp(90px, 26vw, 130px);
    height: clamp(90px, 26vw, 130px);
    margin: 0 auto 10px;
    border-radius: 22px;
    background: linear-gradient(145deg, rgba(255, 77, 141, 0.2), rgba(255, 211, 56, 0.2));
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 77, 141, 0.3);
}

.loading-logo img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.loading-title {
    font-family: 'Luckiest Guy', 'Archivo Black', sans-serif;
    font-size: clamp(1.4rem, 6vw, 2.1rem);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    display: inline-flex;
    align-items: baseline;
    gap: clamp(4px, 1.4vw, 10px);
    color: #ffffff;
    -webkit-text-fill-color: #ffffff;
    -webkit-text-stroke: 1px #000000;
    text-shadow:
        1px 0 0 #000000,
        -1px 0 0 #000000,
        0 1px 0 #000000,
        0 -1px 0 #000000,
        1px 1px 0 #000000,
        -1px 1px 0 #000000,
        1px -1px 0 #000000,
        -1px -1px 0 #000000,
        0 0 8px rgba(59, 182, 255, 0.6),
        0 0 14px rgba(255, 77, 141, 0.4);
    transform: skewX(-4deg);
}

.loading-subtitle {
    font-size: clamp(0.85rem, 3.5vw, 1rem);
    color: #475569;
    font-weight: 600;
    margin-bottom: 14px;
}

.loading-bar {
    width: 100%;
    height: 12px;
    background: rgba(15, 23, 42, 0.08);
    border-radius: 999px;
    overflow: hidden;
    border: 2px solid rgba(255, 77, 141, 0.35);
}

.loading-bar-fill {
    height: 100%;
    width: 30%;
    background: linear-gradient(90deg, #ff4d8d, #ffd338, #3bb6ff);
    border-radius: 999px;
    animation: loadingSlide 1.2s ease-in-out infinite;
}

@keyframes loadingSlide {
    0% {
        transform: translateX(-100%);
        width: 40%;
    }
    50% {
        transform: translateX(40%);
        width: 60%;
    }
    100% {
        transform: translateX(140%);
        width: 40%;
    }
}

/* Main Container */
.game-container {
    width: min(96vw, 680px);
    height: auto;
    max-height: none;
    background: linear-gradient(180deg, var(--card) 0%, var(--card-strong) 100%);
    display: flex;
    flex-direction: column;
    padding: var(--space-2);
    padding-top: calc(var(--space-2) + env(safe-area-inset-top));
    padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
    padding-left: calc(var(--space-2) + env(safe-area-inset-left));
    padding-right: calc(var(--space-2) + env(safe-area-inset-right));
    position: relative;
    text-align: center;
    overflow: visible;
    border-radius: var(--radius-card);
    box-shadow: 0 14px 28px rgba(7, 10, 24, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.75);
}

@media (min-width: 768px) and (max-width: 1024px) {
    body {
        align-items: center;
        padding: var(--space-2);
    }

    .game-container {
        width: min(90vw, 720px);
        min-height: 0;
    }

    .puzzle-grid {
        width: min(72vmin, 560px);
        max-width: 560px;
    }

}

@media (min-width: 1025px) {
    body {
        align-items: center;
        padding: var(--space-2);
    }

    .game-container {
        width: min(80vw, 760px);
    }

    .puzzle-grid {
        width: min(60vmin, 560px);
        max-width: 560px;
    }

    .logo-container {
        width: clamp(110px, 14vw, 160px);
        height: clamp(110px, 14vw, 160px);
    }

    .main-title {
        font-size: clamp(2.2rem, 3.4vw, 3.6rem);
    }
}


.game-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(220px 220px at 12% 10%, rgba(255, 77, 141, 0.08), transparent 70%),
        radial-gradient(240px 240px at 90% 18%, rgba(59, 182, 255, 0.1), transparent 70%);
    pointer-events: none;
}

/* Header */
.game-header {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 0;
    position: relative;
    z-index: 1;
}

.header-main {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    padding: 0;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 20px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
}

.logo-container {
    width: clamp(120px, 26vw, 170px);
    height: clamp(120px, 26vw, 170px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 20px;
    background: transparent;
    border: none;
}

.game-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 6px 10px rgba(15, 23, 42, 0.15));
}

.header-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 2px;
    margin: 0;
    padding: 0;
}

.main-title {
    font-size: clamp(2.1rem, 8vw, 3.6rem);
    font-family: 'Luckiest Guy', 'Archivo Black', sans-serif;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    margin: 0;
    line-height: 1;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    display: inline-flex;
    align-items: baseline;
    gap: clamp(4px, 1.4vw, 10px);
    color: #ffffff;
    -webkit-text-fill-color: #ffffff;
    -webkit-text-stroke: 1px #000000;
    text-shadow:
        1px 0 0 #000000,
        -1px 0 0 #000000,
        0 1px 0 #000000,
        0 -1px 0 #000000,
        1px 1px 0 #000000,
        -1px 1px 0 #000000,
        1px -1px 0 #000000,
        -1px -1px 0 #000000,
        0 0 6px rgba(59, 182, 255, 0.5),
        0 0 10px rgba(255, 77, 141, 0.3),
        0 4px 8px rgba(0, 0, 0, 0.25);
    transform: skewX(-4deg);
}

.main-title .word,
.loading-title .word {
    -webkit-text-stroke: 1px #000000;
    text-shadow:
        1px 0 0 #000000,
        -1px 0 0 #000000,
        0 1px 0 #000000,
        0 -1px 0 #000000,
        1px 1px 0 #000000,
        -1px 1px 0 #000000,
        1px -1px 0 #000000,
        -1px -1px 0 #000000,
        0 0 6px rgba(59, 182, 255, 0.5),
        0 0 10px rgba(255, 77, 141, 0.3),
        0 4px 8px rgba(0, 0, 0, 0.25);
}

.word.play {
    color: #3bb6ff;
    -webkit-text-fill-color: #3bb6ff;
}

.word.two {
    color: #34d399;
    -webkit-text-fill-color: #34d399;
}

.word.bux {
    color: #ffd338;
    -webkit-text-fill-color: #ffd338;
}

header {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Stats */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-top: var(--space-1);
}

.stat-box {
    background: linear-gradient(135deg, rgba(255, 77, 141, 0.15), rgba(255, 211, 56, 0.2));
    border: 2px solid rgba(255, 77, 141, 0.28);
    border-radius: 18px;
    padding: 12px 10px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        0 6px 12px rgba(15, 23, 42, 0.12);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    gap: 4px;
}

.currency-icon {
    width: clamp(16px, 4vw, 24px);
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.25));
}

.robux-particle {
    position: fixed;
    width: clamp(20px, 5vw, 30px);
    height: auto;
    pointer-events: none;
    z-index: 1000;
}

.claim-button-box {
    background: linear-gradient(135deg, #34d399 0%, #22c55e 100%);
    border: 2px solid rgba(34, 197, 94, 0.5) !important;
    border-radius: 18px;
    width: 100%;
    padding: 12px 12px;
    color: white;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow:
        0 8px 14px rgba(34, 197, 94, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.45);
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    transition: transform 0.1s, box-shadow 0.2s;
}

.claim-button-box .claim-label {
    font-size: clamp(0.9rem, 3.2vw, 1.05rem);
}

.claim-button-box .claim-robux {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.14);
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.claim-button-box .claim-robux .value {
    color: #ffffff;
}

.claim-button-box:active {
    transform: translateY(1px);
    box-shadow:
        0 3px 6px rgba(34, 197, 94, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.claim-button-box.unlocked {
    animation: claimPulse 1.1s ease-in-out infinite alternate;
}

@keyframes claimPulse {
    from {
        transform: scale(1);
        filter: brightness(1);
    }

    to {
        transform: scale(1.04);
        filter: brightness(1.1);
    }
}

.label {
    font-size: clamp(0.52rem, 2.2vw, 0.75rem);
    font-weight: 800;
    text-transform: uppercase;
    color: rgba(15, 23, 42, 0.55);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.value {
    font-size: clamp(1rem, 4vw, 1.35rem);
    font-weight: 800;
    color: #0f172a;
}

.glowing-green {
    color: #16a34a;
    text-shadow: 0 0 12px rgba(34, 197, 94, 0.35);
}

/* Buttons */
.exchange-button {
    width: 100%;
    padding: clamp(8px, 2vw, 12px);
    font-size: clamp(0.75rem, 3vw, 0.98rem);
    font-weight: 700;
    font-family: inherit;
    background: linear-gradient(135deg, #9b8df2, #7fb6ff);
    border: 2px solid rgba(124, 92, 255, 0.35);
    border-radius: 18px;
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 12px rgba(59, 182, 255, 0.2);
    transition: transform 0.1s, box-shadow 0.2s;
    margin-top: var(--space-1);
}


.exchange-button:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 0 4px 8px rgba(59, 182, 255, 0.2);
}

.exchange-button:disabled {
    opacity: 0.5;
    filter: grayscale(1);
    box-shadow: none;
    transform: translateY(1px);
}

.exchange-button.exchange-disabled {
    opacity: 0.75;
    filter: grayscale(0.2);
    box-shadow: 0 6px 12px rgba(59, 182, 255, 0.25);
}

.exchange-button.exchange-ready {
    animation: exchangePulse 1s ease-in-out infinite;
}

@keyframes exchangePulse {
    0% {
        transform: scale(1);
        box-shadow: 0 6px 12px rgba(59, 182, 255, 0.25);
    }
    50% {
        transform: scale(1.03);
        box-shadow: 0 10px 18px rgba(59, 182, 255, 0.3);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 6px 12px rgba(59, 182, 255, 0.25);
    }
}

.legal-disclaimer {
    font-size: clamp(0.7rem, 2.4vw, 0.95rem);
    color: #0f172a;
    font-weight: 700;
    padding: 4px 6px;
}

/* Main Area */
main#game-area {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-height: 0;
    justify-content: flex-start;
    position: relative;
    z-index: 1;
}

.how-to-play-card {
    background: linear-gradient(135deg, rgba(255, 211, 56, 0.18), rgba(255, 77, 141, 0.12));
    border: 2px solid rgba(255, 77, 141, 0.25);
    border-radius: 18px;
    padding: 10px 12px;
    text-align: left;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.how-to-play-card h2 {
    font-size: clamp(0.95rem, 3.6vw, 1.2rem);
    color: var(--ink-1);
    margin-bottom: 6px;
    letter-spacing: 0.4px;
}

.how-to-play-card p {
    font-size: clamp(0.72rem, 2.8vw, 0.95rem);
    color: var(--ink-2);
    line-height: 1.35;
}

.game-info {
    display: flex;
    justify-content: space-around;
    gap: 8px;
}

.moves-left,
.target {
    flex: 1;
    background: rgba(59, 182, 255, 0.14);
    border: 2px solid rgba(59, 182, 255, 0.35);
    border-radius: 14px;
    padding: 8px 6px;
    min-width: 0;
}

.moves-left .value,
.target .value {
    color: var(--ink-1);
    text-shadow: none;
    font-size: clamp(0.95rem, 4.4vw, 1.3rem);
}

/* Game Grid */
.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: clamp(2px, 1.2vw, 8px);
    background: rgba(124, 92, 255, 0.08);
    border: 1px solid rgba(124, 92, 255, 0.25);
    border-radius: 18px;
    padding: clamp(8px, 1.8vw, 12px);
    margin: 0 auto;
    width: min(92vw, 460px);
    max-width: 460px;
    aspect-ratio: 1;
    box-sizing: border-box;
    flex: 0 1 auto;
    min-height: 0;
    touch-action: none;
    position: relative;
}

.tile {
    background: white;
    border: 1px solid rgba(124, 92, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(2px, 0.8vw, 4px);
    transition: transform 0.12s, box-shadow 0.2s, border-color 0.2s;
    overflow: hidden;
    position: relative;
    width: 100%;
    height: 100%;
    animation: tilePop 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) backwards;
}

.tile img {
    width: 84%;
    height: 84%;
    object-fit: contain;
    pointer-events: none;
}

.tile.selected {
    transform: translateY(-2px) scale(1.05);
    border-color: rgba(59, 182, 255, 0.9);
    box-shadow: 0 0 0 1.5px rgba(59, 182, 255, 0.25);
    z-index: 5;
}

.tile.match-pop {
    animation: matchPop 0.45s ease-out forwards;
    z-index: 10;
}

.new-game-button {
    width: 100%;
    padding: clamp(9px, 2.5vw, 14px);
    background: linear-gradient(135deg, #ff4d8d 0%, #ffd338 100%);
    border: 2px solid rgba(255, 77, 141, 0.5);
    border-radius: 14px;
    color: white;
    font-weight: 700;
    font-size: clamp(0.9rem, 3.8vw, 1.1rem);
    cursor: pointer;
    box-shadow: 0 10px 18px rgba(255, 77, 141, 0.25);
    margin-top: var(--space-2);
    transition: transform 0.1s, box-shadow 0.2s;
}

.new-game-button:active {
    transform: translateY(1px);
    box-shadow: 0 4px 8px rgba(255, 77, 141, 0.2);
}

.how-to-button {
    width: 100%;
    padding: clamp(9px, 2.5vw, 14px);
    background: linear-gradient(135deg, #50b7ff 0%, #7a6bff 100%);
    border: 2px solid rgba(79, 167, 255, 0.45);
    border-radius: 18px;
    color: white;
    font-weight: 700;
    font-size: clamp(0.85rem, 3.4vw, 1.05rem);
    cursor: pointer;
    box-shadow: 0 6px 12px rgba(59, 182, 255, 0.2);
    margin-top: 6px;
    transition: transform 0.1s, box-shadow 0.2s;
}

.how-to-button:active {
    transform: translateY(1px);
    box-shadow: 0 4px 8px rgba(59, 182, 255, 0.2);
}

.stats-panel .how-to-button {
    margin-top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px 6px;
    box-shadow:
        0 6px 12px rgba(59, 182, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.stats-panel .how-to-button:active {
    transform: translateY(1px);
    box-shadow:
        0 4px 8px rgba(59, 182, 255, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* Popups & Effects */
#result-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 2px solid rgba(124, 92, 255, 0.4);
    border-radius: 22px;
    padding: clamp(16px, 5vw, 30px);
    z-index: 100;
    width: 86%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 20px 45px rgba(7, 10, 24, 0.35);
}

.continue-button {
    padding: 10px 20px;
    background: #22c55e;
    border: 2px solid rgba(34, 197, 94, 0.5);
    border-radius: 12px;
    color: white;
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(34, 197, 94, 0.3);
}

/* Animations & Particles */
.score-popup {
    position: fixed;
    color: #f59e0b;
    font-size: clamp(1rem, 5vw, 1.5rem);
    font-weight: 700;
    pointer-events: none;
    z-index: 1000;
    animation: floatUpResponsive 1.2s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.25);
    transform: translate(-50%, 0);
}

.coin-popup {
    position: fixed;
    color: #f59e0b;
    font-size: clamp(1.2rem, 6vw, 2rem);
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 1001;
    animation: floatUpResponsive 1s ease-out forwards;
    font-family: 'Space Grotesk', sans-serif;
    transform: translate(-50%, -50%);
}

.celebration-emoji {
    position: fixed;
    font-size: clamp(1.5rem, 8vw, 2.5rem);
    pointer-events: none;
    z-index: 998;
    animation: fadeOutResponsive 2s ease-out forwards;
}

@keyframes floatUpResponsive {
    0% {
        transform: translate(-50%, 0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -15vh) scale(1.5);
        opacity: 0;
    }
}

.game-toast {
    position: fixed;
    top: clamp(10px, 3vh, 30px);
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ff4d8d 0%, #3bb6ff 100%);
    color: white;
    padding: clamp(8px, 2vh, 15px) clamp(15px, 5vw, 30px);
    border-radius: clamp(8px, 2vh, 15px);
    border: 2px solid rgba(255, 255, 255, 0.35);
    font-size: clamp(0.9rem, 4vw, 1.2rem);
    font-weight: 700;
    z-index: 9999;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.25);
    pointer-events: none;
    text-align: center;
    width: auto;
    max-width: 85vw;
    animation: toastSlide 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards,
        toastFadeOut 0.4s ease-in 2.5s forwards;
    white-space: nowrap;
}

@keyframes toastSlide {
    0% {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }

    100% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes toastFadeOut {
    0% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
}

.social-toast {
    position: fixed;
    bottom: clamp(10px, 2vh, 20px);
    left: clamp(10px, 2vw, 20px);
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(52, 211, 153, 0.45);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
    z-index: 10000;
    font-size: 0.85rem;
    font-weight: 600;
    animation: socialSlideIn 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards,
        socialFadeOut 0.5s ease-in 4.5s forwards;
    pointer-events: none;
    max-width: 250px;
}

.social-toast .user-avatar {
    width: 24px;
    height: 24px;
    background: #e2e8f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.social-toast b {
    color: #16a34a;
}

@keyframes socialSlideIn {
    0% {
        transform: translateX(-120%);
        opacity: 0;
    }

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

@keyframes socialFadeOut {
    0% {
        transform: translateX(0);
        opacity: 1;
    }

    100% {
        transform: translateX(-120%);
        opacity: 0;
    }
}

@keyframes fadeOutResponsive {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }

    100% {
        opacity: 0;
        transform: scale(0.5) rotate(45deg);
    }
}

.matching {
    animation: matchPop 0.45s ease-out forwards;
    z-index: 10;
}

.tile.hint {
    animation: hintPulse 1s ease-in-out infinite;
    border-color: rgba(255, 211, 56, 0.9);
    box-shadow: 0 0 0 2px rgba(255, 211, 56, 0.35), 0 0 12px rgba(255, 211, 56, 0.6);
}

@keyframes hintPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.06);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes matchPop {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }

    40% {
        transform: scale(1.25);
        filter: brightness(1.8);
    }

    70% {
        transform: scale(0.9);
        filter: brightness(1.1);
    }

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


.particle {
    position: fixed;
    pointer-events: none;
    z-index: 2000;
    font-size: clamp(1rem, 4vw, 1.5rem);
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes tilePop {
    0% {
        transform: scale(0);
        opacity: 0;
    }

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

.combo-indicator {
    position: fixed;
    top: 35%;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(1.2rem, 6vw, 2.2rem);
    font-family: 'Archivo Black', sans-serif;
    color: #ff4d8d;
    text-shadow: 1px 1px 0 #fde68a, 3px 3px 0 #1f2937;
    z-index: 101;
    animation: bouncePop 1s forwards;
    width: 100%;
    text-align: center;
}

@keyframes gridComboGlow {
    0% {
        box-shadow: 0 0 0 rgba(59, 182, 255, 0);
    }
    30% {
        box-shadow: 0 0 18px rgba(59, 182, 255, 0.65), 0 0 36px rgba(255, 77, 141, 0.45);
    }
    100% {
        box-shadow: 0 0 0 rgba(59, 182, 255, 0);
    }
}

.puzzle-grid.combo-glow {
    animation: gridComboGlow 0.55s ease-out;
}
@keyframes bouncePop {
    0% {
        transform: translateX(-50%) scale(0);
    }

    50% {
        transform: translateX(-50%) scale(1.1);
    }

    100% {
        transform: translateX(-50%) scale(1);
        opacity: 0;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .game-container {
        max-width: 98vw;
        gap: 10px;
        padding: 10px;
        overflow-y: auto;
    }

    header {
        justify-content: center;
        margin-bottom: 0;
    }

    main#game-area {
        justify-content: center;
    }

    .stats-panel {
        grid-template-columns: 1fr;
    }

    .puzzle-grid {
        height: 100%;
        width: auto;
        aspect-ratio: 1;
        max-width: none;
    }

    .new-game-button {
        display: block;
        margin-top: 10px;
        padding: 8px;
        font-size: 0.9rem;
    }

    .legal-disclaimer {
        display: none;
    }
}

@media (max-width: 480px) {
    body {
        align-items: flex-start;
        padding: 0;
    }

    .game-container {
        width: 100vw;
        border-radius: 0;
        box-shadow: none;
        border: none;
        padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
    }

    .header-main {
        padding: 4px 8px;
        gap: 12px;
    }

    .logo-container {
        width: clamp(96px, 26vw, 140px);
        height: clamp(96px, 26vw, 140px);
    }

    .stats-panel {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-top: 10px;
    }

    .puzzle-grid {
        width: min(94vw, 420px);
    }
}

@media (max-height: 600px) {
    .game-container {
        overflow-y: auto;
    }
}

@media (min-height: 850px) {
    .game-container {
        padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
    }
}

@media (hover: hover) {
    .exchange-button:hover,
    .new-game-button:hover,
    .how-to-button:hover,
    .claim-button-box:hover,
    .connect-button:hover {
        transform: translateY(-1px);
    }
}

.hidden {
    display: none !important;
}

/* Modal System */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20000;
}

.modal-content {
    background: rgba(255, 255, 255, 0.96);
    width: 90%;
    max-width: 420px;
    padding: clamp(20px, 5vw, 40px);
    border-radius: 22px;
    box-shadow: 0 20px 45px rgba(7, 10, 24, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.6);
    position: relative;
    text-align: center;
    animation: modalScaleIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Claim Page */
.claim-container {
    width: min(92vw, 540px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.claim-header {
    text-align: center;
    display: grid;
    gap: 10px;
    justify-items: center;
}

.claim-subtitle {
    font-size: clamp(0.85rem, 3vw, 1rem);
    color: #94a3b8;
    font-weight: 600;
}

.claim-card {
    background: rgba(255, 255, 255, 0.96);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 22px;
    padding: clamp(18px, 4.5vw, 28px);
    box-shadow: 0 20px 45px rgba(7, 10, 24, 0.35);
    display: grid;
    gap: 16px;
}

.claim-balance {
    background: linear-gradient(135deg, rgba(59, 182, 255, 0.2), rgba(124, 92, 255, 0.2));
    border: 2px solid rgba(59, 182, 255, 0.35);
    border-radius: 14px;
    padding: 12px;
    display: grid;
    gap: 6px;
    text-align: center;
}

.claim-message {
    min-height: 22px;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    color: #475569;
}

.claim-message.success {
    color: #15803d;
}

.claim-message.error {
    color: #b91c1c;
}

.back-button {
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 2px solid rgba(59, 182, 255, 0.45);
    background: rgba(255, 255, 255, 0.9);
    color: #1f2937;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
}

.back-button:active {
    transform: translateY(1px);
    box-shadow: 0 4px 8px rgba(15, 23, 42, 0.12);
}

.howto-content {
    max-width: 460px;
}

.modal-header h1 {
    font-size: clamp(1.6rem, 5vw, 2.2rem);
    margin: 0 0 10px;
    color: var(--ink-1);
}

.modal-header p {
    color: #64748b;
    margin-bottom: 24px;
    font-size: 1rem;
}

.modal-header .highlight {
    color: #0ea5e9;
    font-weight: 700;
}

.input-group {
    text-align: left;
    margin-bottom: 26px;
}

.input-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--ink-1);
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 2px solid rgba(148, 163, 184, 0.6);
    background: #f8fafc;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink-1);
    box-sizing: border-box;
    transition: all 0.25s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #3bb6ff;
    background: white;
    box-shadow: var(--ring);
}

.connect-button {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #3bb6ff 0%, #7c5cff 100%);
    color: white;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(59, 182, 255, 0.3);
    transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.connect-button:active {
    transform: scale(0.98);
    box-shadow: 0 6px 12px rgba(59, 182, 255, 0.22);
}

.howto-body ol {
    list-style: decimal;
    display: grid;
    gap: 10px;
    text-align: left;
    padding-left: 22px;
}

.howto-body li {
    background: rgba(59, 182, 255, 0.1);
    border: 2px solid rgba(59, 182, 255, 0.25);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: clamp(0.85rem, 3vw, 1rem);
    color: #1f2937;
    line-height: 1.35;
}

.howto-body b {
    color: #7c5cff;
}

.close-button {
    position: absolute;
    top: 14px;
    right: 18px;
    background: none;
    border: none;
    font-size: 2rem;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
}

@keyframes modalScaleIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(16px);
    }

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