* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    zoom: 1;
    -moz-transform: scale(1);
    -moz-transform-origin: 0 0;
    transform: scale(1);
    transform-origin: 0 0;
}

:root {
    /* Tile colors */
    --tile-1-bg: #fff2e5;
    --tile-1-color: #45413d;
    --tile-2-bg: #ffbf80;
    --tile-2-color: #45413d;
    --tile-3-bg: #ff8c1a;
    --tile-3-color: #45413d;
    --tile-4-bg: #ff661a;
    --tile-4-color: white;
    --tile-5-bg: #ff401a;
    --tile-5-color: white;
    --tile-6-bg: #ffea7e;
    --tile-6-color: #45413d;
    --tile-7-bg: #ffd91a;
    --tile-7-color: #45413d;
    --tile-8-bg: #ffb21a;
    --tile-8-color: #45413d;
    --tile-9-bg: #80ffd4;
    --tile-9-color: #45413d;
    --tile-10-bg: #1ad9ff;
    --tile-10-color: #45413d;

    /* Special tile colors */
    --tile-joker-bg: linear-gradient(135deg, #9c27b0 0%, #e91e63 100%);
    --tile-joker-color: white;
    --tile-joker-border: #fff6;

    --tile-cursed-bg: linear-gradient(135deg, #6a1b9a 0%, #4a148c 100%);
    --tile-cursed-border: #9c27b0;
    --tile-cursed-color: white;
    --tile-cursed-badge-bg: #9c27b0;

    --tile-power-border: #d91ce9;
    --tile-power-badge-bg: #d91ce9;
    --tile-power-badge-color: white;

    --tile-golden-border: #ffd700;
    --tile-golden-badge-bg: #ffd700;
    --tile-golden-badge-color: black;

    --tile-freeswap-border: #00bcd4;
    --tile-freeswap-badge-bg: #00bcd4;
    --tile-freeswap-badge-color: white;

    --tile-blocked-bg: #3c3c3c;
    --tile-blocked-border: #666;
    --tile-blocked-x-color: #666;
    --tile-blocked-life-color: #fff;

    --tile-blocked-movable-bg: #3c3c3c;
    --tile-blocked-movable-border: #666;
    --tile-blocked-movable-icon-color: white;
}

.flex-spacer {
    flex-grow: 1; /* allow it to take up remaining space */
    flex-shrink: 1; /* allow it to shrink */
    flex-basis: 0; /* start with zero base size */
    min-height: 0; /* allow it to shrink down to 0 height */
}

.flex-spacer.half {
    flex-grow: 0.5; /* take up half the remaining space */
}

.flex-spacer.quarter {
    flex-grow: 0.25; /* take up a quarter of the remaining space */
}

body {
    font-family: Arial, sans-serif;
    background: #222 url("assets/bg.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile browsers */
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
    user-select: none;
    box-sizing: border-box;
}

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

.game-container {
    text-align: center;
    max-width: 600px;
    width: 100%;
    padding: 10px clamp(10px, 3vw, 20px);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: clamp(8px, 4vw, 20px);
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

.info-btn {
    position: absolute;
    top: 12%;
    right: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    font-size: 14px;
    font-family: Nunito;
    font-weight: 900;
    z-index: 10;
    color: rgba(255, 255, 255, 0.5);
}

.info-btn:active {
    transform: scale(0.95);
}

.level-text {
    margin: 0;
    color: rgba(255, 255, 255, 0.5);
    font-family: Nunito;
    font-size: 32px;
    font-style: normal;
    font-weight: 900;
    line-height: normal;
    position: relative;
}

.level-text svg {
    width: 100%;
}

#levelSolvedSvg,
#levelFailedSvg {
    position: relative;
    top: -10px;
}

#levelSolvedSvg.animate {
    animation: levelSolvedBounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

#levelFailedSvg.animate {
    animation: levelFailedBounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes levelSolvedBounce {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.15);
    }
    70% {
        transform: scale(0.9);
    }
    85% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes levelFailedBounce {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.15);
    }
    70% {
        transform: scale(0.9);
    }
    85% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.info-item {
    text-align: center;
    color: white;
}

.info-item .label {
    display: block;
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    opacity: 0.8;
    margin-bottom: clamp(3px, 1vw, 5px);
}

.info-item span:last-child {
    font-size: clamp(1.1rem, 3vw, 1.4rem);
    font-weight: bold;
}

.info-item:nth-child(2) span:last-child {
    font-size: clamp(1.3rem, 3.5vw, 1.6rem);
    background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
    filter: drop-shadow(0 0 8px rgba(255, 107, 107, 0.2));
}

.game-info {
    display: flex;
    gap: clamp(10px, 3vw, 20px);
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    width: 100%;
    align-items: stretch;
}

.goals-container,
.moves-container {
    position: relative;
    border-radius: 24px;
    border: 3px solid #000;
    background: #141414;

    box-shadow: 0 8px 0 0 rgba(0, 0, 0, 0.25);
}

.goals-container .label,
.moves-container .label {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-family: Nunito;
    font-size: 22px;
    font-style: normal;
    font-weight: 900;
    line-height: normal;
    white-space: nowrap;
}

.goals-container {
    flex: 1;
    padding: 25px 0 5px;
}

.goals-container .crown {
    position: absolute;
    top: -34px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 34px;
}

.moves-container {
    width: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.moves-container span {
    color: #fff;
    text-shadow: -2px -2px 0 #222, 2px -2px 0 #222, -2px 2px 0 #222, 2px 2px 0 #222;
    font-family: Nunito;
    font-size: 40px;
    font-style: normal;
    font-weight: 900;
}

.goals {
    display: flex;
    gap: clamp(6px, 2vw, 10px);
    justify-content: center;
    flex-wrap: wrap;
}

.goal-card {
    min-width: clamp(60px, 25%, 80px);
    position: relative;
}

.goal-icon {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: #141414;
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1rem;
    width: 1.2rem;
    height: 1.2rem;
    text-align: center;
}

.goal-progress {
    font-family: Nunito;
    font-weight: 900;

    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
}

.goal-progress svg {
    height: 1.2rem;
}

.goal-check {
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    background: #5aec69;
    border: 3px solid black;
    color: black;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
        "Open Sans", "Helvetica Neue", sans-serif;
    font-size: 12px;
    font-weight: bolder;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: clamp(1px, 0.7vw, 3px);
    border: 3px solid #000;
    background: #141414;
    padding: clamp(6px, 3vw, 15px);
    border-radius: 24px;
    box-shadow: 0 8px 0 0 rgba(0, 0, 0, 0.25);
    margin: 0 auto;
    flex-shrink: 1;
    flex-grow: 0;
    max-height: 50vh;
}

.gem {
    aspect-ratio: 1;
    border-radius: 20%;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 -3px 0 0 rgba(0, 0, 0, 0.25) inset;
    font-family: Nunito;
    font-size: clamp(16px, 3vw, 24px);
    font-weight: 900;
    color: #45413d;
    container-type: inline-size;
    container-name: card;
    padding-bottom: 2px;

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

.gem > * {
    pointer-events: none;
}

.gem.dragging {
    z-index: 10;
    transform: scale(1.1);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.gem.preview, .gem.pending-preview {
    opacity: 0.7;
    transform: scale(0.95);
}

/* Tile colors based on internal value (1, 2, 3, 4...) */
.gem.tile-1 {
    background: var(--tile-1-bg);
    color: var(--tile-1-color);
}

.gem.tile-2 {
    background: var(--tile-2-bg);
    color: var(--tile-2-color);
}

.gem.tile-3 {
    background: var(--tile-3-bg);
    color: var(--tile-3-color);
}

.gem.tile-4 {
    background: var(--tile-4-bg);
    color: var(--tile-4-color);
}

.gem.tile-5 {
    background: var(--tile-5-bg);
    color: var(--tile-5-color);
}

.gem.tile-6 {
    background: var(--tile-6-bg);
    color: var(--tile-6-color);
}

.gem.tile-7 {
    background: var(--tile-7-bg);
    color: var(--tile-7-color);
    font-size: clamp(10px, 2.5vw, 20px);
}

.gem.tile-8 {
    background: var(--tile-8-bg);
    color: var(--tile-8-color);
    font-size: clamp(10px, 2.5vw, 20px);
}

.gem.tile-9 {
    background: var(--tile-9-bg);
    color: var(--tile-9-color);
    font-size: clamp(10px, 2.5vw, 20px);
}

.gem.tile-10 {
    background: var(--tile-10-bg);
    color: var(--tile-10-color);
    font-size: clamp(9px, 2.2vw, 18px);
}

/* .gem.tile-11 {
    background: #edc22e;
    font-size: clamp(9px, 2.2vw, 18px);
}

.gem.tile-12 {
    background: #edc22e;
    font-size: clamp(8px, 2vw, 16px);
} */

.gem.tile-JOKER {
    background: var(--tile-joker-bg);
    color: var(--tile-joker-color);
    border: 4px solid var(--tile-joker-border);
    font-size: clamp(22px, 4.5vw, 32px);
    cursor: pointer;
    position: relative;
}

.gem.cursed-tile {
    background: var(--tile-cursed-bg) !important;
    border: 3px solid var(--tile-cursed-border) !important;
    position: relative;
    color: var(--tile-cursed-color);
}

.gem.cursed-tile::after {
    content: attr(data-cursed-moves);
    position: absolute;
    bottom: -3px;
    right: -3px;
    font-family: Nunito;
    font-size: clamp(12px, 2.5vw, 16px);
    font-weight: 900;
    background: var(--tile-cursed-badge-bg);
    width: 33%;
    height: 33%;
    border-radius: 50%;
    color: var(--tile-cursed-color);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--tile-cursed-badge-bg);
    box-shadow: 0 0 8px rgba(156, 39, 176, 0.6);
}

.goal-tile {
    margin-top: -10%;
    transform-origin: center center;
    transform: scale(0.8);
}

.gem.cursed-disappear {
    animation: cursedFadeOut 0.4s ease-out forwards;
}

@keyframes cursedFadeOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.5);
    }
}

.gem.cursed-implode {
    animation: cursedImplode 0.4s ease-out forwards;
}

@keyframes cursedImplode {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        box-shadow: 0 0 30px rgba(156, 39, 176, 1);
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.gem.cursed-sucked {
    background: var(--tile-cursed-bg) !important;
    transition: background 0.1s ease-out;
}

.gem.power-tile {
    border: 4px solid var(--tile-power-border);
    position: relative;
}

.gem.power-tile::after {
    content: "+";
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: clamp(10px, 2vw, 16px);
    background-color: var(--tile-power-badge-bg);
    width: 40%;
    height: 40%;
    border-radius: 50%;
    color: var(--tile-power-badge-color);
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gem.golden-tile {
    border: 4px solid var(--tile-golden-border);
    position: relative;
}

.gem.golden-tile::after {
    content: "★";
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: clamp(8px, 2vw, 16px);
    width: 40%;
    height: 40%;
    border-radius: 50%;
    background-color: var(--tile-golden-badge-bg);
    color: var(--tile-golden-badge-color);
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gem.freeswap-tile {
    border: 4px solid var(--tile-freeswap-border);
    position: relative;
}

.gem.freeswap-tile::after {
    content: "↔";
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: clamp(8px, 2vw, 16px);
    width: 40%;
    height: 40%;
    border-radius: 50%;
    background-color: var(--tile-freeswap-badge-bg);
    color: var(--tile-freeswap-badge-color);
    font-weight: bolder;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gem.sticky-freeswap-tile {
    border: 4px solid var(--tile-freeswap-border);
    position: relative;
}

.gem.sticky-freeswap-tile::after {
    content: "⇄";
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: clamp(8px, 2vw, 16px);
    width: 40%;
    height: 40%;
    border-radius: 50%;
    background-color: var(--tile-freeswap-badge-bg);
    color: var(--tile-freeswap-badge-color);
    font-weight: bolder;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gem.tile-BLOCKED {
    background: var(--tile-blocked-bg);
    color: transparent;
    border: 2px solid var(--tile-blocked-border);
    position: relative;
    overflow: hidden;
}

.gem.tile-BLOCKED::before {
    content: "";
    position: absolute;
    top: 45%;
    left: 50%;
    width: 60%;
    height: 60%;
    background: linear-gradient(
            45deg,
            transparent 30%,
            var(--tile-blocked-x-color) 30%,
            var(--tile-blocked-x-color) 70%,
            transparent 70%
        ),
        linear-gradient(
            -45deg,
            transparent 30%,
            var(--tile-blocked-x-color) 30%,
            var(--tile-blocked-x-color) 70%,
            transparent 70%
        );
    transform: translate(-50%, -50%);
}

.gem.tile-BLOCKED.unblocking {
    animation: unblock-move 0.6s ease-out forwards;
    z-index: 200;
}

.gem.tile-BLOCKED_WITH_LIFE {
    background: var(--tile-blocked-bg);
    color: var(--tile-blocked-life-color);
    border: 2px solid var(--tile-blocked-border);
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.gem.tile-BLOCKED_WITH_LIFE::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    height: 60%;
    background: linear-gradient(
            45deg,
            transparent 30%,
            var(--tile-blocked-x-color) 30%,
            var(--tile-blocked-x-color) 70%,
            transparent 70%
        ),
        linear-gradient(
            -45deg,
            transparent 30%,
            var(--tile-blocked-x-color) 30%,
            var(--tile-blocked-x-color) 70%,
            transparent 70%
        );
    transform: translate(-50%, -50%);
    z-index: 0;
}

.gem.tile-BLOCKED_WITH_LIFE::after {
    content: attr(data-life);
    position: relative;
    z-index: 1;
    color: var(--tile-blocked-life-color);
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    font-weight: bold;
}

.gem.tile-BLOCKED_WITH_LIFE.unblocking {
    animation: unblock-move 0.6s ease-out forwards;
    z-index: 200;
}

.gem.tile-BLOCKED_MOVABLE {
    background: var(--tile-blocked-movable-bg);
    color: transparent;
    border: 2px solid var(--tile-blocked-movable-border);
    position: relative;
    overflow: visible;
    cursor: pointer;
}

.gem.tile-BLOCKED_MOVABLE::before {
    content: "";
    position: absolute;
    top: 45%;
    left: 50%;
    width: 60%;
    height: 60%;
    background: linear-gradient(
            45deg,
            transparent 30%,
            var(--tile-blocked-x-color) 30%,
            var(--tile-blocked-x-color) 70%,
            transparent 70%
        ),
        linear-gradient(
            -45deg,
            transparent 30%,
            var(--tile-blocked-x-color) 30%,
            var(--tile-blocked-x-color) 70%,
            transparent 70%
        );
    transform: translate(-50%, -50%);
}

.gem.tile-BLOCKED_MOVABLE::after {
    content: "↔";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40cqw;
    padding-bottom: 0.8rem;
    color: var(--tile-blocked-movable-icon-color);
    font-weight: bold;
    z-index: 1;
    opacity: 0.7;
}

.gem.matched {
    animation: match-animation 0.5s ease-out forwards;
}

.gem.sliding {
    z-index: 20;
    transition: transform 0.4s ease-out, opacity 0.3s ease-out;
}

.gem.merge-target {
    animation: merge-pulse 0.4s ease-in forwards;
}

/* .gem.falling animation is now handled via inline styles in animator.js */

.gem.new-gem {
    opacity: 0; /* Start invisible until animation begins */
    animation: new-gem-animation 0.4s ease-in forwards;
}

.bottom-container {
    min-height: 18vw;
}

.controls {
    display: flex;
    gap: clamp(6px, 2vw, 10px);
    justify-content: center;
    flex-shrink: 0;
    align-items: center;
}

.control-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: clamp(8px, 2vw, 12px) clamp(16px, 4vw, 24px);
    border-radius: 16px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    font-family: Nunito;
    font-weight: 900;
    border: none;
}

.next {
    background: #aee96b;
    box-shadow: 0 -4px 0 0 rgba(0, 0, 0, 0.25) inset;
    color: black;
    border: 2px solid black;
}

.continue {
    background: #141414;
    box-shadow: 0 -4px 0 0 rgba(0, 0, 0, 0.25) inset;
    color: white;
}

/* Power-ups */
.power-ups {
    display: flex;
    gap: clamp(8px, 2vw, 16px);
    justify-content: center;
}

.power-up-btn {
    width: clamp(60px, 20vw, 120px);
    height: clamp(60px, 20vw, 120px);
    border-radius: 24px;
    border: 4px solid #000;
    background: #141414;
    color: white;
    font-size: clamp(16px, 8vw, 50px);
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.power-up-btn:active {
    transform: translateY(0) scale(0.98);
}

.power-up-btn.active {
    background: #aee96b;
    /* border-color: #277229; */
    box-shadow: 0 -6px 0 0 rgba(0, 0, 0, 0.25) inset;
}

.power-up-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Power-up use indicator */
.use-indicator {
    position: absolute;
    top: -10%;
    right: -10%;
    width: clamp(26px, 8vw, 50px);
    height: clamp(26px, 8vw, 50px);
    background: #ff401a;
    box-shadow: 0 -0.5vw 0 0 rgba(0, 0, 0, 0.25) inset;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #902009;
    z-index: 10;

    color: #fff;
    /* text-shadow: -2px -2px 0 black, 2px -2px 0 black, -2px 2px 0 black, 2px 2px 0 black; */
    font-family: Nunito;
    font-size: 16px;
    font-weight: 900;
}

/* Power-up visual feedback */
.gem.selected {
    border: 3px solid #4caf50;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.8);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes match-animation {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.8;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

@keyframes fall-animation {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes new-gem-animation {
    0% {
        transform: translateY(-150px) scale(0.8);
        opacity: 0;
    }
    80% {
        transform: translateY(0px) scale(1.05);
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.gem.tile-to-blocked {
    animation: tile-to-blocked-animation 0.4s ease-in-out forwards;
}

@keyframes tile-to-blocked-animation {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    51% {
        /* Change to blocked tile appearance at peak of bump */
        background: var(--tile-blocked-bg);
        color: transparent;
        border: 2px solid var(--tile-blocked-border);
    }
    100% {
        transform: scale(1);
        background: var(--tile-blocked-bg);
        color: transparent;
        border: 2px solid var(--tile-blocked-border);
    }
}

@keyframes merge-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    30% {
        transform: scale(1.1);
        box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
    }
    60% {
        transform: scale(1.2);
        box-shadow: 0 6px 16px rgba(255, 255, 255, 0.4);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
}

/* Introduction Dialog Styles */
.intro-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.intro-dialog {
    background: #ffffff;
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes unblock-move {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(0.8);
        opacity: 0.7;
    }
    100% {
        transform: scale(0.3);
        opacity: 0;
    }
}

.intro-header {
    background: #222 url("assets/bg.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: white;
    padding: 20px;
    border-radius: 20px 20px 0 0;
    position: relative;
}

.intro-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
}

.intro-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: #776e65;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.intro-content {
    padding: 20px;
    color: #333;
    overflow-y: auto;
}

.intro-section {
    margin-bottom: 20px;
}

.intro-section h3 {
    color: #667eea;
    margin: 0 0 10px 0;
    font-size: 1.2rem;
}

.intro-section h4 {
    margin: 15px 0 8px 0;
    font-size: 1rem;
}

.intro-section p {
    margin: 0 0 10px 0;
    line-height: 1.5;
}

.intro-section ul {
    margin: 10px 0;
    padding-left: 20px;
}

.intro-section li {
    margin: 5px 0;
    line-height: 1.4;
}

.formation-example {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    margin: 15px 0;
    border-left: 4px solid #667eea;
}

.formation-example h4 {
    margin: 0 0 10px 0;
    color: #555;
    font-size: 1rem;
}

.formation-example p {
    margin: 10px 0 0 0;
    font-size: 0.9rem;
    color: #666;
    font-weight: bold;
}

.example-grid {
    background-color: #30303044;
    border-radius: 6px;
    padding: 4px;
}

.example-tiles {
    display: flex;
    align-items: center;
    gap: 1px;
    flex-wrap: wrap;
}

.example-formations-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 10px 0px;
}

.example-result-row {
    display: flex;
    align-items: center;
}

.grid-row {
    display: flex;
    gap: 2px;
    margin-bottom: 2px;
}

.example-tile {
    width: 30px;
    height: 30px;
    background: #eee4da;
    color: #776e65;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.example-tile.target-highlight {
    width: 30px;
    height: 30px;
    box-shadow: 0px 0px 0px 3px #f59563;
    z-index: 2;
}

.example-tile.highlight {
    background: #f59563;
    color: white;
    box-shadow: 0 4px 8px rgba(246, 124, 95, 0.4);
}

.grid-row span:empty {
    width: 30px;
    height: 30px;
    display: inline-block;
}

.example-result {
    display: inline-block;
    margin: 10px;
}

.arrow {
    font-size: 28px;
    color: #667eea;
    font-weight: bold;
    margin: 0 10px;
    padding-bottom: 5px;
}

/* Power-up info styling */
.powerup-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.powerup-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
}

.powerup-icon {
    font-size: 24px;
    width: 32px;
    text-align: center;
}

.powerup-info {
    flex: 1;
    font-size: 14px;
    line-height: 1.3;
}

.powerup-info strong {
    color: #333;
}

.intro-footer {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 0 0 20px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #e9ecef;
}

.intro-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: #666;
}

.intro-checkbox input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-radius: 3px;
    margin-right: 8px;
    position: relative;
    transition: all 0.2s;
}

.intro-checkbox input[type="checkbox"]:checked + .checkmark {
    background: #667eea;
    border-color: #667eea;
}

.intro-checkbox input[type="checkbox"]:checked + .checkmark::after {
    content: "✓";
    color: white;
    font-size: 12px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

.intro-button {
    background: #aee96b;
    box-shadow: 0 -4px 0 0 rgba(0, 0, 0, 0.25) inset;
    color: black;
    border-radius: 10px;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.intro-button:active {
    transform: translateY(0);
}

/* Hide dialog by default */
.intro-dialog-overlay.hidden {
    display: none;
}

/* Extra Moves Dialog Styles */
.extra-moves-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #222 url("assets/bg.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    backdrop-filter: blur(8px);
}

.extra-moves-dialog-overlay.hidden {
    display: none;
}

.extra-moves-dialog {
    max-width: 500px;
    width: 90%;
    animation: slideIn 0.3s ease-out;
    overflow: hidden;

    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 40px 0;
}

.extra-moves-header {
    /* background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%); */
    color: white;
    padding: 30px 20px;
    text-align: center;
    font-family: Nunito;
    font-weight: 900;
    flex: 1;
}

.extra-moves-header h2 {
    margin: 0 0 10px 0;
    font-size: 1.8rem;
    font-weight: bold;
}

.extra-moves-header p {
    margin: 0;
    font-size: 1rem;
    opacity: 0.95;
}

.extra-moves-content {
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
}

.button-container {
    position: relative;
    font-family: Nunito;
    font-weight: 900;
}

.button-container svg {
    position: absolute;
    top: -20px;
    right: 0;
    pointer-events: none;
}

.extra-move-option {
    border: none;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
    width: 100%;

    font-family: Nunito;
    font-weight: 900;
    font-size: 40px;
    border-radius: 24px;
}

.extra-move-option:active {
    transform: translateY(0);
}

.extra-move-option.primary {
    background: #aee96b;
    box-shadow: 0 -8px 0 0 rgba(0, 0, 0, 0.25) inset;
    border: 3px solid #000;
    color: black;
}

.extra-move-option.primary-alt {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.extra-move-option.secondary {
    border-radius: 24px;
    border: 3px solid #000;
    background: #141414;
    box-shadow: 0 -9px 0 0 rgba(255, 255, 255, 0.1) inset;
    color: rgba(255, 255, 255, 0.5);
}

.extra-move-option.tertiary {
    border-radius: 15px;
    border: 2px solid #000;
    background: #141414;
    width: fit-content;
    color: white;
    padding: 8px 15px;
    font-size: 26px;
    margin: 0 auto;
}

.extra-move-option.tertiary.hidden {
    display: none;
}

.option-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.option-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 4px;
}

.option-subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Settings Dialog Styles */
.settings-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.settings-dialog-overlay.hidden {
    display: none;
}

.settings-dialog {
    background: #ffffff;
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
}

.settings-header {
    background: #222 url("assets/bg.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: white;
    padding: 20px;
    border-radius: 20px 20px 0 0;
}

.settings-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: bold;
}

.settings-content {
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    flex: 1;
}

.settings-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #667eea;
    margin-top: 10px;
    margin-bottom: -10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
}

.setting-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.setting-item label {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    flex: 2;
}

.setting-item select {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 0;
    flex: 3;
    color: black;
}

.setting-item select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.settings-footer {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 0 0 20px 20px;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid #e9ecef;
}

.settings-button {
    background: #aee96b;
    box-shadow: 0 -4px 0 0 rgba(0, 0, 0, 0.25) inset;
    color: black;
    border-radius: 10px;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-button:active {
    transform: translateY(0);
}

.settings-button.reset-button {
    background: #ff401a;
    box-shadow: 0 -5px 0 0 #00000040 inset;
}

/* Checkbox styling for settings */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    gap: 12px;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 22px;
    height: 22px;
    border: 2px solid #ddd;
    border-radius: 6px;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: #667eea;
    border-color: #667eea;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: "✓";
    color: white;
    font-size: 14px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

/* Special tile help text */
.special-tile-help {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #555;
    margin-top: -10px;
}

.special-tile-help strong {
    color: #333;
    font-weight: 600;
}

/* User ID display in settings */
.user-id-display {
    margin-top: 10px;
    padding: 12px;
    background: #f0f0f0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd;
}

.user-id-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-id-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-id-copy-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.user-id-copy-btn:active {
    transform: translateY(0);
}

.user-id-value {
    flex: 1;
    margin-left: 8px;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.75rem;
    color: #333;
    word-break: break-all;
    user-select: all;
}

.version-display {
    display: flex;
    align-items: center;
    padding-top: 8px;
    margin-top: 8px;
    border-top: 1px solid #ddd;
}

.version-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.version-value {
    margin-left: 8px;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.75rem;
    color: #333;
    font-weight: 500;
}

/* Safari-specific viewport fixes */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
        padding-top: env(safe-area-inset-top, 10px);
    }

    .game-container {
        justify-content: flex-start;
    }
}

.invalid-swap {
    z-index: 100;
    box-shadow: 0 4px 12px rgba(255, 100, 100, 0.4);
    filter: brightness(1.1);
}

/* Goal Dialog Styles */
.goal-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1002;
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.goal-dialog-overlay.visible {
    opacity: 1;
}

.goal-dialog-overlay.hidden {
    display: none;
}

.goal-dialog {
    background: #ffffff;
    border-radius: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.goal-dialog-header {
    background: #222 url("assets/bg.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: white;
    padding: 25px 20px;
    border-radius: 24px 24px 0 0;
    text-align: center;
    position: relative;
}

.goal-dialog-header h2 {
    font-size: 1.5rem;
    font-weight: bold;
}

.goal-dialog-header h3 {
    font-weight: normal;
    opacity: 0.8;
    margin-top: 6px;
}

.goal-dialog-goals {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.goal-dialog-goals .goal-icon {
    background: white;
}

.goal-dialog-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    animation: bounceIn 0.5s ease-out;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

.goal-dialog-goals .goal-card {
    animation: bounceIn 0.5s ease-out;
}

.goal-dialog-content {
    padding: 25px 20px;
    color: #333;
    flex: 1;
    overflow-y: auto;
}

.goal-dialog-content p {
    margin: 0 0 15px 0;
    line-height: 1.6;
}

.goal-dialog-content p:last-child {
    margin-bottom: 0;
}

.goal-dialog-content strong {
    color: #667eea;
    font-weight: 600;
}

.goal-dialog-content ul {
    margin: 15px 0;
    padding-left: 25px;
}

.goal-dialog-content li {
    margin: 8px 0;
    line-height: 1.5;
}

.goal-dialog-content em {
    display: block;
    margin-top: 15px;
    padding: 12px;
    background: #f0f4ff;
    border-left: 4px solid #667eea;
    border-radius: 8px;
    font-style: normal;
    color: #555;
}

.goal-dialog-footer {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 0 0 24px 24px;
    display: flex;
    justify-content: center;
    border-top: 1px solid #e9ecef;
}

.goal-dialog-button {
    background: #aee96b;
    box-shadow: 0 -4px 0 0 rgba(0, 0, 0, 0.25) inset;
    color: black;
    border: none;
    padding: 14px 32px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.goal-dialog-button:active {
    transform: translateY(0);
}
