@font-face {
    font-family: "GameFont";
    src: url("../fonts/Gilroy-Heavy.woff");
}

body {
    font-family: GameFont;
    background: #b6ab8a;
    background-attachment: fixed;
    /* Prevents pull-to-refresh on mobile */
    overscroll-behavior: none;
}

canvas {
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

@keyframes winCelebrate {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0px rgba(74, 222, 128, 0), inset 0 0 0px rgba(74, 222, 128, 0);
        border-color: #57534e;
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 25px 8px rgba(74, 222, 128, 0.8), inset 0 0 40px rgba(74, 222, 128, 0.6);
        border-color: #4ade80;
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0px rgba(74, 222, 128, 0), inset 0 0 0px rgba(74, 222, 128, 0);
        border-color: #57534e;
    }
}

.win-celebrate {
    animation: winCelebrate 1s ease-in-out;
}

@keyframes statSubtlePulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.04);
    }

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

.stat-subtle-pulse {
    animation: statSubtlePulse 0.3s ease-out;
}

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

    20% {
        transform: scale(1.08) rotate(-1.5deg);
    }

    40% {
        transform: scale(1.08) rotate(1.5deg);
    }

    60% {
        transform: scale(1.08) rotate(-1.5deg);
    }

    80% {
        transform: scale(1.08) rotate(1.5deg);
    }

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

.stat-urgent {
    animation: statUrgent 0.5s ease-in-out;
}

@keyframes numberDrop {
    0% {
        transform: scale(1.8);
        opacity: 0;
        text-shadow: 0px 10px 10px rgba(0, 0, 0, 0.3);
    }

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

.number-drop-anim {
    animation: numberDrop 0.8s cubic-bezier(0.2, 1.1, 0.4, 1) forwards;
}

/* --- Start Screen Styles --- */
#startScreen {
    position: fixed;
    inset: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    cursor: pointer;
}

.SymmetryPuzzle-container {
    position: relative;
    width: 780px;
    max-width: 90vw;
    pointer-events: none;
}

.SymmetryPuzzle-container svg {
    width: 100%;
    display: block;
}

.start-btn {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -55px;
    width: 220px;
    height: 54px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(68, 64, 60, 0.5);
    color: #44403c;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 5px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    pointer-events: auto;
    animation: startPulse 2.5s infinite ease-in-out;
}

.start-btn:hover {
    background: rgba(68, 64, 60, 0.85);
    color: #e7e5e4;
    border-color: #44403c;
}

.start-btn:active {
    background: #292524;
    border-color: #292524;
    transform: translateX(-50%) scale(0.98);
}

@keyframes startPulse {

    0%,
    100% {
        border-color: rgba(68, 64, 60, 0.5);
        box-shadow: 0 0 0 rgba(217, 119, 6, 0);
    }

    50% {
        border-color: rgba(217, 119, 6, 0.8);
        background: rgba(255, 255, 255, 0.25);
        box-shadow: 0 0 15px rgba(217, 119, 6, 0.3);
        text-shadow: 0 0 8px rgba(217, 119, 6, 0.2);
    }
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #57534e;
    border-radius: 20px;
}

:root {
    --game-bg: #172033;
    --game-bg-2: #24324d;

    --panel-bg: #22304a;
    --panel-bg-hover: #2e4266;
    --panel-border: #4f6f9f;

    --text-main: #f8fafc;
    --text-soft: #cbd5e1;

    --accent: #38bdf8;
    --accent-2: #facc15;
    --danger: #ef4444;

    --board-bg: #1e293b;
    --paper-fill: #e0f2fe;
    --paper-stroke: #38bdf8;
    --selected-fill: #facc15;
    --selected-stroke: #f59e0b;

    --play-shape-fill: #7dd3fc;
    --play-shape-fill-temp: #facc15;
    --play-shape-selected: #fb7185;

    --play-shape-stroke: #e0f2fe;
    --play-shape-stroke-temp: #f59e0b;
    --play-shape-stroke-selected: #ffffff;
}

body {
    background: radial-gradient(circle at top, var(--game-bg-2), var(--game-bg));
    color: var(--text-main);
}

/* Buttons / panels */
.bg-stone-700,
.bg-stone-800,
.bg-stone-600 {
    background-color: var(--panel-bg) !important;
}

.hover\:bg-stone-600:hover {
    background-color: var(--panel-bg-hover) !important;
}

.border-stone-600,
.border-stone-500,
.border-stone-700 {
    border-color: var(--panel-border) !important;
}

.text-stone-100,
.text-stone-200,
.text-stone-300,
.text-stone-400 {
    color: var(--text-soft) !important;
}

.text-amber-400,
.group-hover\:text-amber-400:hover,
.hover\:text-amber-400:hover {
    color: var(--accent-2) !important;
}

.focus\:ring-amber-500:focus {
    --tw-ring-color: var(--accent) !important;
}

.bg-amber-500 {
    background-color: var(--accent-2) !important;
}

.text-stone-900 {
    color: #111827 !important;
}

/* Start screen */
.start-btn {
    background: rgba(56, 189, 248, 0.14);
    border-color: rgba(56, 189, 248, 0.55);
    color: var(--text-main);
}

.start-btn:hover {
    background: var(--accent);
    color: #082f49;
    border-color: var(--accent);
}

/* Board wrappers */
#targetBox,
#paperBox {
    background-color: var(--panel-bg) !important;
    border-color: var(--panel-border) !important;
}

/* Modal */
#levelSelectModal {
    background-color: rgba(15, 23, 42, 0.96) !important;
}

#failModal {
    background-color: rgba(30, 41, 59, 0.88) !important;
}

#modeUnlockLocalModal {
    background-color: rgba(30, 41, 59, 0.92) !important;
}

.SymmetryPuzzle-container {
    position: relative;
    width: 820px;
    max-width: 92vw;
    padding: 34px 42px 72px;
    pointer-events: none;

    background: linear-gradient(
        135deg,
        rgba(15, 23, 42, 0.78),
        rgba(30, 41, 59, 0.52)
    );
    border: 1px solid rgba(125, 211, 252, 0.45);
    border-radius: 34px;

    box-shadow:
        0 28px 80px rgba(2, 6, 23, 0.48),
        0 0 55px rgba(56, 189, 248, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);

    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.SymmetryPuzzle-container::before {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: 36px;
    padding: 2px;
    background: linear-gradient(
        135deg,
        rgba(103, 232, 249, 0.9),
        rgba(250, 204, 21, 0.45),
        rgba(59, 130, 246, 0.65)
    );
    opacity: 0.75;
    pointer-events: none;

    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

.SymmetryPuzzle-container::after {
    content: "";
    position: absolute;
    inset: 18px;
    border-radius: 26px;
    background:
        radial-gradient(circle at 50% 0%, rgba(103, 232, 249, 0.18), transparent 46%),
        radial-gradient(circle at 80% 80%, rgba(250, 204, 21, 0.12), transparent 42%);
    pointer-events: none;
    z-index: -1;
}

.SymmetryPuzzle-container svg {
    width: 100%;
    display: block;
    position: relative;
    z-index: 1;
    filter:
        drop-shadow(0 12px 24px rgba(2, 6, 23, 0.38))
        drop-shadow(0 0 18px rgba(56, 189, 248, 0.18));
}

.start-btn {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 22px;
    width: 230px;
    height: 58px;

    background: linear-gradient(135deg, #38bdf8, #facc15);
    border: 0;
    color: #0f172a;

    font-size: 17px;
    font-weight: 900;
    letter-spacing: 5px;
    cursor: pointer;
    border-radius: 999px;

    box-shadow:
        0 14px 30px rgba(2, 6, 23, 0.35),
        0 0 28px rgba(56, 189, 248, 0.35);

    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
    pointer-events: auto;
    animation: startPulse 2.4s infinite ease-in-out;
    z-index: 2;
}

.start-btn:hover {
    filter: brightness(1.08) saturate(1.08);
    transform: translateX(-50%) translateY(-2px);
    box-shadow:
        0 18px 38px rgba(2, 6, 23, 0.42),
        0 0 36px rgba(250, 204, 21, 0.38);
}

.start-btn:active {
    transform: translateX(-50%) scale(0.97);
}

@keyframes startPulse {
    0%,
    100% {
        box-shadow:
            0 14px 30px rgba(2, 6, 23, 0.35),
            0 0 22px rgba(56, 189, 248, 0.25);
    }

    50% {
        box-shadow:
            0 18px 42px rgba(2, 6, 23, 0.45),
            0 0 42px rgba(250, 204, 21, 0.45);
    }
}

.mirror-logo {
    position: relative;
    z-index: 2;
    width: 100%;
    min-height: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
}

.mirror-shape {
    position: relative;
    width: 360px;
    height: 185px;
    max-width: 78vw;
    filter:
        drop-shadow(0 22px 36px rgba(2, 6, 23, 0.45))
        drop-shadow(0 0 28px rgba(56, 189, 248, 0.22));
}

.mirror-axis {
    position: absolute;
    left: 50%;
    top: -20px;
    bottom: -20px;
    width: 4px;
    transform: translateX(-50%);
    border-radius: 999px;
    background: linear-gradient(
        to bottom,
        transparent,
        rgba(224, 242, 254, 0.95),
        rgba(56, 189, 248, 0.95),
        rgba(224, 242, 254, 0.95),
        transparent
    );
    box-shadow:
        0 0 18px rgba(56, 189, 248, 0.8),
        0 0 38px rgba(56, 189, 248, 0.45);
}

.mirror-axis::before,
.mirror-axis::after {
    content: "";
    position: absolute;
    left: 50%;
    width: 28px;
    height: 28px;
    transform: translateX(-50%) rotate(45deg);
    border: 3px solid rgba(224, 242, 254, 0.9);
    background: rgba(15, 23, 42, 0.65);
    box-shadow: 0 0 18px rgba(56, 189, 248, 0.45);
}

.mirror-axis::before {
    top: -8px;
}

.mirror-axis::after {
    bottom: -8px;
}

.shape-piece {
    position: absolute;
    top: 22px;
    width: 145px;
    height: 145px;
    border-radius: 28px;
    transform: rotate(45deg);
    overflow: hidden;
}

.shape-piece::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.32), transparent 38%),
        linear-gradient(315deg, rgba(2, 6, 23, 0.35), transparent 48%);
    z-index: 2;
}

.shape-piece::after {
    content: "";
    position: absolute;
    inset: 13px;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.32);
    box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.12);
    z-index: 3;
}

.shape-piece span {
    position: absolute;
    inset: 0;
    display: block;
    background:
        radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.45), transparent 26%),
        linear-gradient(135deg, #facc15, #f59e0b);
}

.shape-left {
    left: 24px;
    border: 4px solid rgba(250, 204, 21, 0.95);
    box-shadow:
        0 18px 34px rgba(2, 6, 23, 0.34),
        0 0 28px rgba(250, 204, 21, 0.35),
        inset 0 0 22px rgba(255, 255, 255, 0.18);
}

.shape-right {
    right: 24px;
    border: 4px solid rgba(103, 232, 249, 0.95);
    box-shadow:
        0 18px 34px rgba(2, 6, 23, 0.34),
        0 0 28px rgba(56, 189, 248, 0.38),
        inset 0 0 22px rgba(255, 255, 255, 0.18);
}

.shape-right span {
    background:
        radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.42), transparent 26%),
        linear-gradient(135deg, #67e8f9, #0ea5e9);
}

.shape-left::before {
    clip-path: polygon(0 0, 68% 0, 100% 32%, 100% 100%, 0 100%);
}

.shape-right::before {
    clip-path: polygon(32% 0, 100% 0, 100% 100%, 0 100%, 0 32%);
}

.mirror-glow {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 260px;
    height: 120px;
    transform: translate(-50%, -50%);
    border-radius: 999px;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.24), transparent 68%);
    filter: blur(8px);
    z-index: -1;
}

.mirror-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    font-size: clamp(34px, 6vw, 64px);
    line-height: 1;
    letter-spacing: 6px;
    text-align: center;
    text-shadow:
        0 8px 22px rgba(2, 6, 23, 0.55),
        0 0 18px rgba(56, 189, 248, 0.18);
}

.mirror-title span {
    color: #e0f2fe;
    font-weight: 900;
}

.mirror-title strong {
    color: #facc15;
    font-weight: 900;
}

.mirror-subtitle {
    margin-top: -4px;
    color: rgba(203, 213, 225, 0.82);
    font-size: clamp(11px, 2vw, 15px);
    letter-spacing: 6px;
    text-align: center;
}

/* Mobile */
@media (max-width: 640px) {
    .mirror-logo {
        min-height: 300px;
        gap: 14px;
    }

    .mirror-shape {
        width: 285px;
        height: 155px;
    }

    .shape-piece {
        width: 116px;
        height: 116px;
        border-radius: 23px;
    }

    .shape-left {
        left: 18px;
    }

    .shape-right {
        right: 18px;
    }

    .mirror-title {
        flex-direction: column;
        gap: 4px;
        letter-spacing: 5px;
    }

    .mirror-subtitle {
        letter-spacing: 4px;
    }
}