/* ============================================================
   Times Castle - learn the times tables
   Blocks: rows alternate TEAL and VIOLET so each row (one group)
   stands out.  "3 x 4" = 3 rows of 4.
   ============================================================ */

:root {
    --ra: #2bb3a3;
    --ra-dark: #1d8a7d;
    --rb: #8a6cf0;
    --rb-dark: #6a4ed0;
    --ink: #2f3150;
    --ink-soft: #686a8a;
    --paper: #fffdf8;
    --stone: #d9dcef;
    --stone-dark: #a9aed0;
    --gold: #ffc93c;
    --gold-dark: #e0a400;
    --good: #2fbf71;
    --soft: #f29b5b;
    --pink: #f07ca8;
    --shadow: 0 6px 0 rgba(0, 0, 0, .08), 0 12px 26px rgba(70, 60, 120, .14);
}

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

html,
body {
    min-height: 100%;
}

body {
    font-family: 'Baloo 2', 'Trebuchet MS', sans-serif;
    color: var(--ink);
    background: linear-gradient(175deg, #e3dcff 0%, #eef0ff 38%, #e6fbf3 100%);
    padding: 64px 14px 50px;
    overflow-x: hidden;
}

/* rolling hills along the bottom */
.hills {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 140px;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(120% 100% at 15% 100%, #bfeedd 0 55%, transparent 56%),
        radial-gradient(110% 100% at 80% 100%, #a8e4cf 0 50%, transparent 51%);
    opacity: .8;
}

/* ---------------- top bar ---------------- */
.topbar {
    position: fixed;
    top: 10px;
    left: 0;
    right: 0;
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    z-index: 40;
}

.chip {
    font-family: inherit;
    font-size: .95rem;
    font-weight: 700;
    color: var(--ink);
    background: rgba(255, 255, 255, .9);
    border: 2px solid #fff;
    border-radius: 999px;
    padding: .35rem .85rem;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(60, 60, 110, .13);
    transition: transform .12s;
}

.chip:hover {
    transform: translateY(-2px);
}

.chip.small {
    font-size: .85rem;
    padding: .25rem .7rem;
}

.chip.starcount {
    cursor: default;
}

.chip .s {
    color: var(--gold);
    margin-right: .3rem;
}

.chip.mastered .s {
    color: var(--good);
}

.chip.off {
    opacity: .5;
}

body.at-start .topbar {
    display: none;
}

/* ---------------- screens + cards ---------------- */
.screen {
    display: none;
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
}

.screen.active {
    display: block;
    animation: rise .35s ease-out;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
}

.card {
    background: var(--paper);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.start-card {
    max-width: 620px;
    margin: 0 auto;
    text-align: center;
}

.game-title {
    font-family: 'Fredoka One', 'Baloo 2', sans-serif;
    font-size: clamp(2.4rem, 7vw, 3.6rem);
    color: var(--rb);
    letter-spacing: 1px;
    line-height: 1.05;
    margin-top: 6px;
}

.game-title span {
    color: var(--ra);
}

.tagline {
    font-size: 1.2rem;
    color: var(--ink-soft);
    margin: 8px 0 16px;
}

.how-to {
    display: grid;
    gap: 10px;
    text-align: left;
    margin: 0 auto 20px;
    max-width: 480px;
}

.how-step {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f3f1ff;
    border-radius: 18px;
    padding: 8px 12px;
}

.how-num {
    flex: 0 0 52px;
    height: 52px;
    border-radius: 16px;
    background: #fff;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--rb);
}

.how-num.star {
    color: var(--gold);
}

.how-step p {
    font-size: 1.02rem;
    line-height: 1.3;
}

.mini-arr {
    display: grid;
    grid-template-columns: repeat(2, 12px);
    gap: 2px;
}

.mini-arr i {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: var(--ra);
}

.mini-arr i:nth-child(3),
.mini-arr i:nth-child(4) {
    background: var(--rb);
}

.tiny-note {
    font-size: .9rem;
    color: var(--ink-soft);
    margin-top: 10px;
}

.screen-title {
    font-family: 'Fredoka One', 'Baloo 2', sans-serif;
    font-size: clamp(1.7rem, 5vw, 2.3rem);
    text-align: center;
    color: var(--rb-dark);
}

.screen-sub {
    text-align: center;
    color: var(--ink-soft);
    font-size: 1.05rem;
    margin: 4px 0 16px;
}

.screen-sub.left {
    text-align: left;
    margin: 0;
}

.sub-h {
    font-size: 1.25rem;
    margin: 18px 0 2px;
    text-align: center;
    color: var(--rb-dark);
}

/* ---------------- buttons ---------------- */
.btn {
    font-family: inherit;
    font-weight: 800;
    font-size: 1.15rem;
    color: #fff;
    background: var(--ra);
    border: none;
    border-radius: 18px;
    padding: .65rem 1.4rem;
    cursor: pointer;
    box-shadow: 0 5px 0 var(--ra-dark);
    transition: transform .1s, box-shadow .1s;
    touch-action: manipulation;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 var(--ra-dark);
}

.btn-huge {
    font-size: 1.6rem;
    padding: .8rem 2.4rem;
    background: var(--rb);
    box-shadow: 0 6px 0 var(--rb-dark);
}

.btn-big {
    font-size: 1.3rem;
}

.btn-small {
    font-size: 1rem;
    padding: .45rem 1rem;
    border-radius: 14px;
}

.btn-ghost {
    background: #fff;
    color: var(--rb-dark);
    border: 3px solid #ddd6ff;
    box-shadow: 0 4px 0 #ddd6ff;
}

.btn-ghost:active {
    box-shadow: 0 1px 0 #ddd6ff;
}

.btn[hidden] {
    display: none;
}

.btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.btn-row.center {
    justify-content: center;
}

/* ---------------- mascot: Brix the little castle ---------------- */
.mascot-holder {
    display: flex;
    justify-content: center;
    padding-top: 6px;
}

.brix {
    position: relative;
    width: 74px;
    height: 84px;
    flex: 0 0 auto;
    animation: bob 2.6s ease-in-out infinite;
}

.brix.big {
    transform: scale(1.5);
    margin: 22px 0 26px;
    animation: bobBig 2.6s ease-in-out infinite;
}

@keyframes bob {
    50% {
        transform: translateY(-5px);
    }
}

@keyframes bobBig {
    0%,
    100% {
        transform: scale(1.5);
    }

    50% {
        transform: scale(1.5) translateY(-5px);
    }
}

.brix-top {
    position: absolute;
    left: 6px;
    right: 6px;
    top: 0;
    height: 16px;
    display: flex;
    justify-content: space-between;
}

.brix-top i {
    width: 16px;
    height: 16px;
    background: #f5b25a;
    border-radius: 4px 4px 0 0;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .08);
}

.brix-body {
    position: absolute;
    left: 6px;
    right: 6px;
    top: 14px;
    bottom: 0;
    background: #f7c06e;
    border-radius: 8px 8px 14px 14px;
    box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .08);
    background-image:
        linear-gradient(rgba(0, 0, 0, .05) 2px, transparent 2px);
    background-size: 100% 14px;
}

.brix-eye {
    position: absolute;
    top: 14px;
    width: 10px;
    height: 12px;
    background: var(--ink);
    border-radius: 50%;
    animation: blink 4.5s infinite;
}

.brix-eye::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #fff;
}

.brix-eye.left {
    left: 15px;
}

.brix-eye.right {
    right: 15px;
}

@keyframes blink {

    0%,
    92%,
    100% {
        transform: scaleY(1);
    }

    95% {
        transform: scaleY(.1);
    }
}

.brix-cheek {
    position: absolute;
    top: 28px;
    width: 9px;
    height: 6px;
    border-radius: 50%;
    background: #ff9aa8;
    opacity: .75;
}

.brix-cheek.left {
    left: 8px;
}

.brix-cheek.right {
    right: 8px;
}

.brix-mouth {
    position: absolute;
    top: 29px;
    left: 50%;
    width: 16px;
    height: 8px;
    margin-left: -8px;
    border-bottom: 3px solid var(--ink);
    border-radius: 0 0 12px 12px;
    transition: all .2s;
}

.brix-door {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-left: -10px;
    background: #9b6a3a;
    border-radius: 10px 10px 0 0;
}

.brix-arm {
    position: absolute;
    top: 42px;
    width: 10px;
    height: 22px;
    background: #f5b25a;
    border-radius: 6px;
    transform-origin: top center;
    transition: transform .3s;
}

.brix-arm.left {
    left: 0;
    transform: rotate(18deg);
}

.brix-arm.right {
    right: 0;
    transform: rotate(-18deg);
}

.brix.happy .brix-arm.left {
    transform: rotate(150deg);
}

.brix.happy .brix-arm.right {
    transform: rotate(-150deg);
}

.brix.happy .brix-mouth {
    height: 12px;
    background: #c4495f;
    border: none;
    border-radius: 0 0 12px 12px;
}

.brix.happy {
    animation: jump .5s ease-out;
}

@keyframes jump {
    40% {
        transform: translateY(-14px);
    }
}

.brix.think .brix-mouth {
    width: 10px;
    margin-left: -5px;
    height: 3px;
    border-bottom: 3px solid var(--ink);
    border-radius: 2px;
    top: 33px;
}

.brix.think {
    animation: tilt .6s ease-in-out;
}

@keyframes tilt {
    30% {
        transform: rotate(-7deg);
    }

    70% {
        transform: rotate(5deg);
    }
}

/* ---------------- map: the towers ---------------- */
.towers {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
}

.tower {
    font-family: inherit;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform .15s;
    color: var(--ink);
}

.tower:hover {
    transform: translateY(-4px);
}

.t-roof {
    width: 92px;
    height: 20px;
    background:
        linear-gradient(90deg, var(--roof) 0 20%, transparent 20% 40%, var(--roof) 40% 60%, transparent 60% 80%, var(--roof) 80%);
}

.t-body {
    position: relative;
    width: 92px;
    height: 104px;
    background: var(--stone);
    border-top: 8px solid var(--roof);
    border-radius: 0 0 10px 10px;
    box-shadow: inset 0 -8px 0 var(--stone-dark), var(--shadow);
    background-image:
        linear-gradient(rgba(255, 255, 255, .35) 2px, transparent 2px),
        linear-gradient(90deg, rgba(255, 255, 255, .25) 2px, transparent 2px);
    background-size: 100% 20px, 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.t-num {
    font-family: 'Fredoka One', 'Baloo 2', sans-serif;
    font-size: 2rem;
    color: var(--ink);
    margin-top: 6px;
    background: rgba(255, 255, 255, .8);
    padding: 0 8px;
    border-radius: 12px;
}

.t-window {
    width: 24px;
    height: 30px;
    margin-top: 8px;
    border-radius: 12px 12px 0 0;
    background: #6a5aa8;
}

.tower.done .t-window {
    background: var(--gold);
    box-shadow: 0 0 14px var(--gold);
}

.t-stars {
    margin-top: 6px;
    font-size: 1.05rem;
    letter-spacing: 1px;
}

.t-stars b {
    color: var(--gold);
}

.t-stars i {
    font-style: normal;
    color: #cfd0e3;
}

.t-known {
    font-size: .82rem;
    color: var(--ink-soft);
    font-weight: 700;
}

.extras {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 24px;
}

.extra {
    font-family: inherit;
    color: var(--ink);
    border: none;
    border-radius: 22px;
    padding: 14px 16px;
    cursor: pointer;
    background: var(--paper);
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 52px 1fr;
    grid-template-rows: auto auto;
    column-gap: 12px;
    text-align: left;
    align-items: center;
    transition: transform .15s;
}

.extra:hover {
    transform: translateY(-3px);
}

.extra b {
    font-size: 1.2rem;
}

.extra small {
    grid-column: 2;
    font-size: .92rem;
    color: var(--ink-soft);
}

.extra-ico {
    grid-row: span 2;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1.6rem;
    color: #fff;
}

.grid-ico {
    background:
        linear-gradient(90deg, transparent 30%, #fff 30% 36%, transparent 36% 64%, #fff 64% 70%, transparent 70%),
        linear-gradient(transparent 30%, #fff 30% 36%, transparent 36% 64%, #fff 64% 70%, transparent 70%),
        var(--gold);
}

.mix-ico {
    background: var(--pink);
}

.bud-ico {
    background: #eae6ff;
    grid-template-columns: repeat(2, 16px);
    gap: 3px;
    place-content: center;
}

.bud-ico i {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    background: var(--ra);
}

.bud-ico i:nth-child(n+3) {
    background: var(--rb);
}

/* ---------------- tower screen ---------------- */
.tower-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}

.tower-head h2 {
    font-family: 'Fredoka One', 'Baloo 2', sans-serif;
    font-size: clamp(1.5rem, 4.5vw, 2rem);
    color: var(--rb-dark);
}

.tower-flag {
    flex: 0 0 auto;
    font-family: 'Fredoka One', 'Baloo 2', sans-serif;
    font-size: 1.8rem;
    color: #fff;
    min-width: 76px;
    height: 76px;
    padding: 0 8px;
    border-radius: 22px;
    display: grid;
    place-items: center;
    box-shadow: var(--shadow);
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.tab {
    flex: 1;
    font-family: inherit;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--ink-soft);
    background: rgba(255, 255, 255, .6);
    border: 3px solid transparent;
    border-radius: 16px;
    padding: .55rem;
    cursor: pointer;
}

.tab.active {
    background: var(--paper);
    color: var(--rb-dark);
    border-color: #ddd6ff;
    box-shadow: 0 4px 0 #ddd6ff;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: rise .3s ease-out;
}

.pane-card {
    max-width: 820px;
    margin: 0 auto;
}

.see-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.fact-big {
    font-family: 'Fredoka One', 'Baloo 2', sans-serif;
    font-size: clamp(1.9rem, 6vw, 2.6rem);
    color: var(--ink);
}

.fact-big b {
    color: var(--rb);
}

.see-ctrl {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

input[type=range] {
    width: 200px;
    accent-color: var(--rb);
    height: 30px;
}

.see-words {
    font-size: 1.1rem;
    color: var(--ink-soft);
    text-align: center;
    margin: 8px 0;
}

.see-words b {
    color: var(--ink);
}

.array-stage {
    display: flex;
    justify-content: center;
    padding: 10px 0;
    min-height: 120px;
}

/* ---------------- block arrays ---------------- */
.arr-wrap {
    position: relative;
    display: inline-block;
}

.arr-wrap.labelled {
    padding: 30px 0 0 70px;
}

.arr {
    display: grid;
    gap: 2px;
    transition: transform .45s ease-in-out;
    transform-origin: center;
}

.arr.turning {
    transform: rotate(90deg);
}

.blk {
    width: var(--b);
    height: var(--b);
    border-radius: calc(var(--b) * .22);
    background: var(--ra);
    box-shadow: inset 0 calc(var(--b) * -.14) 0 var(--ra-dark);
    position: relative;
}

.blk.rb {
    background: var(--rb);
    box-shadow: inset 0 calc(var(--b) * -.14) 0 var(--rb-dark);
}

.arr.pop-in .blk {
    animation: popBlk .3s backwards ease-out;
}

@keyframes popBlk {
    from {
        transform: scale(0);
    }
}

/* the little face on the first block */
.blk.face::before,
.blk.face::after,
.bblk.face::before,
.bblk.face::after {
    content: '';
    position: absolute;
    top: 30%;
    width: 18%;
    height: 22%;
    border-radius: 50%;
    background: #fff;
    box-shadow: inset 0 0 0 2px var(--ink);
}

.blk.face::before,
.bblk.face::before {
    left: 22%;
}

.blk.face::after,
.bblk.face::after {
    right: 22%;
}

.arr-lab {
    position: absolute;
    font-weight: 800;
    font-size: .95rem;
    color: var(--ink-soft);
    white-space: nowrap;
}

.arr-lab.top {
    top: 4px;
    left: 70px;
    right: 0;
    text-align: center;
}

.arr-lab.side {
    left: 0;
    top: 30px;
    bottom: 0;
    width: 64px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 6px;
    white-space: normal;
    text-align: right;
    line-height: 1.1;
}

/* ---------------- number line ---------------- */
.hop-wrap {
    overflow-x: auto;
}

.hop-svg {
    width: 100%;
    height: auto;
    display: block;
}

.nl {
    stroke: var(--ink);
    stroke-width: 4;
    stroke-linecap: round;
}

.nl-tick {
    stroke: var(--ink);
    stroke-width: 3;
}

.nl-num {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 17px;
    fill: var(--ink-soft);
    text-anchor: middle;
}

.nl-num.on {
    fill: var(--rb-dark);
}

.nl-arc {
    fill: none;
    stroke: var(--rb);
    stroke-width: 3;
    stroke-dasharray: 6 5;
}

.nl-plus {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 14px;
    fill: var(--rb);
    text-anchor: middle;
}

.nl-count {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 18px;
    fill: var(--ra-dark);
    text-anchor: middle;
}

.frog-body {
    fill: #6cc24a;
    stroke: #3f8f2a;
    stroke-width: 2;
}

.frog-eye {
    fill: #fff;
    stroke: #3f8f2a;
    stroke-width: 1.5;
}

.frog-pupil {
    fill: var(--ink);
}

.frog-smile {
    fill: none;
    stroke: #2c5e1d;
    stroke-width: 1.8;
    stroke-linecap: round;
}

/* ---------------- trick card ---------------- */
.trick-card {
    text-align: center;
}

.trick-badge {
    display: inline-block;
    font-family: 'Fredoka One', 'Baloo 2', sans-serif;
    font-size: 1.4rem;
    color: #fff;
    background: var(--pink);
    border-radius: 14px;
    padding: 2px 14px;
}

.trick-title {
    font-family: 'Fredoka One', 'Baloo 2', sans-serif;
    font-size: 1.8rem;
    color: var(--rb-dark);
    margin: 6px 0;
}

.trick-rule {
    font-size: 1.15rem;
    max-width: 620px;
    margin: 0 auto 14px;
    line-height: 1.4;
}

.try-lab {
    font-weight: 800;
    color: var(--ink-soft);
}

.trick-fact {
    font-family: 'Fredoka One', 'Baloo 2', sans-serif;
    font-size: 2rem;
    margin-top: 10px;
}

.trick-steps {
    list-style: none;
    display: inline-flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px auto;
    text-align: left;
}

.trick-steps li {
    font-size: 1.25rem;
    background: #f3f1ff;
    border-radius: 14px;
    padding: 4px 14px;
}

.trick-steps.play li {
    animation: stepIn .4s backwards ease-out;
}

@keyframes stepIn {
    from {
        opacity: 0;
        transform: translateX(-16px);
    }
}

.trick-steps b,
.trick-rule b {
    color: var(--rb-dark);
}

.split-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
}

.split-part {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.split-lab {
    font-weight: 800;
    color: var(--ink-soft);
}

.fing-wrap {
    margin: 8px auto;
    max-width: 440px;
}

.fingers {
    width: 100%;
    height: auto;
}

.fg {
    stroke-width: 2;
}

.fg.left {
    fill: var(--ra);
    stroke: var(--ra-dark);
}

.fg.right {
    fill: var(--rb);
    stroke: var(--rb-dark);
}

.fg.down {
    fill: #d6d8ea;
    stroke: var(--stone-dark);
}

.fg-lab {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 14px;
    fill: var(--ink-soft);
    text-anchor: middle;
}

.fing-say {
    font-size: 1.1rem;
}

.c-a {
    color: var(--ra-dark);
}

.c-b {
    color: var(--rb-dark);
}

/* ---------------- games list ---------------- */
.games {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.game-btn {
    font-family: inherit;
    color: var(--ink);
    text-align: center;
    background: var(--paper);
    border: 3px solid transparent;
    border-radius: 24px;
    padding: 16px 12px;
    cursor: pointer;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: transform .15s;
}

.game-btn:hover {
    transform: translateY(-3px);
}

.game-btn.done {
    border-color: var(--gold);
}

.game-btn b {
    font-size: 1.25rem;
}

.game-btn small {
    font-size: .92rem;
    color: var(--ink-soft);
    line-height: 1.2;
}

.g-star {
    font-weight: 800;
    color: var(--gold-dark);
    font-size: .95rem;
}

.game-btn:not(.done) .g-star {
    color: #b9bad0;
}

.g-ico {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    position: relative;
}

.munch-ico {
    background: #9d7cf5;
}

.munch-ico::after {
    content: '';
    position: absolute;
    left: 14px;
    right: 14px;
    top: 30px;
    height: 18px;
    background: #4a2f7a;
    border-radius: 0 0 18px 18px;
}

.munch-ico::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 14px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 22px 0 0 #fff;
}

.miss-ico {
    background: var(--gold);
}

.miss-ico::after {
    content: '?';
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 2.4rem;
    font-weight: 800;
    color: #fff;
}

.build-ico {
    background:
        linear-gradient(90deg, transparent 48%, #fff 48% 52%, transparent 52%),
        linear-gradient(transparent 48%, #fff 48% 52%, transparent 52%),
        linear-gradient(var(--ra) 0 50%, var(--rb) 50%);
    background-size: 21px 21px, 21px 21px, 100% 100%;
}

.hop-ico {
    background: #6cc24a;
}

.hop-ico::before,
.hop-ico::after {
    content: '';
    position: absolute;
    top: 14px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 4px solid #3f8f2a;
}

.hop-ico::before {
    left: 12px;
}

.hop-ico::after {
    right: 12px;
}

/* ---------------- game screen ---------------- */
.game-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.lvl-name {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--rb-dark);
}

.dots {
    display: flex;
    gap: 6px;
}

.dot {
    width: 16px;
    height: 16px;
    border-radius: 5px;
    background: #fff;
    border: 2px solid #d4d0f0;
}

.dot.now {
    border-color: var(--rb);
    transform: scale(1.2);
}

.dot.ok {
    background: var(--good);
    border-color: var(--good);
}

.dot.meh {
    background: var(--soft);
    border-color: var(--soft);
}

.game-card {
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.game-card > * {
    order: 2;
}

.game-card > .brix-row,
.game-card > .timer-bar {
    order: 0;
}

/* Array Builder: read the request before the grid */
.q-first .game-card > .question,
.q-first .game-card > .answer-show {
    order: 1;
}

.brix-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.bubble {
    position: relative;
    flex: 1;
    background: #f3f1ff;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 1.15rem;
    font-weight: 700;
    min-height: 52px;
    display: flex;
    align-items: center;
}

.bubble::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    margin-top: -10px;
    border: 10px solid transparent;
    border-right-color: #f3f1ff;
    border-left: 0;
}

.bubble.good {
    background: #dff7ea;
}

.bubble.good::before {
    border-right-color: #dff7ea;
}

.bubble.bad {
    background: #fff0e2;
}

.bubble.bad::before {
    border-right-color: #fff0e2;
}

.bubble.pop {
    animation: bpop .3s ease-out;
}

@keyframes bpop {
    from {
        transform: scale(.94);
    }
}

.timer-bar {
    height: 10px;
    border-radius: 6px;
    background: #ece9ff;
    margin-top: 12px;
    overflow: hidden;
}

.timer-bar[hidden] {
    display: none;
}

.timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--ra), var(--rb));
}

.stage {
    display: flex;
    justify-content: center;
    margin-top: 14px;
}

.question {
    font-family: 'Fredoka One', 'Baloo 2', sans-serif;
    font-size: clamp(1.8rem, 6.5vw, 2.8rem);
    text-align: center;
    margin: 10px 0 4px;
}

.question b {
    color: var(--rb-dark);
}

.slot {
    display: inline-block;
    min-width: 1.6em;
    padding: 0 .2em;
    border-radius: 14px;
    background: #f3f1ff;
    border: 3px dashed var(--rb);
    color: var(--rb-dark);
}

.answer-show {
    text-align: center;
    min-height: 0;
}

.built {
    display: inline-block;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--ink-soft);
}

.built b {
    color: var(--rb-dark);
}

.hint-box {
    margin-top: 12px;
    background: #fff8ec;
    border: 3px dashed #f6cf8e;
    border-radius: 20px;
    padding: 12px;
    display: flex;
    justify-content: center;
    animation: rise .3s ease-out;
}

.hint-box[hidden] {
    display: none;
}

.hint-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.hint-words {
    font-size: 1.08rem;
    text-align: center;
    line-height: 1.35;
}

.hint-words b {
    color: var(--rb-dark);
}

/* number pad */
.pad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.pad-display {
    display: none;
}

.pad-keys {
    display: grid;
    grid-template-columns: repeat(3, 72px);
    gap: 8px;
}

.pad-key {
    font-family: inherit;
    font-weight: 800;
    font-size: 1.6rem;
    height: 58px;
    border: none;
    border-radius: 16px;
    background: #fff;
    color: var(--ink);
    box-shadow: 0 4px 0 #dcd8f5, 0 6px 14px rgba(80, 70, 140, .1);
    cursor: pointer;
    touch-action: manipulation;
}

.pad-key:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #dcd8f5;
}

.pad-key.ok {
    background: var(--ra);
    color: #fff;
    box-shadow: 0 4px 0 var(--ra-dark);
}

.pad-key.del {
    color: var(--ink-soft);
}

/* Monster Munch */
.munch-row {
    display: flex;
    align-items: center;
    gap: 30px;
    position: relative;
}

.monster {
    position: relative;
    width: 130px;
    height: 130px;
}

.m-body {
    position: absolute;
    inset: 12px 6px 14px;
    background: #9d7cf5;
    border-radius: 48% 48% 40% 40%;
    box-shadow: inset 0 -10px 0 rgba(0, 0, 0, .1);
}

.m-horn {
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 24px solid #ffcf4a;
}

.m-horn.l {
    left: 26px;
    transform: rotate(-14deg);
}

.m-horn.r {
    right: 26px;
    transform: rotate(14deg);
}

.m-eye {
    position: absolute;
    top: 18px;
    width: 26px;
    height: 26px;
    background: #fff;
    border-radius: 50%;
}

.m-eye.l {
    left: 22px;
}

.m-eye.r {
    right: 22px;
}

.m-eye i {
    position: absolute;
    right: 4px;
    top: 7px;
    width: 11px;
    height: 11px;
    background: var(--ink);
    border-radius: 50%;
}

.m-mouth {
    position: absolute;
    left: 50%;
    top: 52px;
    width: 64px;
    height: 34px;
    margin-left: -32px;
    background: #4a2f7a;
    border-radius: 8px 8px 32px 32px;
    overflow: hidden;
    transition: height .15s;
}

.m-teeth {
    height: 8px;
    background: linear-gradient(90deg, #fff 0 22%, transparent 22% 39%, #fff 39% 61%, transparent 61% 78%, #fff 78%);
}

.m-belly {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 800;
    color: #fff;
    font-size: .9rem;
}

.m-foot {
    position: absolute;
    bottom: 2px;
    width: 34px;
    height: 16px;
    background: #7d5ce0;
    border-radius: 16px 16px 6px 6px;
}

.m-foot.l {
    left: 22px;
}

.m-foot.r {
    right: 22px;
}

.monster.chomp .m-mouth {
    animation: chomp .6s ease-in-out;
}

@keyframes chomp {

    0%,
    100% {
        height: 34px;
    }

    20%,
    60% {
        height: 6px;
    }

    40%,
    80% {
        height: 26px;
    }
}

.cookie {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #7a4a26 0 5px, transparent 6px),
        radial-gradient(circle at 70% 40%, #7a4a26 0 4px, transparent 5px),
        radial-gradient(circle at 45% 75%, #7a4a26 0 5px, transparent 6px),
        #e9b26a;
    box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .1);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1.3rem;
    color: #fff;
    text-shadow: 0 2px 0 rgba(0, 0, 0, .3);
    transition: transform .45s ease-in, opacity .45s;
}

.cookie.eaten {
    transform: translateX(-150px) scale(.2);
    opacity: 0;
}

/* Missing Number */
.miss-pic {
    text-align: center;
    color: var(--ink-soft);
    font-weight: 700;
}

.treasure {
    width: 130px;
    height: 84px;
    margin: 0 auto 4px;
    border-radius: 16px 16px 10px 10px;
    background: linear-gradient(#c58a4a 0 38%, #8a5a2b 38% 44%, #c58a4a 44%);
    border: 4px solid #8a5a2b;
    display: grid;
    place-items: center;
    font-family: 'Fredoka One', 'Baloo 2', sans-serif;
    font-size: 2.1rem;
    color: #fff3c4;
    text-shadow: 0 2px 0 rgba(0, 0, 0, .3);
}

/* Array Builder */
.build-grid {
    display: grid;
    grid-template-columns: repeat(12, var(--c));
    gap: 2px;
    padding: 6px;
    background: #ece9ff;
    border-radius: 14px;
    touch-action: none;
    user-select: none;
    cursor: crosshair;
}

.bcell {
    width: var(--c);
    height: var(--c);
    border-radius: 6px;
    background: #fff;
    transition: background .08s;
}

.bcell:first-child {
    box-shadow: inset 0 0 0 3px var(--rb);
}

.bcell.on {
    background: var(--ra);
    box-shadow: inset 0 -4px 0 var(--ra-dark);
}

.bcell.on.rb {
    background: var(--rb);
    box-shadow: inset 0 -4px 0 var(--rb-dark);
}

.build-grid.win .bcell.on {
    animation: popBlk .35s ease-out;
}

/* Skip Hop */
.pond {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 46px 10px 10px;
    background: linear-gradient(#bfe9ff, #9ed8f5);
    border-radius: 24px;
    width: 100%;
}

.stone {
    width: 62px;
    height: 46px;
    border-radius: 50% / 46%;
    background: var(--stone);
    box-shadow: inset 0 -6px 0 var(--stone-dark);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1.3rem;
    color: var(--ink-soft);
}

.stone.known {
    background: #fff;
    color: var(--rb-dark);
}

.pond-frog {
    position: absolute;
    width: 50px;
    height: 40px;
    transform: translate(-50%, -100%);
    transition: left .35s ease-out, top .35s ease-out;
    pointer-events: none;
}

.pond-frog svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.pond-frog.jump svg {
    animation: frogJump .35s ease-out;
}

@keyframes frogJump {
    50% {
        transform: translateY(-26px);
    }
}

.choices {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.choice {
    font-family: inherit;
    font-weight: 800;
    font-size: 1.7rem;
    min-width: 96px;
    padding: .4rem 1rem;
    border: none;
    border-radius: 18px;
    background: #fff;
    color: var(--ink);
    box-shadow: 0 5px 0 #dcd8f5, 0 8px 18px rgba(80, 70, 140, .12);
    cursor: pointer;
    touch-action: manipulation;
}

.choice.right {
    background: var(--good);
    color: #fff;
    box-shadow: 0 5px 0 #1f9456;
}

.choice.wrong {
    background: #ffe7d4;
    color: var(--ink-soft);
    box-shadow: none;
    opacity: .7;
}

/* ---------------- fact map ---------------- */
.legend {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    font-weight: 700;
    color: var(--ink-soft);
}

.legend span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend .fcell {
    width: 20px;
    height: 20px;
    display: inline-block;
    border-radius: 6px;
}

.fact-grid-wrap {
    overflow-x: auto;
    padding-bottom: 6px;
}

.fact-grid {
    display: grid;
    grid-template-columns: repeat(13, minmax(30px, 1fr));
    gap: 3px;
    max-width: 680px;
    margin: 0 auto;
    min-width: 440px;
}

.fhead {
    display: grid;
    place-items: center;
    font-weight: 800;
    color: var(--rb-dark);
    font-size: 1rem;
    aspect-ratio: 1;
}

.fhead.corner {
    color: var(--ink-soft);
}

.fcell {
    font-family: inherit;
    border: none;
    aspect-ratio: 1;
    border-radius: 8px;
    font-weight: 700;
    font-size: .82rem;
    cursor: pointer;
    color: var(--ink-soft);
    transition: transform .1s;
}

.fcell:hover {
    transform: scale(1.12);
}

.f-new {
    background: #fff;
    box-shadow: inset 0 0 0 2px #e6e3fa;
}

.f-b0,
.f-b1 {
    background: #ffe2c8;
    color: #a0562a;
}

.f-b2,
.f-b3 {
    background: #c9efe9;
    color: var(--ra-dark);
}

.f-gold {
    position: relative;
    background: var(--gold);
    color: #fff;
    box-shadow: inset 0 -3px 0 var(--gold-dark);
}

.f-gold::after {
    content: '\2605';
    position: absolute;
    top: 0;
    right: 3px;
    font-size: .6rem;
}

.fcell.sel {
    outline: 3px solid var(--rb);
    outline-offset: 1px;
}

.fact-detail {
    max-width: 520px;
    margin: 16px auto 0;
    text-align: center;
}

.fact-detail[hidden] {
    display: none;
}

/* ---------------- review setup ---------------- */
.table-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.table-chips.shake {
    animation: shake .4s;
}

@keyframes shake {

    25%,
    75% {
        transform: translateX(-6px);
    }

    50% {
        transform: translateX(6px);
    }
}

.tchip {
    font-family: inherit;
    font-weight: 800;
    font-size: 1.25rem;
    min-width: 64px;
    padding: .35rem .6rem;
    border-radius: 14px;
    border: 3px solid #ddd6ff;
    background: #fff;
    color: var(--ink-soft);
    cursor: pointer;
}

.tchip.on {
    background: var(--rb);
    border-color: var(--rb);
    color: #fff;
}

.tchip.small {
    font-size: 1rem;
    min-width: 48px;
    padding: .2rem .5rem;
}

.games.small .game-btn {
    padding: 12px 10px;
}

/* ---------------- block buddies ---------------- */
.bud-ctrl {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
}

.bud-num {
    font-family: 'Fredoka One', 'Baloo 2', sans-serif;
    font-size: 2.6rem;
    color: var(--rb-dark);
    min-width: 90px;
    text-align: center;
}

.bud-num small {
    font-size: 1.2rem;
    color: var(--ink-soft);
}

.bud-num.small {
    font-size: 1.8rem;
    min-width: 50px;
}

#budSlider {
    display: block;
    width: min(420px, 90%);
    margin: 6px auto;
}

.bud-quick {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.bud-stage {
    position: relative;
    height: 200px;
    background: #f6f4ff;
    border-radius: 20px;
    transition: height .4s;
    overflow: hidden;
}

.bblk {
    position: absolute;
    left: 50%;
    top: 8px;
    width: 10px;
    height: 10px;
    border-radius: 22%;
    background: var(--ra);
    box-shadow: inset 0 -3px 0 var(--ra-dark);
    transition: left .6s cubic-bezier(.5, 1.6, .5, 1), top .6s cubic-bezier(.5, 1.6, .5, 1), width .4s, height .4s, background .4s;
}

.bblk.rb {
    background: var(--rb);
    box-shadow: inset 0 -3px 0 var(--rb-dark);
}

.bud-pairs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.pair {
    font-family: inherit;
    font-weight: 800;
    font-size: 1.3rem;
    padding: .3rem .9rem;
    border-radius: 14px;
    border: 3px solid #ddd6ff;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
}

.pair small {
    font-size: .7rem;
    color: var(--ink-soft);
    font-weight: 700;
    display: none;
}

.pair.active {
    background: var(--ra);
    border-color: var(--ra);
    color: #fff;
}

.pair.active small {
    display: block;
    color: #e6fffb;
}

/* ---------------- reward overlay ---------------- */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(40, 36, 80, .45);
    display: none;
    place-items: center;
    z-index: 60;
    padding: 16px;
}

.overlay.show {
    display: grid;
    animation: rise .3s;
}

.reward-card {
    background: var(--paper);
    border-radius: 30px;
    padding: 26px 24px;
    text-align: center;
    max-width: 440px;
    box-shadow: var(--shadow);
}

.reward-stars {
    font-size: 2.8rem;
    letter-spacing: 4px;
}

.reward-stars b {
    color: var(--gold);
    display: inline-block;
    animation: starPop .5s backwards;
}

.reward-stars b:nth-child(2) {
    animation-delay: .15s;
}

.reward-stars b:nth-child(3) {
    animation-delay: .3s;
}

.reward-stars b:nth-child(4) {
    animation-delay: .45s;
}

.reward-stars span {
    color: #dedfee;
}

@keyframes starPop {
    from {
        transform: scale(0) rotate(-60deg);
    }
}

.reward-card h2 {
    font-family: 'Fredoka One', 'Baloo 2', sans-serif;
    color: var(--rb-dark);
    font-size: 1.9rem;
}

.reward-card p {
    font-size: 1.1rem;
    color: var(--ink-soft);
    margin: 6px 0 4px;
}

/* ---------------- confetti ---------------- */
.confetti {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 70;
    overflow: hidden;
}

.conf {
    position: absolute;
    top: -20px;
    width: 10px;
    height: 14px;
    border-radius: 3px;
    animation: fall linear forwards;
}

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

/* ---------------- small screens ---------------- */
@media (max-width: 760px) {
    .towers {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 560px) {
    .towers {
        grid-template-columns: repeat(3, 1fr);
    }

    .card {
        padding: 16px;
        border-radius: 22px;
    }

    .pad-keys {
        grid-template-columns: repeat(3, 64px);
    }

    .pad-key {
        height: 52px;
    }

    .monster {
        transform: scale(.85);
    }

    .cookie {
        width: 76px;
        height: 76px;
        font-size: 1.1rem;
    }

    .stone {
        width: 54px;
        height: 40px;
        font-size: 1.1rem;
    }

    .tab {
        font-size: .98rem;
    }

    .arr-wrap.labelled {
        padding-left: 58px;
    }

    .arr-lab.top {
        left: 58px;
    }

    .arr-lab.side {
        width: 54px;
        font-size: .85rem;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
