:root {
    --sky: #b8e8ff;
    --sand: #f5d9a8;
    --sun: #ffe08a;
    --leaf: #9ee4b0;
    --pink: #ffc9e0;
    --ink: #1e3d52;
    --white: #ffffff;
    --ok: #2ecc71;
    --err: #e74c3c;
    --shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
    --radius-xl: 28px;
    --radius-lg: 18px;
    --radius-md: 14px;
}



* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Comic Neue', cursive;
    color: var(--ink);
    background: linear-gradient(180deg, var(--sky) 0%, var(--sun) 45%, var(--sand) 100%);
    display: grid;
    place-items: center;
    padding: 12px;
}

.app {
    width: min(1100px, 100%);
    background: rgba(255, 255, 255, 0.42);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    border: 3px solid rgba(255, 255, 255, 0.65);
    overflow: hidden;
}

.screen {
    display: none;
    padding: clamp(14px, 3vw, 26px);
    animation: fadeIn 0.45s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-8px);
    }

    40% {
        transform: translateX(8px);
    }

    60% {
        transform: translateX(-6px);
    }

    80% {
        transform: translateX(6px);
    }
}

@keyframes snapPop {
    0% {
        transform: scale(0.7);
    }

    60% {
        transform: scale(1.12);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.5);
    }

    50% {
        box-shadow: 0 0 0 12px rgba(46, 204, 113, 0);
    }
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(120px) rotate(360deg);
        opacity: 0;
    }
}

.float {
    animation: float 2.8s ease-in-out infinite;
}

.pulse {
    animation: pulse 1.9s ease-in-out infinite;
}

.shake {
    animation: shake 0.45s ease;
}

.snap-pop {
    animation: snapPop 0.45s ease;
}

.glow {
    animation: glow 1.2s ease 2;
}

/* —— Form —— */
.form-card {
    margin: 0 auto;
    width: min(620px, 100%);
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    padding: clamp(20px, 4vw, 34px);
    text-align: center;
}

.title {
    margin: 4px 0;
    font-size: clamp(1.7rem, 5vw, 2.1rem);
    color: #0f5f7a;
    line-height: 1.15;
}

.sub {
    margin: 0 0 16px;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: #4a7a94;
}

.icon {
    font-size: clamp(2.4rem, 9vw, 3.6rem);
    margin-bottom: 6px;
}

.field {
    text-align: left;
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 6px;
    color: #2f6f8a;
}

.field input {
    width: 100%;
    border: 3px solid #cdefff;
    border-radius: var(--radius-md);
    font-size: 1.15rem;
    padding: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
    border-color: #5ec4ff;
    box-shadow: 0 0 0 4px rgba(94, 196, 255, 0.25);
}

.field input.invalid {
    border-color: var(--err);
}

.main-btn {
    width: 100%;
    border: none;
    border-radius: 999px;
    font-family: inherit;
    font-size: clamp(1.2rem, 3.5vw, 1.55rem);
    font-weight: 800;
    background: linear-gradient(140deg, #5ed4ff, #ffd966);
    color: #0d3f56;
    padding: 14px 18px;
    box-shadow: 0 7px 0 #4eb0d4;
    cursor: pointer;
    transition: transform 0.12s;
}

.main-btn:active {
    transform: translateY(3px);
    box-shadow: 0 4px 0 #4eb0d4;
}

.error-msg {
    min-height: 26px;
    margin-top: 10px;
    color: var(--err);
    font-size: 1.05rem;
    font-weight: 700;
}

/* —— Game —— */
.game-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.game-header h2 {
    margin: 0;
    font-size: clamp(1.4rem, 4vw, 2rem);
    color: #0c5f7f;
}

.score-pill {
    background: var(--white);
    border-radius: 999px;
    padding: 8px 18px;
    font-size: clamp(1rem, 2.8vw, 1.25rem);
    font-weight: 800;
    color: #0a6b8f;
    border: 3px solid #b8ecff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.hint {
    margin: 0 0 10px;
    font-size: clamp(0.95rem, 2.4vw, 1.1rem);
    color: #3d6d86;
    text-align: center;
}

.game-layout {
    display: grid;
    grid-template-columns: 1fr minmax(200px, 260px);
    gap: 14px;
    align-items: start;
}

.map-panel {
    background: linear-gradient(165deg, #e8c98a 0%, #d4a96a 35%, #c9e6b5 70%, #a8d4f0 100%);
    border-radius: var(--radius-lg);
    border: 4px solid rgba(255, 255, 255, 0.85);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.map-panel svg {
    display: block;
    width: 100%;
    height: auto;
    touch-action: none;
    user-select: none;
}

.route-path {
    fill: none;
    stroke: #c45c26;
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 14 8;
    opacity: 0.9;
}

.route-glow {
    fill: none;
    stroke: rgba(255, 200, 100, 0.45);
    stroke-width: 12;
    stroke-linecap: round;
}

.zone-ring {
    fill: rgba(255, 255, 255, 0.75);
    stroke: #3d9fd4;
    stroke-width: 3;
    stroke-dasharray: 6 4;
    transition: fill 0.25s, stroke 0.25s;
}

.zone-ring.filled {
    fill: rgba(46, 204, 113, 0.35);
    stroke: var(--ok);
    stroke-dasharray: none;
}

.zone-ring.hover-target {
    fill: rgba(94, 196, 255, 0.35);
    stroke: #2a9fd4;
}

.zone-label {
    font-family: "Baloo 2", sans-serif;
    font-size: 11px;
    font-weight: 700;
    fill: #1a4a62;
    text-anchor: middle;
    pointer-events: none;
}

.check-mark {
    font-size: 18px;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.check-mark.show {
    opacity: 1;
}

.placed-token {
    pointer-events: none;
}

.tray-panel {
    background: rgba(255, 255, 255, 0.92);
    border-radius: var(--radius-lg);
    border: 3px solid #d4f0ff;
    padding: 12px;
    box-shadow: var(--shadow);
}

.tray-panel h3 {
    margin: 0 0 10px;
    font-size: 1.15rem;
    color: #1a6585;
    text-align: center;
}

.tray {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: min(520px, 58vh);
    overflow-y: auto;
    padding-right: 4px;
}

.drag-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--white);
    border: 3px solid #d8f2ff;
    border-radius: var(--radius-md);
    padding: 8px 10px;
    cursor: grab;
    font-size: 0.95rem;
    font-weight: 700;
    color: #2a5f78;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    touch-action: none;
}

.drag-item:hover:not(.placed):not(.dragging) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
    border-color: #7ed0ff;
}

.drag-item.dragging {
    opacity: 0.35;
    cursor: grabbing;
}

.drag-item.placed {
    opacity: 0.45;
    cursor: default;
    text-decoration: line-through;
}

.drag-item .emoji {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.drag-ghost {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--white);
    border: 3px solid #5ec4ff;
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-family: "Baloo 2", sans-serif;
    font-size: 1rem;
    font-weight: 800;
    color: #1a5f7a;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
    transform: translate(-50%, -50%);
}

.feedback-bar {
    margin-top: 12px;
    min-height: 56px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--radius-md);
    border: 3px solid #d4f0ff;
    padding: 10px 14px;
    text-align: center;
    font-size: clamp(1rem, 2.6vw, 1.2rem);
    font-weight: 700;
    color: #1a7a4a;
    transition: color 0.2s, border-color 0.2s;
}

.feedback-bar.wrong {
    color: var(--err);
    border-color: #ffc9c9;
}

.feedback-bar.success {
    color: #16884a;
    border-color: #a8e6c4;
}

/* —— Completion overlay —— */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 55, 75, 0.72);
    display: none;
    place-items: center;
    z-index: 2000;
    padding: 14px;
}

.overlay.show {
    display: grid;
}

.popup {
    width: min(560px, 96vw);
    background: var(--white);
    border-radius: var(--radius-xl);
    border: 4px solid #c8f0ff;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    text-align: center;
    padding: clamp(22px, 5vw, 38px);
    position: relative;
    overflow: hidden;
}

.popup h2 {
    margin: 0 0 8px;
    font-size: clamp(2rem, 6vw, 2.8rem);
    color: #0a6b8f;
}

.popup .final-score {
    font-size: clamp(1.3rem, 4vw, 1.8rem);
    color: #2d8a4e;
    font-weight: 800;
    margin: 8px 0;
}

.popup p {
    margin: 0 0 16px;
    font-size: clamp(1.05rem, 3vw, 1.25rem);
    color: #456d82;
}

.celebration {
    font-size: 2rem;
    letter-spacing: 6px;
    margin-bottom: 10px;
}

.celebration span {
    display: inline-block;
    animation: confettiFall 1.4s ease infinite;
}

.celebration span:nth-child(2) {
    animation-delay: 0.2s;
}

.celebration span:nth-child(3) {
    animation-delay: 0.4s;
}

.celebration span:nth-child(4) {
    animation-delay: 0.15s;
}

.celebration span:nth-child(5) {
    animation-delay: 0.35s;
}

@media (max-width: 820px) {

    body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .app {
        overflow: visible;
    }

    .game-layout {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .map-panel {
        overflow: visible;
    }

    .tray-panel {
        position: relative;
        z-index: 5;
    }

    .drag-item {
        touch-action: pan-y;
    }

    .game-layout {
        grid-template-columns: 1fr;
    }

    .tray {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        max-height: none;
        overflow: visible;
    }

    .drag-item {
        min-width: 0;
        width: 100%;
        font-size: 0.9rem;
    }
}