@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    overflow: hidden;
    cursor: crosshair;
    background: #0f0f23;
    position: relative;
    width: 100vw;
    height: 100vh;
    touch-action: none;
    /* Critical for mobile touch control */
    user-select: none;
    /* Prevent text selection */
    -webkit-user-select: none;
}

.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a3e 25%, #2d1b4e 50%, #1a1a3e 75%, #0f0f23 100%);
    animation: gradientShift 15s ease infinite;
    z-index: -1;
}

@keyframes gradientShift {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

/* Game UI */
.game-ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 100;
    pointer-events: none;
}

.ui-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

/* Tail Length Display */
.tail-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.tail-length {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 8px rgba(167, 139, 250, 0.4));
}

.tail-length.grow {
    animation: tailGrow 0.5s ease;
}

@keyframes tailGrow {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

/* Level Badge */
.level-container {
    display: flex;
    justify-content: center;
    flex: 1;
}

.level-badge {
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.2), rgba(236, 72, 153, 0.2));
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 12px 30px;
    box-shadow: 0 8px 32px rgba(167, 139, 250, 0.3);
    animation: badgePulse 2s ease-in-out infinite;
}

.level-badge.medium {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(236, 72, 153, 0.2));
    box-shadow: 0 8px 32px rgba(245, 158, 11, 0.3);
}

.level-badge.fast {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(236, 72, 153, 0.2));
    box-shadow: 0 8px 32px rgba(239, 68, 68, 0.3);
    animation: badgePulseFast 1s ease-in-out infinite;
}

@keyframes badgePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes badgePulseFast {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

.level-text {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 3px;
}

/* Score Display */
.score-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.score {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa, #ec4899, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 12px rgba(167, 139, 250, 0.5));
}

.score.score-increase {
    animation: scorePopup 0.5s ease;
}

@keyframes scorePopup {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

/* Modal Overlays */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 35, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, rgba(26, 26, 62, 0.9), rgba(45, 27, 78, 0.9));
    border: 2px solid rgba(167, 139, 250, 0.3);
    border-radius: 30px;
    padding: 50px 60px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 500px;
}

.game-title {
    font-size: 3.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa, #ec4899, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
    filter: drop-shadow(0 4px 12px rgba(167, 139, 250, 0.5));
}

.game-description {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 30px;
}

.instructions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 40px;
    text-align: left;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(167, 139, 250, 0.1);
    padding: 15px 20px;
    border-radius: 15px;
    border: 1px solid rgba(167, 139, 250, 0.2);
}

.instruction-icon {
    font-size: 1.8rem;
}

.game-button {
    background: linear-gradient(135deg, #a78bfa, #ec4899);
    color: white;
    border: none;
    padding: 18px 50px;
    font-size: 1.3rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(167, 139, 250, 0.4);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-family: 'Outfit', sans-serif;
    transition: all 0.3s ease;
}

.game-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(167, 139, 250, 0.6);
}

.final-score-container {
    margin: 30px 0;
}

.final-score-label {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.final-score {
    font-size: 5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa, #ec4899, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 12px rgba(167, 139, 250, 0.5));
}

.final-tail,
.final-level {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 10px;
}

/* Level Up Notification */
.level-up-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    animation: levelUpAppear 2s ease forwards;
}

.level-up-notification.hidden {
    display: none;
}

@keyframes levelUpAppear {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }

    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

.level-up-content {
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.95), rgba(236, 72, 153, 0.95));
    padding: 40px 60px;
    border-radius: 25px;
    box-shadow: 0 20px 60px rgba(167, 139, 250, 0.6);
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.level-up-title {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    margin-bottom: 10px;
}

.level-up-text {
    font-size: 2rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 3px;
}

/* Cat */
.cat-container {
    position: absolute;
    width: 80px;
    height: 80px;
    pointer-events: none;
    z-index: 100;
    filter: drop-shadow(0 8px 20px rgba(167, 139, 250, 0.4));
}

.cat-body {
    position: relative;
    width: 100%;
    height: 100%;
}

.cat-head {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #ff9a56, #ffb380);
    border-radius: 50%;
    z-index: 10;
}

.ear {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 18px solid #ff9a56;
}

.ear-left {
    top: -12px;
    left: 5px;
    transform: rotate(-15deg);
}

.ear-right {
    top: -12px;
    right: 5px;
    transform: rotate(15deg);
}

.face {
    position: relative;
    width: 100%;
    height: 100%;
}

.eye {
    position: absolute;
    top: 15px;
    width: 8px;
    height: 10px;
    background: white;
    border-radius: 50%;
}

.eye-left {
    left: 12px;
}

.eye-right {
    right: 12px;
}

.pupil {
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 6px;
    background: #1a1a3e;
    border-radius: 50%;
}

.nose {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 5px;
    background: #ff6b9d;
    border-radius: 50%;
}

.mouth {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 6px;
}

.mouth-left,
.mouth-right {
    position: absolute;
    top: 0;
    width: 8px;
    height: 5px;
    border: 1.5px solid #ff6b9d;
    border-top: none;
}

.mouth-left {
    left: 0;
    border-right: none;
    border-radius: 0 0 0 100%;
}

.mouth-right {
    right: 0;
    border-left: none;
    border-radius: 0 0 100% 0;
}

.whiskers {
    position: absolute;
    top: 18px;
}

.whiskers-left {
    left: -12px;
}

.whiskers-right {
    right: -12px;
}

.whisker {
    width: 15px;
    height: 1px;
    background: rgba(255, 255, 255, 0.6);
    margin: 3px 0;
    border-radius: 2px;
}

.body {
    position: absolute;
    top: 45px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 35px;
}

.body-main {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ff9a56, #ffb380);
    border-radius: 50%;
}

.leg {
    position: absolute;
    width: 6px;
    height: 15px;
    background: linear-gradient(180deg, #ff9a56, #ffb380);
    border-radius: 3px;
}

.leg-front-left {
    bottom: -12px;
    left: 10px;
}

.leg-front-right {
    bottom: -12px;
    right: 10px;
}

.leg-back-left {
    bottom: -12px;
    left: 2px;
}

.leg-back-right {
    bottom: -12px;
    right: 2px;
}

.tail {
    position: absolute;
    bottom: 8px;
    right: -18px;
    width: 25px;
    height: 20px;
}

.tail-segment {
    position: absolute;
    background: linear-gradient(135deg, #ff9a56, #ffb380);
    border-radius: 50%;
}

.tail-1 {
    bottom: 0;
    right: 10px;
    width: 10px;
    height: 14px;
}

.tail-2 {
    bottom: 8px;
    right: 5px;
    width: 8px;
    height: 12px;
}

.tail-3 {
    bottom: 14px;
    right: 0;
    width: 6px;
    height: 10px;
}

.shadow {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 8px;
    background: radial-gradient(ellipse, rgba(0, 0, 0, 0.3), transparent);
    border-radius: 50%;
}

/* Mouse Sprite */
.mouse {
    position: absolute;
    width: 25px;
    height: 25px;
    background: linear-gradient(135deg, #94a3b8, #cbd5e1);
    border-radius: 50% 50% 45% 45%;
    pointer-events: none;
    z-index: 50;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    animation: mouseWiggle 0.5s ease-in-out infinite;
}

.mouse::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 4px;
    width: 10px;
    height: 10px;
    background: #cbd5e1;
    border-radius: 50% 50% 0 0;
}

.mouse::after {
    content: '';
    position: absolute;
    top: -6px;
    right: 4px;
    width: 10px;
    height: 10px;
    background: #cbd5e1;
    border-radius: 50% 50% 0 0;
}

@keyframes mouseWiggle {

    0%,
    100% {
        transform: rotate(-3deg);
    }

    50% {
        transform: rotate(3deg);
    }
}

/* Tail Segments (Game) */
.tail-segment-game {
    position: absolute;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #ff9a56, #ffb380);
    border-radius: 50%;
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Difficulty Selection */
.difficulty-selection {
    margin-top: 30px;
}

.difficulty-title {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 20px;
}

.difficulty-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.difficulty-button {
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.2), rgba(236, 72, 153, 0.2));
    border: 2px solid rgba(167, 139, 250, 0.3);
    border-radius: 20px;
    padding: 20px 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 140px;
}

.difficulty-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(167, 139, 250, 0.4);
    border-color: rgba(167, 139, 250, 0.6);
}

.diff-icon {
    font-size: 2.5rem;
}

.diff-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
}

.diff-desc {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

.easy-btn:hover {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.3), rgba(167, 139, 250, 0.3));
}

.medium-btn:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(236, 72, 153, 0.3));
}

.hard-btn:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.3), rgba(236, 72, 153, 0.3));
}

/* Timer and Missed */
.center-ui,
.left-ui,
.right-ui {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.timer-container,
.missed-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.timer,
.missed {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #f59e0b, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 8px rgba(245, 158, 11, 0.4));
}

.timer.warning {
    animation: timerWarning 0.5s ease-in-out infinite;
}

@keyframes timerWarning {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
        color: #ef4444;
    }
}

/* Game Over Reason */
.game-over-reason {
    font-size: 1.5rem;
    color: rgba(255, 68, 68, 0.9);
    margin-bottom: 20px;
    font-weight: 600;
}

.final-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.final-stat {
    display: flex;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(167, 139, 250, 0.1);
    border-radius: 10px;
}

.stat-label {
    color: rgba(255, 255, 255, 0.7);
}

.stat-value {
    color: white;
    font-weight: 600;
}

/* Developer Credit */
.developer-credit {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    z-index: 1000;
    font-family: 'Outfit', sans-serif;
    background: rgba(15, 15, 35, 0.6);
    padding: 8px 15px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.developer-credit a {
    color: #ec4899;
    text-decoration: none;
    font-weight: 700;
    transition: color 0.3s ease;
}

.developer-credit a:hover {
    color: #a78bfa;
    text-decoration: underline;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .game-ui {
        padding: 10px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        gap: 10px;
        align-items: start;
    }

    .left-ui {
        grid-column: 1;
        grid-row: 1;
        align-items: flex-start;
        gap: 5px;
    }

    .right-ui {
        grid-column: 2;
        grid-row: 1;
        align-items: flex-end;
        gap: 5px;
    }

    .center-ui {
        grid-column: 1 / -1;
        grid-row: 2;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 20px;
        margin-top: 5px;
    }

    .ui-label {
        font-size: 0.6rem;
        margin-bottom: 0;
    }

    .score,
    .tail-length,
    .timer,
    .missed {
        font-size: 1.2rem;
    }

    .level-badge {
        padding: 5px 15px;
    }

    .level-text {
        font-size: 0.9rem;
    }

    /* Modal Adjustments */
    .modal-content {
        padding: 20px;
        width: 95%;
        max-width: 350px;
        max-height: 95vh;
        overflow-y: auto;
    }

    .game-title {
        font-size: 1.8rem;
        margin-bottom: 10px;
    }

    .game-description {
        font-size: 1rem;
        margin-bottom: 15px;
    }

    .difficulty-buttons {
        gap: 8px;
    }

    .difficulty-button {
        padding: 10px;
        min-width: 80px;
        flex: 1;
    }

    .diff-icon {
        font-size: 1.5rem;
    }

    .diff-name {
        font-size: 0.9rem;
    }

    .diff-desc {
        font-size: 0.7rem;
    }

    .instructions {
        gap: 8px;
        margin-bottom: 15px;
    }

    .instruction-item {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .instruction-icon {
        font-size: 1.2rem;
    }

    /* Cat Size Mobile */
    .cat-container {
        transform: scale(0.7);
    }
}