/* ============ Luna's Directions Game ============ */

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: "Comic Sans MS", "Chalkboard SE", "Segoe UI", sans-serif;
    /* Prevents double-tap zoom so fast little taps don't zoom the page */
    touch-action: manipulation;
}

body {
    background: linear-gradient(160deg, #a18cd1 0%, #fbc2eb 40%, #ffe9a8 100%);
}

button {
    font-family: inherit;
    border: none;
    cursor: pointer;
    background: none;
}

.screen {
    display: none;
    height: 100dvh;
    width: 100vw;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.screen.active {
    display: flex;
}

/* ============ Pick-a-friend screen ============ */

.pick-title {
    font-size: clamp(2.2rem, 8vw, 4rem);
    color: #6a1b9a;
    text-shadow: 2px 3px 0 #ffffffaa;
}

.pick-subtitle {
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    color: #4a148c;
    margin: 0.4rem 0 1.5rem;
}

.pick-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 220px));
    gap: clamp(0.8rem, 3vw, 1.5rem);
    padding: 0 1rem;
}

.pick-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: clamp(1rem, 4vw, 2rem);
    border-radius: 28px;
    background: #fffdf5;
    box-shadow: 0 8px 0 #d6a5e0, 0 12px 24px #0002;
    transition: transform 0.15s ease;
    animation: card-bob 2.4s ease-in-out infinite;
}

.pick-card:nth-child(2) { animation-delay: 0.3s; }
.pick-card:nth-child(3) { animation-delay: 0.6s; }
.pick-card:nth-child(4) { animation-delay: 0.9s; }

.pick-card:active {
    transform: scale(0.92);
}

@keyframes card-bob {
    0%, 100% { translate: 0 0; }
    50%      { translate: 0 -8px; }
}

.pick-emoji {
    font-size: clamp(3.5rem, 12vw, 6rem);
    line-height: 1.1;
}

.pick-name {
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    font-weight: bold;
    color: #6a1b9a;
}

/* ============ Game screen ============ */

#game-screen {
    justify-content: space-between;
    padding: 0.8rem;
}

/* Everything Luna taps stays above the growing star */
.game-header, .board, .direction-banner {
    position: relative;
    z-index: 2;
}

/* --- The giant progress star: grows with every right answer --- */

.giant-star {
    position: fixed;
    top: 84px;
    left: 50%;
    z-index: 1;
    font-size: 2rem;
    line-height: 1;
    pointer-events: none;
    opacity: 0.6;
    translate: -50%;
    transform: scale(var(--star-scale, 1));
    transform-origin: center top;
    transition: transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 0 14px #ffd54f);
}

.giant-star.exploding {
    animation: star-explode 2.4s ease-in forwards;
}

@keyframes star-explode {
    0%   { transform: scale(var(--star-scale, 1)) rotate(0deg); opacity: 0.6; }
    40%  { transform: scale(calc(var(--star-scale, 1) * 1.15)) rotate(8deg); opacity: 1; }
    55%  { transform: scale(calc(var(--star-scale, 1) * 0.85)) rotate(-8deg); opacity: 1; }
    70%  { transform: scale(calc(var(--star-scale, 1) * 1.2)) rotate(8deg); opacity: 1; }
    100% { transform: scale(calc(var(--star-scale, 1) * 4)) rotate(40deg); opacity: 0; }
}

.flash-overlay {
    position: fixed;
    inset: 0;
    z-index: 45;
    pointer-events: none;
    background: radial-gradient(circle, #fff7d1ee 0%, #ffd54f88 45%, transparent 75%);
    animation: flash-fade 2.2s ease forwards;
}

@keyframes flash-fade {
    0%   { opacity: 0; }
    30%  { opacity: 1; }
    100% { opacity: 0; }
}

.game-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.round-button {
    font-size: 1.8rem;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #fffdf5;
    box-shadow: 0 4px 0 #d6a5e0;
    flex-shrink: 0;
}

.round-button:active {
    transform: scale(0.9);
}

.score {
    font-size: clamp(1.8rem, 7vw, 2.8rem);
    font-weight: bold;
    color: #6a1b9a;
    background: #fffdf5;
    border-radius: 999px;
    padding: 0.3rem 1.6rem;
    box-shadow: 0 4px 0 #d6a5e0;
}

.score.pop {
    animation: score-pop 0.5s ease;
}

@keyframes score-pop {
    0%   { transform: scale(0.6); }
    60%  { transform: scale(1.35) rotate(6deg); }
    100% { transform: scale(1); }
}

/* --- The board: a plus-shaped grid --- */

.board {
    display: grid;
    grid-template-areas:
        ".    top    ."
        "left center right"
        ".    bottom .";
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: clamp(0.4rem, 2vw, 1rem);
    width: min(92vw, 58dvh);
    aspect-ratio: 1;
}

.zone {
    border-radius: 24px;
    background: #ffffff66;
    border: 5px solid #ffffffcc;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background 0.2s;
}

/* Each direction gets its own bright color */
.zone[data-direction="top"]    { grid-area: top;    border-color: #29b6f6; background: #29b6f62e; }
.zone[data-direction="left"]   { grid-area: left;   border-color: #ffa726; background: #ffa7262e; }
.zone[data-direction="right"]  { grid-area: right;  border-color: #ec407a; background: #ec407a2e; }
.zone[data-direction="bottom"] { grid-area: bottom; border-color: #66bb6a; background: #66bb6a2e; }

.zone:active {
    background: #ffffffaa;
}

.zone-hint {
    font-size: clamp(3rem, 13vw, 5.5rem);
    line-height: 1;
    filter: drop-shadow(0 3px 3px #0003);
    animation: hint-throb 1.4s ease-in-out infinite;
}

.zone[data-direction="top"]    .zone-hint { color: #29b6f6; }
.zone[data-direction="left"]   .zone-hint { color: #ffa726; }
.zone[data-direction="right"]  .zone-hint { color: #ec407a; }
.zone[data-direction="bottom"] .zone-hint { color: #66bb6a; }

@keyframes hint-throb {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.12); }
}

.zone-food {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(2.6rem, 10vw, 4.5rem);
    filter: drop-shadow(0 3px 3px #0003);
}

/* Food only visible in the active zone */
.zone .zone-food { display: none; }

.zone.has-food .zone-food {
    display: flex;
    animation: food-bounce 0.9s ease-in-out infinite;
}

.zone.has-food .zone-hint {
    opacity: 0.15;
    animation: none;
}

@keyframes food-bounce {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.18); }
}

.zone.wrong {
    animation: zone-shake 0.4s ease;
}

@keyframes zone-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-8px); }
    75%      { transform: translateX(8px); }
}

.zone.eaten .zone-food {
    animation: food-eaten 0.5s ease forwards;
}

@keyframes food-eaten {
    to { transform: scale(0) rotate(180deg); opacity: 0; }
}

.zone.eaten {
    animation: zone-glow 0.8s ease;
}

@keyframes zone-glow {
    0%   { box-shadow: 0 0 0 0 #ffd54fcc; }
    60%  { box-shadow: 0 0 45px 20px #ffd54f88; }
    100% { box-shadow: 0 0 0 0 #ffd54f00; }
}

/* --- Correct-answer celebration effects --- */

.burst-piece {
    position: fixed;
    z-index: 60;
    font-size: 1.7rem;
    pointer-events: none;
    translate: -50% -50%;
    animation: burst-fly 0.9s ease-out forwards;
}

@keyframes burst-fly {
    0%   { transform: translate(0, 0) scale(0.4) rotate(0deg); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(1.3) rotate(180deg); opacity: 0; }
}

.fly-star {
    position: fixed;
    z-index: 60;
    font-size: 2.4rem;
    pointer-events: none;
    translate: -50% -50%;
    filter: drop-shadow(0 0 8px #ffd54f);
    transition: transform 0.6s cubic-bezier(0.45, -0.25, 0.6, 1);
}

.center-cell {
    grid-area: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.character {
    font-size: clamp(3.2rem, 13vw, 5.5rem);
    filter: drop-shadow(0 4px 4px #0003);
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: inline-block;
    animation: character-idle 2s ease-in-out infinite;
}

@keyframes character-idle {
    0%, 100% { rotate: -4deg; }
    50%      { rotate: 4deg; }
}

.character.hopping {
    animation: none;
}

/* --- Direction banner --- */

.direction-banner {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: #fffdf5;
    border-radius: 999px;
    padding: 0.5rem 2rem;
    box-shadow: 0 6px 0 #d6a5e0, 0 10px 20px #0002;
    min-height: 84px;
}

.banner-arrow {
    font-size: clamp(2.4rem, 10vw, 3.6rem);
    line-height: 1;
    filter: drop-shadow(0 2px 2px #0003);
}

.banner-word {
    font-size: clamp(2rem, 9vw, 3.4rem);
    font-weight: bold;
    letter-spacing: 0.06em;
    color: #6a1b9a;
}

.direction-banner.cheer .banner-word {
    color: #2e7d32;
}

.direction-banner.pulse {
    animation: banner-pulse 0.5s ease;
}

@keyframes banner-pulse {
    50% { transform: scale(1.08); }
}

/* ============ Win screen ============ */

.win-character {
    font-size: clamp(5rem, 22vw, 9rem);
    animation: win-dance 0.7s ease-in-out infinite;
}

@keyframes win-dance {
    0%, 100% { transform: rotate(-10deg) translateY(0); }
    50%      { transform: rotate(10deg) translateY(-20px); }
}

.win-title {
    font-size: clamp(2.4rem, 10vw, 4.5rem);
    color: #6a1b9a;
    text-shadow: 2px 3px 0 #ffffffaa;
    margin: 0.5rem 0;
}

.win-foods {
    font-size: clamp(1.6rem, 7vw, 2.6rem);
    letter-spacing: 0.4rem;
    margin-bottom: 1.5rem;
    max-width: 90vw;
    text-align: center;
    overflow-wrap: break-word;
}

.win-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.big-button {
    font-size: clamp(1.4rem, 5vw, 2rem);
    font-weight: bold;
    color: #fff;
    background: #ab47bc;
    border-radius: 999px;
    padding: 1rem 2.5rem;
    box-shadow: 0 6px 0 #7b1fa2;
}

.big-button.secondary {
    background: #26a69a;
    box-shadow: 0 6px 0 #00796b;
}

.big-button:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #7b1fa2;
}

/* --- Confetti --- */

.confetti {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.confetti span {
    position: absolute;
    top: -10%;
    font-size: 1.8rem;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
    to {
        transform: translateY(120vh) rotate(720deg);
    }
}
