/* ============================================
   MOJO MATHS - Shared Styles
   3D Magnetic Silicon Ball Theme
   ============================================ */

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

body {
    font-family: 'Segoe UI', 'Arial Rounded MT Bold', 'Nunito', sans-serif;
    background: linear-gradient(135deg, #0a0a2e 0%, #1a1a4e 30%, #2a1a3e 60%, #0a0a2e 100%);
    color: #fff;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Colour Number System --- */
.num-0 { --ball-color: #1a1a1a; --ball-highlight: #555; --ball-shadow: #000; --text-color: #333; }
.num-1 { --ball-color: #f0f0f0; --ball-highlight: #fff; --ball-shadow: #aaa; --text-color: #e8e8e8; }

/* Make black/white balls more visible on dark backgrounds */
.ball.num-0 { border: 2px solid rgba(255,255,255,0.15); }
.ball.num-1 { border: 2px solid rgba(255,255,255,0.3); }
.num-2 { --ball-color: #e62020; --ball-highlight: #ff6666; --ball-shadow: #8b0000; --text-color: #e62020; }
.num-3 { --ball-color: #ff8c00; --ball-highlight: #ffbb55; --ball-shadow: #cc6600; --text-color: #ff8c00; }
.num-4 { --ball-color: #ffd700; --ball-highlight: #ffef88; --ball-shadow: #b8960f; --text-color: #ffd700; }
.num-5 { --ball-color: #2ecc40; --ball-highlight: #7dff8a; --ball-shadow: #1a7a28; --text-color: #2ecc40; }
.num-6 { --ball-color: #54c8ff; --ball-highlight: #a8e4ff; --ball-shadow: #2980b9; --text-color: #54c8ff; }
.num-7 { --ball-color: #1a3a8a; --ball-highlight: #4a6adf; --ball-shadow: #0a1a4a; --text-color: #4a6adf; }
.num-8 { --ball-color: #9b30ff; --ball-highlight: #c77dff; --ball-shadow: #5b0f9f; --text-color: #9b30ff; }
.num-9 { --ball-color: #ff69b4; --ball-highlight: #ffaacc; --ball-shadow: #cc3388; --text-color: #ff69b4; }

/* --- 3D Magnetic Silicon Ball ---
   Real-world: 35mm diameter, silicone rubber shell,
   25mm×5mm neodymium disc magnet inside.
   Visual: glossy silicone surface with deep specular highlight,
   subtle subsurface scattering, magnetic field glow, ground shadow.
*/
.ball {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background:
        /* Primary specular highlight (top-left light source) */
        radial-gradient(circle at 32% 28%, var(--ball-highlight) 0%, transparent 45%),
        /* Subsurface glow (silicone lets light through slightly) */
        radial-gradient(circle at 50% 50%, var(--ball-color) 0%, transparent 70%),
        /* Core-to-edge darkening (3D roundness) */
        radial-gradient(circle at 50% 50%, var(--ball-color) 30%, var(--ball-shadow) 100%);
    box-shadow:
        /* Ground contact shadow */
        0 6px 20px -2px rgba(0,0,0,0.5),
        /* Soft ambient shadow */
        0 2px 8px rgba(0,0,0,0.3),
        /* Inner bottom shadow (underside of sphere) */
        inset 0 -6px 12px -2px rgba(0,0,0,0.4),
        /* Inner top light (rim lighting from above) */
        inset 0 6px 12px -4px rgba(255,255,255,0.2),
        /* Magnetic field glow (subtle coloured halo) */
        0 0 15px -3px var(--ball-color);
    font-size: 32px;
    font-weight: 900;
    color: #fff;
    text-shadow:
        0 1px 2px rgba(0,0,0,0.6),
        0 0 8px rgba(0,0,0,0.3);
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    /* Slight 3D lift */
    transform: translateY(0);
}

/* Primary specular highlight — sharp white spot like light on silicone */
.ball::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 20%;
    width: 30%;
    height: 22%;
    background: radial-gradient(ellipse at 50% 50%,
        rgba(255,255,255,0.75) 0%,
        rgba(255,255,255,0.3) 40%,
        rgba(255,255,255,0) 100%);
    border-radius: 50%;
    transform: rotate(-20deg);
    pointer-events: none;
}

/* Secondary rim highlight — bottom-right reflected light */
.ball::after {
    content: '';
    position: absolute;
    bottom: 12%;
    right: 15%;
    width: 20%;
    height: 14%;
    background: radial-gradient(ellipse,
        rgba(255,255,255,0.18) 0%,
        rgba(255,255,255,0) 100%);
    border-radius: 50%;
    pointer-events: none;
}

/* Hover: lift up, expand magnetic glow, deepen shadow */
.ball:hover {
    transform: scale(1.12) translateY(-3px);
    box-shadow:
        0 12px 35px -2px rgba(0,0,0,0.5),
        0 4px 12px rgba(0,0,0,0.3),
        inset 0 -6px 12px -2px rgba(0,0,0,0.4),
        inset 0 6px 12px -4px rgba(255,255,255,0.2),
        /* Expanded magnetic field glow on hover */
        0 0 35px -3px var(--ball-color),
        0 0 60px -8px var(--ball-color);
}

/* Press: squish down like silicone */
.ball:active {
    transform: scale(0.94) translateY(1px);
    box-shadow:
        0 2px 8px rgba(0,0,0,0.5),
        inset 0 -4px 8px rgba(0,0,0,0.4),
        inset 0 4px 8px rgba(255,255,255,0.15),
        0 0 10px -3px var(--ball-color);
}

/* Ball sizes — proportional to real 35mm ball
   small=25mm, medium=35mm, large=45mm, xlarge=55mm (screen equivalent) */
.ball.small { width: 50px; height: 50px; font-size: 20px; }
.ball.medium { width: 80px; height: 80px; font-size: 32px; }
.ball.large { width: 110px; height: 110px; font-size: 44px; }
.ball.xlarge { width: 140px; height: 140px; font-size: 56px; }

/* --- Magnetic Float Animation ---
   Simulates the subtle wobble of a ball with a disc magnet inside
   hovering near a magnetic surface — slight tilt as poles interact */
@keyframes magneticFloat {
    0%   { transform: translateY(0px) rotate(0deg); }
    15%  { transform: translateY(-6px) rotate(0.8deg); }
    30%  { transform: translateY(-10px) rotate(-0.5deg); }
    50%  { transform: translateY(-4px) rotate(0.3deg); }
    70%  { transform: translateY(-9px) rotate(-0.8deg); }
    85%  { transform: translateY(-3px) rotate(0.4deg); }
    100% { transform: translateY(0px) rotate(0deg); }
}

/* Magnetic snap animation — when ball is attracted to another */
@keyframes magneticSnap {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.06); }
    70%  { transform: scale(0.97); }
    100% { transform: scale(1); }
}

.ball.floating {
    animation: magneticFloat 3s ease-in-out infinite;
}

.ball.floating:nth-child(2n) { animation-delay: -0.5s; animation-duration: 3.5s; }
.ball.floating:nth-child(3n) { animation-delay: -1s; animation-duration: 2.8s; }
.ball.floating:nth-child(5n) { animation-delay: -1.5s; animation-duration: 3.2s; }
.ball.floating:nth-child(7n) { animation-delay: -0.3s; animation-duration: 3.3s; }

.ball.snapping {
    animation: magneticSnap 0.3s ease-out;
}

/* --- Magnetic proximity effect for answer grids ---
   When balls in a choice group are hovered, they all rise and glow together */
.choices > div, .answer-row > div, .p-choices > div {
    transition: transform 0.2s ease;
}
.choices > div:hover .ball,
.answer-row > div:hover .ball,
.p-choices > div:hover .ball {
    box-shadow:
        0 8px 25px -2px rgba(0,0,0,0.5),
        inset 0 -6px 12px -2px rgba(0,0,0,0.4),
        inset 0 6px 12px -4px rgba(255,255,255,0.25),
        0 0 30px -3px var(--ball-color),
        0 0 60px -8px var(--ball-color);
    transform: translateY(-2px);
    transition: all 0.2s ease;
}
.choices > div:hover,
.answer-row > div:hover,
.p-choices > div:hover {
    transform: scale(1.08) translateY(-4px);
}

/* --- Magnetic Pulse --- visible field glow when ball is active */
@keyframes magneticPulse {
    0%, 100% {
        box-shadow:
            0 6px 20px -2px rgba(0,0,0,0.5),
            inset 0 -6px 12px -2px rgba(0,0,0,0.4),
            inset 0 6px 12px -4px rgba(255,255,255,0.2),
            0 0 20px -3px var(--ball-color);
    }
    50% {
        box-shadow:
            0 6px 20px -2px rgba(0,0,0,0.5),
            inset 0 -6px 12px -2px rgba(0,0,0,0.4),
            inset 0 6px 12px -4px rgba(255,255,255,0.2),
            0 0 45px -3px var(--ball-color),
            0 0 80px -8px var(--ball-color);
    }
}

.ball.pulsing {
    animation: magneticPulse 2s ease-in-out infinite;
}

/* --- Pop Animation --- */
@keyframes ballPop {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.7; }
    100% { transform: scale(0); opacity: 0; }
}

.ball.popping {
    animation: ballPop 0.4s ease-out forwards;
}

/* --- Shake Wrong Answer --- */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-10px); }
    80% { transform: translateX(10px); }
}

.ball.wrong {
    animation: shake 0.5s ease-in-out;
}

/* --- Landing Page --- */
.hero {
    text-align: center;
    padding: 10px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.site-title {
    font-size: clamp(48px, 10vw, 96px);
    font-weight: 900;
    letter-spacing: 4px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #ff6b6b, #ffa500, #ffd700, #2ecc40, #54c8ff, #9b30ff, #ff69b4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.site-logo {
    max-width: min(520px, 90vw);
    height: auto;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 8px 24px rgba(0,0,0,0.5));
}
.logo-area {
    position: relative;
}

.site-subtitle {
    font-size: clamp(16px, 3vw, 28px);
    color: #ccc;
    margin-bottom: 40px;
    font-weight: 300;
}

/* --- Number Showcase Row --- */
.ball-showcase {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 30px auto;
    max-width: 900px;
    padding: 0 10px;
}

/* --- Game Cards Grid --- */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    max-width: 1200px;
    width: 100%;
    padding: 20px;
    margin: 0 auto;
}

.game-card {
    background: rgba(255,255,255,0.06);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 24px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    backdrop-filter: blur(10px);
}

.game-card:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.3);
    transform: translateY(-5px);
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.game-card .card-icon {
    font-size: 50px;
}

.game-card h2 {
    font-size: 24px;
    font-weight: 800;
}

.game-card p {
    font-size: 15px;
    color: #aaa;
    line-height: 1.5;
}

/* --- Game Page Layout --- */
.game-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(255,255,255,0.1);
    flex-wrap: wrap;
    gap: 10px;
}

.game-header h1 {
    font-size: clamp(24px, 5vw, 36px);
    font-weight: 900;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 50px;
    color: #fff;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
}

.back-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* --- Score / Stats Bar --- */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.stat {
    background: rgba(255,255,255,0.08);
    padding: 12px 24px;
    border-radius: 16px;
    font-size: 18px;
    font-weight: 700;
}

.stat span {
    color: #ffd700;
}

/* --- Game Arena --- */
.game-arena {
    background: rgba(0,0,0,0.3);
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: 24px;
    padding: 40px 20px;
    margin: 20px 0;
    min-height: 300px;
    position: relative;
    overflow: hidden;
}

/* --- Question Display --- */
.question {
    font-size: clamp(28px, 6vw, 48px);
    font-weight: 900;
    margin: 20px 0 30px;
    letter-spacing: 2px;
}

/* --- Answer Choices --- */
.choices {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 20px 0;
}

/* --- Feedback Messages --- */
.feedback {
    font-size: 28px;
    font-weight: 800;
    margin: 15px 0;
    min-height: 40px;
}

.feedback.correct { color: #2ecc40; }
.feedback.wrong { color: #e62020; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 32px;
    border: none;
    border-radius: 50px;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    color: #fff;
    background: linear-gradient(135deg, #9b30ff, #ff69b4);
    box-shadow: 0 4px 15px rgba(155, 48, 255, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(155, 48, 255, 0.5);
}

.btn:active { transform: translateY(0); }

.btn.green { background: linear-gradient(135deg, #1a7a28, #2ecc40); box-shadow: 0 4px 15px rgba(46, 204, 64, 0.3); }
.btn.blue { background: linear-gradient(135deg, #2980b9, #54c8ff); box-shadow: 0 4px 15px rgba(84, 200, 255, 0.3); }
.btn.orange { background: linear-gradient(135deg, #cc6600, #ff8c00); box-shadow: 0 4px 15px rgba(255, 140, 0, 0.3); }

/* --- Level Selector --- */
.level-select {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 15px 0;
    flex-wrap: wrap;
}

.level-btn {
    padding: 10px 24px;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 50px;
    background: rgba(255,255,255,0.05);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.level-btn:hover { background: rgba(255,255,255,0.15); }
.level-btn.active {
    background: linear-gradient(135deg, #9b30ff, #ff69b4);
    border-color: transparent;
}
.level-btn.active[data-level="mojo"] {
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: #333;
}

/* --- Streak / Combo --- */
@keyframes streakGlow {
    0%, 100% { text-shadow: 0 0 10px #ffd700; }
    50% { text-shadow: 0 0 30px #ffd700, 0 0 60px #ff8c00; }
}

.streak {
    font-size: 22px;
    font-weight: 900;
    color: #ffd700;
    animation: streakGlow 1s ease-in-out infinite;
}

/* --- Timer Bar --- */
.timer-bar-container {
    width: 100%;
    height: 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    overflow: hidden;
    margin: 15px 0;
}

.timer-bar {
    height: 100%;
    background: linear-gradient(90deg, #2ecc40, #ffd700, #e62020);
    border-radius: 6px;
    transition: width 0.1s linear;
}

/* --- Drag & Drop Zone --- */
.drop-zone {
    min-height: 100px;
    border: 3px dashed rgba(255,255,255,0.2);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin: 15px 0;
    transition: border-color 0.2s;
}

.drop-zone.drag-over {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.05);
}

/* --- Confetti Overlay --- */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    top: -20px;
}

@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* --- Accessibility --- */
*:focus-visible {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
    border-radius: 4px;
}

button, a, [tabindex], select, input {
    min-height: 44px;
    min-width: 44px;
}

.ball, .level-btn, .game-tab, .filter-chip, .option-btn, .yr-chip {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Skip to content link (screen readers) */
.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.skip-link:focus {
    position: static;
    width: auto;
    height: auto;
    display: block;
    padding: 10px 20px;
    background: #ffd700;
    color: #333;
    font-weight: 800;
    text-align: center;
    z-index: 10000;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .ball { width: 60px; height: 60px; font-size: 24px; }
    .ball.large { width: 80px; height: 80px; font-size: 34px; }
    .ball.xlarge { width: 100px; height: 100px; font-size: 42px; }
    .ball-showcase { gap: 8px; }
    .games-grid { grid-template-columns: 1fr; padding: 10px; }
    .game-card { padding: 20px; }
    .stats-bar { gap: 15px; }
    .stat { padding: 8px 16px; font-size: 15px; }
}
