/* ════════════════════════════════════════════════════════════════
   WHACK-A-MOLE ASSESSMENT — CUSTOM STYLES
   ════════════════════════════════════════════════════════════════ */

/* ── Base Reset & Font ────────────────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Entrance Animations ──────────────────────────────────────── */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

.animate-fade-in-down { animation: fadeInDown 0.6s ease-out both; }
.animate-fade-in-up   { animation: fadeInUp 0.6s ease-out both; }
.animate-scale-in     { animation: scaleIn 0.3s ease-out both; }

/* ── Grass Field (Arena Background) ───────────────────────────── */
.grass-field {
    position: relative;
    overflow: hidden;
    border-radius: 28px;
    border: 4px solid #3d7a22;
    background:
        repeating-linear-gradient(90deg, rgba(255,255,255,0.045) 0 56px, rgba(0,0,0,0.035) 56px 112px),
        linear-gradient(180deg, #68c443 0%, #4fa42f 45%, #3d8526 100%);
    box-shadow:
        inset 0 2px 24px rgba(0,0,0,0.18),
        0 10px 34px rgba(20,60,10,0.25);
}

/* Grass texture dots */
.grass-field::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle 2px, rgba(255,255,255,0.1) 50%, transparent 50%),
        radial-gradient(circle 1.5px, rgba(0,0,0,0.06) 50%, transparent 50%);
    background-size: 18px 18px, 25px 25px;
    background-position: 0 0, 9px 9px;
    pointer-events: none;
}

/* ── Arena grid: 2x2 on phones, 4 across (staggered) on desktop ─ */
.arena-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 14px 10px 10px;
}

@media (min-width: 768px) {
    .arena-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 18px;
        padding: 28px 24px 44px;
    }
    /* Staggered rows give the field some depth */
    .arena-grid .mole-hole:nth-child(even) { transform: translateY(22px); }
}

/* Hide the system cursor over the arena only when the mallet replaces it */
@media (hover: hover) and (pointer: fine) {
    #arena, #arena * { cursor: none !important; }
}

/* ── Hole ─────────────────────────────────────────────────────────
   Geometry contract (all % of the hole box):
   pit  = ellipse, left 9 / width 82 / bottom 2 / height 24  → centre line at 86% from top
   slot = mask: everything above the centre line + the pit's lower half,
          so the mole is hidden "inside" the hole and emerges over the front rim.        */
.mole-hole {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 5;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    --accent: #086FB2;
}
.mole-hole[data-index="1"] { --accent: #00ACED; }
.mole-hole[data-index="2"] { --accent: #e85d3a; }
.mole-hole[data-index="3"] { --accent: #8b5cf6; }

.hole-mound {
    position: absolute;
    z-index: 1;
    left: 2%;
    bottom: -1.5%;
    width: 96%;
    height: 30%;
    border-radius: 50%;
    background: radial-gradient(ellipse at 50% 30%, #ac8546 0%, #7b5a2a 55%, #55391a 100%);
    box-shadow: 0 6px 10px rgba(0,0,0,0.28);
}

.hole-pit {
    position: absolute;
    z-index: 2;
    left: 9%;
    bottom: 2%;
    width: 82%;
    height: 24%;
    border-radius: 50%;
    background: radial-gradient(ellipse at 50% 30%, #0b0501 0%, #1c0f05 55%, #2d1a09 100%);
    box-shadow: inset 0 6px 10px rgba(0,0,0,0.6);
}

.mole-slot {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    -webkit-mask:
        linear-gradient(#000, #000) 0 0 / 100% 86% no-repeat,
        radial-gradient(ellipse 41% 12% at 50% 86%, #000 98%, transparent 100%) 0 0 / 100% 100% no-repeat;
            mask:
        linear-gradient(#000, #000) 0 0 / 100% 86% no-repeat,
        radial-gradient(ellipse 41% 12% at 50% 86%, #000 98%, transparent 100%) 0 0 / 100% 100% no-repeat;
}

/* Front rim highlight — also hides the aliasing on the mask edge */
.hole-lip {
    position: absolute;
    z-index: 4;
    left: 9%;
    bottom: 2%;
    width: 82%;
    height: 24%;
    border-radius: 50%;
    border-bottom: 5px solid #b48d4d;
    pointer-events: none;
}

/* ── Mole: rise / sink ────────────────────────────────────────────
   .mole       → position + rise/sink transition (toggled by the .popped class)
   .mole-inner → idle bob and bonk squash, so those animations never fight the transition */
.mole {
    position: absolute;
    left: 50%;
    bottom: 10%;
    width: 88%;
    transform: translate(-50%, 128%);
    transition: transform 0.4s cubic-bezier(0.55, 0.05, 0.8, 0.3);   /* sink: accelerates down */
    pointer-events: none;
    will-change: transform;
}

.mole.popped {
    transform: translate(-50%, 0);
    transition: transform 0.52s cubic-bezier(0.34, 1.45, 0.64, 1);   /* rise: springy overshoot */
    pointer-events: auto;
}

.mole-inner {
    position: relative;
    width: 100%;
    aspect-ratio: 220 / 280;
    container-type: inline-size;       /* sign sizes use cqw so they scale with the mole */
    transform-origin: 50% 100%;
}

.mole-inner > svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}
.mole-back  { z-index: 0; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.35)); }
.mole-front { z-index: 2; }

/* Idle bob while above ground */
.mole.popped:not(.bonked) .mole-inner {
    animation: moleIdle 2.2s ease-in-out 0.5s infinite;
}
@keyframes moleIdle {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50%      { transform: translateY(-1.5%) rotate(0.8deg); }
}

/* Whacked */
.mole.bonked .mole-inner { animation: moleBonk 0.45s ease-out; }
@keyframes moleBonk {
    0%   { transform: scale(1, 1); }
    30%  { transform: scale(1.18, 0.7); }
    55%  { transform: scale(0.94, 1.08); }
    100% { transform: scale(1, 1); }
}

/* Eyes: blink while idle, dizzy X when bonked */
.mole-eyes-open {
    transform-box: fill-box;
    transform-origin: center;
    animation: moleBlink 4.2s infinite;
}
@keyframes moleBlink {
    0%, 92%, 100% { transform: scaleY(1); }
    95%           { transform: scaleY(0.1); }
}
#arena-grid .mole-hole:nth-child(2) .mole-eyes-open { animation-delay: -1.4s; }
#arena-grid .mole-hole:nth-child(3) .mole-eyes-open { animation-delay: -2.7s; }
#arena-grid .mole-hole:nth-child(4) .mole-eyes-open { animation-delay: -0.6s; }

.mole-eyes-dizzy { display: none; }
.mole.bonked .mole-eyes-open  { display: none; }
.mole.bonked .mole-eyes-dizzy { display: inline; }

/* ── Option sign (held in the mole's paws) ────────────────────── */
.mole-sign {
    position: absolute;
    z-index: 1;
    left: 16.4%;
    top: 53.6%;
    width: 67.3%;
    height: 29.3%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.2cqw 5.5cqw;
    background:
        repeating-linear-gradient(0deg, transparent 0 3cqw, rgba(120,80,30,0.07) 3cqw 3.6cqw),
        linear-gradient(180deg, #fbecc4 0%, #f0d596 100%);
    border: 0.9cqw solid #8a5a2f;
    border-radius: 4.5cqw;
    box-shadow:
        0 1.4cqw 0 #6a4220,
        0 3cqw 4cqw rgba(0,0,0,0.3),
        inset 0 0.8cqw 0 rgba(255,255,255,0.5);
}

.mole-letter {
    position: absolute;
    top: -4.4cqw;
    left: -3.4cqw;
    width: 9cqw;
    height: 9cqw;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 0.7cqw solid #fff;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    font-size: 5.4cqw;
    line-height: 1;
    box-shadow: 0 0.8cqw 1.6cqw rgba(0,0,0,0.3);
}

.mole-option-text {
    font-size: 6.6cqw;
    font-weight: 700;
    line-height: 1.15;
    color: #3a2616;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Narrow moles (phones): bigger text relative to the sign */
@container (max-width: 170px) {
    .mole-option-text { font-size: 8.6cqw; }
    .mole-letter { width: 10.5cqw; height: 10.5cqw; font-size: 6.4cqw; top: -5cqw; left: -4cqw; }
    .mole-sign { padding: 1cqw 4cqw; }
}

.mole.selected-mole .mole-sign {
    box-shadow:
        0 0 0 1.3cqw var(--accent),
        0 1.4cqw 0 #6a4220,
        0 3cqw 4cqw rgba(0,0,0,0.3),
        inset 0 0.8cqw 0 rgba(255,255,255,0.5);
}

/* ── Whack Stars ──────────────────────────────────────────────── */
.whack-stars {
    position: absolute;
    z-index: 4;
    top: 12%;
    left: 50%;
    pointer-events: none;
}
.whack-stars .star {
    position: absolute;
    font-size: 8cqw;
    opacity: 0;
    animation: starBurst 0.6s ease-out forwards;
}
.whack-stars.show .star { opacity: 1; }

.star-1 { animation-delay: 0s;    --tx: -16cqw; --ty: -10cqw; }
.star-2 { animation-delay: 0.08s; --tx: 14cqw;  --ty: -14cqw; }
.star-3 { animation-delay: 0.16s; --tx: -10cqw; --ty: -20cqw; }
.star-4 { animation-delay: 0.24s; --tx: 17cqw;  --ty: -7cqw; }

@keyframes starBurst {
    0%   { opacity: 1; transform: translate(0, 0) scale(0.5); }
    60%  { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(1.2); }
}

/* ── Start-screen hero mole (CSS-only peek loop) ──────────────── */
.hero-stage { width: min(260px, 64vw); }
.hero-stage .mole { animation: heroPeek 6s ease-in-out infinite; }
@keyframes heroPeek {
    0%, 8%    { transform: translate(-50%, 128%); }
    24%, 76%  { transform: translate(-50%, 0); }
    92%, 100% { transform: translate(-50%, 128%); }
}

/* ── Score Ring Animation ─────────────────────────────────────── */
.score-circle-animate {
    transition: stroke-dashoffset 1.5s ease-out;
}

/* ── Timer bar ────────────────────────────────────────────────── */
#timer-bar {
    transition: width 1s linear;
}
#timer-bar.danger {
    background: linear-gradient(90deg, #ef4444, #f97316) !important;
}

/* ── Review Modal Cards ───────────────────────────────────────── */
.review-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    transition: box-shadow 0.2s;
}
.review-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.review-option {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    margin: 3px 0;
    border: 1px solid transparent;
}
.review-option.correct-answer {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}
.review-option.user-wrong {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

/* ── Mallet Cursor ────────────────────────────────────────────── */
.mallet-cursor {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 9999;
    pointer-events: none;
    transform: translate(-30px, -14px);
}
.mallet-cursor svg {
    display: block;
    transform: rotate(28deg);
    transform-origin: 38% 90%;
    transition: transform 0.09s ease-out;
}
.mallet-cursor.whacking svg {
    transform: rotate(-38deg);
}
@media (hover: none), (pointer: coarse) {
    .mallet-cursor { display: none !important; }
}

/* ── Hide scrollbar chrome in review modal ────────────────────── */
#review-body::-webkit-scrollbar { width: 6px; }
#review-body::-webkit-scrollbar-track { background: transparent; }
#review-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
#review-body::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ── Reduced motion: keep the cycle, drop the decorative motion ─ */
@media (prefers-reduced-motion: reduce) {
    .mole-inner, .mole-eyes-open, .hero-stage .mole { animation: none !important; }
    .mole, .mole.popped { transition-duration: 0.01s; }
}