/* ===========================================================
   layer-2.quest — the second-layer arcade
   y2k-futurism + bento-box + approachable-casual
   =========================================================== */

:root {
    --burnt-orange: #D8602A;
    --sherbet-cream: #FBE9C9;
    --periwinkle-bloop: #A8B6E8;
    --jade-soda: #7DC4A1;
    --pixel-bubblegum: #F4A8C0;
    --carbon-plum: #2E1F2A;
    --plum-faded: #5A4452;

    --radius-cell: 36px;
    --border-w: 4px;
    --inset-hl: inset 0 0 0 2px var(--sherbet-cream);

    --font-display: 'Bagel Fat One', 'DM Sans', system-ui, sans-serif;
    --font-body: 'DM Sans', system-ui, sans-serif;
    --font-hand: 'Caveat', 'DM Sans', cursive;
    --font-mono: 'Major Mono Display', 'Courier New', monospace;

    --bezier-bounce: cubic-bezier(.34, 1.56, .64, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--sherbet-cream);
    color: var(--carbon-plum);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.55;
    text-transform: lowercase;
    letter-spacing: 0.01em;
    cursor: none;
}

body {
    position: relative;
    background-image:
        radial-gradient(ellipse 1200px 800px at 30% 20%, rgba(168, 182, 232, 0.18), transparent 60%),
        radial-gradient(ellipse 800px 700px at 80% 90%, rgba(244, 168, 192, 0.14), transparent 60%),
        linear-gradient(180deg, #FCEED1 0%, var(--sherbet-cream) 60%, #F5DDB6 100%);
}

/* === Site-wide Noise Overlay ===================== */
.noise-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9000;
    opacity: 0.06;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.18 0 0 0 0 0.12 0 0 0 0 0.16 0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 200px 200px;
}

/* CRT scanline ghost */
.noise-overlay::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(
        180deg,
        rgba(46, 31, 42, 0) 0px,
        rgba(46, 31, 42, 0) 2px,
        rgba(46, 31, 42, 0.04) 2px,
        rgba(46, 31, 42, 0.04) 3px
    );
    opacity: 0.5;
    mix-blend-mode: multiply;
}

/* === Outer Lunchbox Panel ========================= */
.lunchbox {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 28px;
    transform-origin: center center;
    animation: lunchboxArrive 720ms var(--bezier-bounce) both, lunchboxRock 9s ease-in-out infinite 720ms;
}

@keyframes lunchboxArrive {
    0%   { transform: translateY(-220px) scale(0.92) rotate(-1.5deg); opacity: 0; }
    60%  { transform: translateY(0) scale(1.06) rotate(0.6deg); opacity: 1; }
    78%  { transform: translateY(0) scale(0.98) rotate(-0.2deg); }
    90%  { transform: translateY(0) scale(1.02) rotate(0deg); }
    100% { transform: translateY(0) scale(1.00) rotate(0deg); }
}

@keyframes lunchboxRock {
    0%   { transform: rotate(-0.6deg); }
    50%  { transform: rotate(0.6deg); }
    100% { transform: rotate(-0.6deg); }
}

/* === Bento Lattice ================================= */
.bento {
    width: min(1480px, 96vw);
    height: min(880px, 92vh);
    display: grid;
    grid-template-columns: 40fr 15fr 30fr 15fr;
    grid-template-rows: 35fr 30fr 35fr;
    grid-template-areas:
        "c1 c1 c2 c3"
        "c4 c5 c5 c6"
        "c7 c7 c8 c9";
    gap: 14px;
    padding: 22px;
    background:
        linear-gradient(135deg, #FFEFD2 0%, #F8DEB4 100%);
    border-radius: 48px;
    border: 5px solid var(--carbon-plum);
    box-shadow:
        var(--inset-hl),
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        inset 0 -2px 0 rgba(46, 31, 42, 0.18),
        0 28px 56px rgba(46, 31, 42, 0.22),
        0 4px 0 rgba(46, 31, 42, 0.4);
}

/* Grid-areas mapped to cells */
.cell-1 { grid-area: c1; }
.cell-2 { grid-area: c2; }
.cell-3 { grid-area: c3; }
.cell-4 { grid-area: c4; }
.cell-5 { grid-area: c5; }
.cell-6 { grid-area: c6; }
.cell-7 { grid-area: c7; }
.cell-8 { grid-area: c8; }
.cell-9 { grid-area: c9; }

/* === Cell Base ===================================== */
.cell {
    position: relative;
    border-radius: var(--radius-cell);
    border: var(--border-w) solid var(--carbon-plum);
    background: var(--sherbet-cream);
    box-shadow:
        var(--inset-hl),
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        inset 0 -2px 0 rgba(46, 31, 42, 0.18),
        0 6px 0 rgba(46, 31, 42, 0.18),
        0 14px 24px rgba(46, 31, 42, 0.12);
    padding: 22px;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.4) translateY(-40px);
    animation: bounceEnter 720ms var(--bezier-bounce) both;
}

@keyframes bounceEnter {
    0%   { transform: scale(0.4) translateY(-40px); opacity: 0; }
    60%  { transform: scale(1.12) translateY(0);    opacity: 1; }
    78%  { transform: scale(0.96) translateY(0); }
    90%  { transform: scale(1.03) translateY(0); }
    100% { transform: scale(1.00) translateY(0); }
}

/* Tilts: odd -1.4deg, even +0.9deg */
.cell-1 { animation-delay: 1000ms; transform: scale(0.4) translateY(-40px) rotate(-1.4deg); background: linear-gradient(140deg, #FBE9C9 0%, #F8DAA9 100%); }
.cell-2 { animation-delay: 1665ms; transform: scale(0.4) translateY(-40px) rotate(0.9deg); background: #FCEFD3; }
.cell-3 { animation-delay: 1190ms; transform: scale(0.4) translateY(-40px) rotate(-1.4deg); background: linear-gradient(155deg, #BCC8EE 0%, #A8B6E8 100%); }
.cell-4 { animation-delay: 1380ms; transform: scale(0.4) translateY(-40px) rotate(0.9deg); background: #FBE9C9; }
.cell-5 { animation-delay: 1095ms; transform: scale(0.4) translateY(-40px) rotate(-1.4deg); background: linear-gradient(160deg, #F8E1B4 0%, #F2CB8E 100%); }
.cell-6 { animation-delay: 1475ms; transform: scale(0.4) translateY(-40px) rotate(0.9deg); background: linear-gradient(180deg, #2E1F2A 0%, #3D2A35 100%); }
.cell-7 { animation-delay: 1285ms; transform: scale(0.4) translateY(-40px) rotate(-1.4deg); background: #FBE9C9; }
.cell-8 { animation-delay: 1760ms; transform: scale(0.4) translateY(-40px) rotate(0.9deg); background: linear-gradient(155deg, #FCEFD3 0%, #F4DDB1 100%); }
.cell-9 { animation-delay: 1570ms; transform: scale(0.4) translateY(-40px) rotate(-1.4deg); background: #FFF5DD; }

/* When animation finishes, retain rotation through final transform: rely on animation's final keyframe (scale 1, translateY 0) — re-apply tilt via wrapper hack: we use will-change + a sub-rule after animation */
@keyframes bounceEnterOdd {
    0%   { transform: scale(0.4) translateY(-40px) rotate(-1.4deg); opacity: 0; }
    60%  { transform: scale(1.12) translateY(0) rotate(-1.4deg);    opacity: 1; }
    78%  { transform: scale(0.96) translateY(0) rotate(-1.4deg); }
    90%  { transform: scale(1.03) translateY(0) rotate(-1.4deg); }
    100% { transform: scale(1.00) translateY(0) rotate(-1.4deg); }
}
@keyframes bounceEnterEven {
    0%   { transform: scale(0.4) translateY(-40px) rotate(0.9deg); opacity: 0; }
    60%  { transform: scale(1.12) translateY(0) rotate(0.9deg);    opacity: 1; }
    78%  { transform: scale(0.96) translateY(0) rotate(0.9deg); }
    90%  { transform: scale(1.03) translateY(0) rotate(0.9deg); }
    100% { transform: scale(1.00) translateY(0) rotate(0.9deg); }
}

.cell-1, .cell-3, .cell-5, .cell-7, .cell-9 { animation-name: bounceEnterOdd; }
.cell-2, .cell-4, .cell-6, .cell-8 { animation-name: bounceEnterEven; }

/* === Compartment 1: THE BIG SMILE ================= */
.cell-1 {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 32px 38px;
}

.bg-blob-wrap {
    position: absolute;
    top: -12%;
    right: -8%;
    width: 70%;
    height: 90%;
    pointer-events: none;
    z-index: 0;
}

.hero-blob {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 18px 32px rgba(46, 31, 42, 0.18));
    animation: heroBlobSpin 14s linear infinite;
}

@keyframes heroBlobSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.wordmark {
    position: relative;
    z-index: 2;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(3.6rem, 7.2vw, 7.6rem);
    line-height: 0.92;
    letter-spacing: -0.02em;
    color: var(--carbon-plum);
    text-shadow:
        6px 6px 0 var(--burnt-orange),
        12px 12px 0 var(--sherbet-cream),
        18px 18px 0 var(--periwinkle-bloop);
    user-select: none;
    cursor: none;
}

.wordmark .g {
    display: inline-block;
    animation: wordmarkWobble 3.2s ease-in-out infinite;
    transform-origin: center bottom;
}

.wordmark .g:nth-child(1)  { animation-delay: -0.0s; }
.wordmark .g:nth-child(2)  { animation-delay: -0.25s; }
.wordmark .g:nth-child(3)  { animation-delay: -0.5s; }
.wordmark .g:nth-child(4)  { animation-delay: -0.75s; }
.wordmark .g:nth-child(5)  { animation-delay: -1.0s; }
.wordmark .g:nth-child(6)  { animation-delay: -1.25s; }
.wordmark .g:nth-child(7)  { animation-delay: -1.5s; }
.wordmark .g:nth-child(8)  { animation-delay: -1.75s; }
.wordmark .g:nth-child(9)  { animation-delay: -2.0s; }
.wordmark .g:nth-child(10) { animation-delay: -2.25s; }
.wordmark .g:nth-child(11) { animation-delay: -2.5s; }
.wordmark .g:nth-child(12) { animation-delay: -2.75s; }
.wordmark .g:nth-child(13) { animation-delay: -3.0s; }

@keyframes wordmarkWobble {
    0%   { transform: translateY(0px) rotate(-1deg); }
    25%  { transform: translateY(-6px) rotate(2deg); }
    50%  { transform: translateY(0px) rotate(-1deg); }
    75%  { transform: translateY(6px) rotate(2deg); }
    100% { transform: translateY(0px) rotate(-1deg); }
}

.wordmark.foil-active .g {
    background: linear-gradient(90deg, #F4A8C0, #FBE9C9, #A8B6E8, #7DC4A1, #D8602A, #F4A8C0);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    animation: wordmarkWobble 3.2s ease-in-out infinite, foilSweep 1.4s linear;
}

@keyframes foilSweep {
    from { background-position: -300% 0; }
    to   { background-position: 300% 0; }
}

.welcome {
    position: relative;
    z-index: 2;
    margin-top: 20px;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 17px;
    color: var(--plum-faded);
    max-width: 75%;
}

/* === Compartment 2: THE PILL DRAWER =============== */
.cell-2 {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 18px 12px;
}

.pill-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    align-items: center;
}

.pill {
    position: relative;
    width: 92%;
    padding: 14px 12px;
    border: 3px solid var(--carbon-plum);
    border-radius: 999px;
    font-family: var(--font-display);
    font-size: 22px;
    color: var(--carbon-plum);
    cursor: none;
    text-transform: lowercase;
    transition: transform 220ms var(--bezier-bounce), box-shadow 220ms ease, filter 220ms ease;
    transform: scale(0);
    background: var(--sherbet-cream);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.7),
        inset 0 -2px 0 rgba(46, 31, 42, 0.2),
        0 4px 0 var(--carbon-plum),
        0 8px 14px rgba(46, 31, 42, 0.18);
}

.pill-hi    { background: linear-gradient(180deg, #FFD6E8 0%, #F4A8C0 100%); animation: pillEnter 720ms var(--bezier-bounce) 1900ms both; }
.pill-about { background: linear-gradient(180deg, #C4D0F2 0%, #A8B6E8 100%); animation: pillEnter 720ms var(--bezier-bounce) 2010ms both; }
.pill-snack { background: linear-gradient(180deg, #A8DDC2 0%, #7DC4A1 100%); animation: pillEnter 720ms var(--bezier-bounce) 2120ms both; }

@keyframes pillEnter {
    0%   { transform: scale(0.4) translateY(-20px); opacity: 0; }
    60%  { transform: scale(1.18) translateY(0);    opacity: 1; }
    78%  { transform: scale(0.94) translateY(0); }
    90%  { transform: scale(1.04) translateY(0); }
    100% { transform: scale(1.00) translateY(0); }
}

.pill:hover {
    transform: scale(1.08) translateY(-4px);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.85),
        inset 0 -2px 0 rgba(46, 31, 42, 0.2),
        0 6px 0 var(--carbon-plum),
        0 14px 22px rgba(46, 31, 42, 0.25);
    filter: brightness(1.05);
}

.pill.active {
    transform: scale(0.96) translateY(2px);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.7),
        inset 0 -2px 0 rgba(46, 31, 42, 0.2),
        0 2px 0 var(--carbon-plum),
        0 4px 8px rgba(46, 31, 42, 0.2);
}

.pill.bouncing {
    animation: pillBounce 460ms var(--bezier-bounce);
}
@keyframes pillBounce {
    0%   { transform: scale(1.0); }
    35%  { transform: scale(1.18) translateY(-6px); }
    70%  { transform: scale(0.92) translateY(2px); }
    100% { transform: scale(1.0); }
}

.pill-drawer {
    width: 100%;
    max-height: 0;
    overflow: hidden;
    border-radius: 22px;
    transition: max-height 380ms var(--bezier-bounce), padding 220ms ease, opacity 280ms ease;
    background: rgba(46, 31, 42, 0.06);
    border: 0px solid transparent;
    color: var(--carbon-plum);
    opacity: 0;
}
.pill-drawer.open {
    max-height: 240px;
    padding: 14px 14px;
    border: 2px dashed var(--carbon-plum);
    opacity: 1;
}
.drawer-content {
    display: none;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    color: var(--carbon-plum);
}
.drawer-content.shown {
    display: block;
    animation: drawerFade 320ms ease both;
}
@keyframes drawerFade {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* === Compartment 3: THE JELLY ORB ================== */
.cell-3 {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.orb-stage {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: none;
}

.jelly-orb {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    aspect-ratio: 1 / 1;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0.3) 18%, transparent 32%),
        radial-gradient(circle at 65% 70%, rgba(46, 31, 42, 0.18) 0%, transparent 50%),
        radial-gradient(circle at 50% 55%, #C4D0F2 0%, #A8B6E8 60%, #7B8DC8 100%);
    box-shadow:
        inset 6px 6px 14px rgba(255, 255, 255, 0.55),
        inset -8px -10px 24px rgba(46, 31, 42, 0.28),
        0 16px 30px rgba(46, 31, 42, 0.28),
        0 0 0 4px var(--carbon-plum);
    animation: orbOrbit 3s ease-in-out infinite;
    transition: transform 320ms var(--bezier-bounce);
    transform-origin: center center;
}

.orb-specular {
    position: absolute;
    top: 16%;
    left: 22%;
    width: 30%;
    height: 22%;
    border-radius: 50%;
    background: radial-gradient(ellipse at 30% 30%, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0) 65%);
    pointer-events: none;
}

.orb-core {
    display: none;
}

@keyframes orbOrbit {
    0%   { transform: translate(-58%, -50%) scale(1); }
    25%  { transform: translate(-50%, -58%) scale(1); }
    50%  { transform: translate(-42%, -50%) scale(1); }
    75%  { transform: translate(-50%, -42%) scale(1); }
    100% { transform: translate(-58%, -50%) scale(1); }
}

.jelly-orb.wobble {
    animation: orbWobble 720ms var(--bezier-bounce), orbOrbit 3s ease-in-out infinite 720ms;
}
@keyframes orbWobble {
    0%   { transform: translate(-50%, -50%) scale(1, 1); }
    25%  { transform: translate(-50%, -50%) scale(1.18, 0.84); }
    50%  { transform: translate(-50%, -50%) scale(0.88, 1.16); }
    75%  { transform: translate(-50%, -50%) scale(1.06, 0.94); }
    100% { transform: translate(-50%, -50%) scale(1, 1); }
}

.cell-tag {
    position: absolute;
    top: 14px;
    right: 16px;
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--carbon-plum);
    background: var(--sherbet-cream);
    padding: 4px 12px;
    border-radius: 999px;
    border: 2px solid var(--carbon-plum);
    box-shadow: 0 3px 0 var(--carbon-plum);
    z-index: 5;
}

/* === Compartment 4: THE NOTE ======================= */
.cell-4 {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        repeating-linear-gradient(0deg, transparent 0, transparent 22px, rgba(168, 182, 232, 0.22) 22px, rgba(168, 182, 232, 0.22) 23px),
        var(--sherbet-cream);
}

.thumbtack {
    position: absolute;
    top: 16px;
    left: 50%;
    width: 16px;
    height: 16px;
    background: var(--burnt-orange);
    border-radius: 50%;
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.7),
        inset -1px -1px 0 rgba(46, 31, 42, 0.5),
        0 4px 6px rgba(46, 31, 42, 0.4),
        0 0 0 2px var(--carbon-plum);
    transform: translateX(-50%);
    z-index: 4;
}

.thumbtack::after {
    content: "";
    position: absolute;
    top: 14px;
    left: 5px;
    width: 4px;
    height: 4px;
    background: var(--carbon-plum);
    border-radius: 50%;
}

.note-text {
    font-family: var(--font-hand);
    font-weight: 500;
    font-size: 28px;
    line-height: 1.3;
    color: var(--plum-faded);
    text-align: center;
    padding: 26px 14px 14px;
    text-transform: lowercase;
    position: relative;
    z-index: 2;
}

.cursor-blink {
    display: inline-block;
    color: var(--burnt-orange);
    animation: cursorBlink 0.7s steps(2) infinite;
    margin-left: 2px;
    font-weight: 700;
}
@keyframes cursorBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* === Compartment 5: THE BLOB GARDEN ================ */
.cell-5 {
    padding: 0;
}

.garden-noise {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    opacity: 0.09;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.18 0 0 0 0 0.12 0 0 0 0 0.16 0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 200px 200px;
    border-radius: var(--radius-cell);
}

.blob-garden {
    width: 100%;
    height: 100%;
    display: block;
    cursor: none;
}

.garden-tag {
    position: absolute;
    bottom: 12px;
    left: 14px;
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--carbon-plum);
    background: var(--sherbet-cream);
    padding: 3px 10px;
    border-radius: 999px;
    border: 2px solid var(--carbon-plum);
    box-shadow: 0 3px 0 var(--carbon-plum);
    z-index: 5;
}

/* === Compartment 6: THE COUNTER ==================== */
.cell-6 {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 12px;
    background: linear-gradient(180deg, #2E1F2A 0%, #3D2A35 100%) !important;
    color: var(--sherbet-cream);
    border-color: var(--carbon-plum);
}

.counter {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.32);
    border-radius: 14px;
    padding: 10px 8px;
    box-shadow:
        inset 0 2px 6px rgba(0, 0, 0, 0.6),
        inset 0 -1px 0 rgba(255, 255, 255, 0.1);
}

.digit {
    position: relative;
    width: 22px;
    height: 36px;
    perspective: 200px;
    background: var(--carbon-plum);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.06);
}

.digit-front, .digit-back {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 24px;
    color: var(--burnt-orange);
    text-shadow: 0 0 8px rgba(216, 96, 42, 0.6);
    backface-visibility: hidden;
}

.digit-back {
    transform: rotateX(-180deg);
}

.digit.flipping .digit-front {
    animation: flipFront 360ms ease-in forwards;
}
.digit.flipping .digit-back {
    animation: flipBack 360ms ease-in forwards;
}

@keyframes flipFront {
    0%   { transform: rotateX(0deg); }
    100% { transform: rotateX(180deg); }
}
@keyframes flipBack {
    0%   { transform: rotateX(-180deg); }
    100% { transform: rotateX(0deg); }
}

.counter-tag {
    color: var(--sherbet-cream);
    background: var(--burnt-orange);
    border-color: var(--carbon-plum);
}

/* === Compartment 7: THE SHELF OF QUESTS ============ */
.cell-7 {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.quest-rail {
    display: flex;
    gap: 12px;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: space-between;
}

.quest-tab {
    flex: 1 1 22%;
    height: 88%;
    border: 3px solid var(--carbon-plum);
    border-radius: 24px;
    cursor: none;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 14px;
    line-height: 1.3;
    color: var(--carbon-plum);
    text-align: center;
    text-transform: lowercase;
    padding: 14px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 280ms var(--bezier-bounce), box-shadow 240ms ease, filter 240ms ease;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.55),
        inset 0 -2px 0 rgba(46, 31, 42, 0.2),
        0 5px 0 var(--carbon-plum),
        0 10px 18px rgba(46, 31, 42, 0.18);
    animation: questBreathe 4s ease-in-out infinite;
}

.quest-orange { background: linear-gradient(180deg, #F08A4F 0%, #D8602A 100%); }
.quest-peri   { background: linear-gradient(180deg, #C4D0F2 0%, #A8B6E8 100%); }
.quest-jade   { background: linear-gradient(180deg, #A8DDC2 0%, #7DC4A1 100%); }
.quest-bubble { background: linear-gradient(180deg, #FFD0E0 0%, #F4A8C0 100%); }

.quest-tab span {
    pointer-events: none;
    display: block;
}

.quest-tab:nth-child(1) { animation-delay: 0s; }
.quest-tab:nth-child(2) { animation-delay: 0.6s; }
.quest-tab:nth-child(3) { animation-delay: 1.2s; }
.quest-tab:nth-child(4) { animation-delay: 1.8s; }

@keyframes questBreathe {
    0%   { transform: scale(1.0); }
    50%  { transform: scale(1.02); }
    100% { transform: scale(1.0); }
}

.quest-tab.hovering {
    transform: scale(1.06, 0.96) rotate(1.5deg);
    filter: brightness(1.06);
    animation: none;
}

.quest-tab.bouncing {
    animation: questBounce 460ms var(--bezier-bounce);
}
@keyframes questBounce {
    0%   { transform: scale(1.0); }
    30%  { transform: scale(1.14, 0.92); }
    60%  { transform: scale(0.94, 1.08); }
    100% { transform: scale(1.0); }
}

.quest-heading {
    background: var(--burnt-orange);
    color: var(--sherbet-cream);
    border-color: var(--carbon-plum);
}

/* === Compartment 8: THE PET ======================== */
.cell-8 {
    overflow: hidden;
    padding: 12px;
}

.pet-stage {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: none;
}

.pet {
    position: relative;
    width: 50%;
    aspect-ratio: 1 / 1;
    transform: translateX(0px) translateY(0px);
    transition: transform 30ms linear;
    cursor: none;
}

.pet-blob {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 14px 22px rgba(46, 31, 42, 0.22));
}

.pet-eye {
    position: absolute;
    width: 8%;
    height: 14%;
    background: var(--carbon-plum);
    border-radius: 50%;
    transition: transform 130ms var(--bezier-bounce);
}

.pet-eye-left  { top: 38%; left: 32%; }
.pet-eye-right { top: 38%; right: 32%; }

.pet-eye.blink {
    transform: scaleY(0.05);
}

.pet-blush {
    position: absolute;
    width: 14%;
    height: 8%;
    background: var(--pixel-bubblegum);
    border-radius: 50%;
    opacity: 0.85;
    filter: blur(0.6px);
}

.pet-blush-left  { top: 56%; left: 18%; }
.pet-blush-right { top: 56%; right: 18%; }

.pet.hopping {
    animation: petHop 540ms var(--bezier-bounce);
}
.pet.bighop {
    animation: petBigHop 700ms var(--bezier-bounce);
}
@keyframes petHop {
    0%   { transform: translateX(var(--px, 0px)) translateY(0); }
    40%  { transform: translateX(var(--px, 0px)) translateY(-14px); }
    100% { transform: translateX(var(--px, 0px)) translateY(0); }
}
@keyframes petBigHop {
    0%   { transform: translateX(var(--px, 0px)) translateY(0) scale(1); }
    35%  { transform: translateX(var(--px, 0px)) translateY(-28px) scale(1.06); }
    100% { transform: translateX(var(--px, 0px)) translateY(0) scale(1); }
}

.pet-shadow {
    position: absolute;
    bottom: 14%;
    left: 50%;
    width: 32%;
    height: 6%;
    background: rgba(46, 31, 42, 0.18);
    border-radius: 50%;
    transform: translateX(-50%);
    filter: blur(2px);
}

.heart-particle {
    position: absolute;
    width: 22px;
    height: 22px;
    color: var(--pixel-bubblegum);
    font-size: 22px;
    pointer-events: none;
    animation: heartFloat 900ms ease-out forwards;
    text-shadow: 0 0 0 var(--carbon-plum);
}
@keyframes heartFloat {
    0%   { opacity: 0; transform: translateY(0) scale(0.6); }
    20%  { opacity: 1; transform: translateY(-8px) scale(1.2); }
    100% { opacity: 0; transform: translateY(-46px) scale(0.9); }
}

.pet-tag {
    background: var(--jade-soda);
    color: var(--carbon-plum);
}

/* === Compartment 9: THE FOOTER-AS-RECEIPT ========== */
.cell-9 {
    padding: 14px;
    background: transparent !important;
    border: var(--border-w) dashed var(--carbon-plum);
    box-shadow:
        var(--inset-hl),
        0 4px 0 rgba(46, 31, 42, 0.15);
}

.receipt {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--sherbet-cream);
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--plum-faded);
    box-shadow: 0 4px 12px rgba(46, 31, 42, 0.16);
    background-image: repeating-linear-gradient(
        180deg,
        transparent 0,
        transparent 26px,
        rgba(168, 182, 232, 0.12) 26px,
        rgba(168, 182, 232, 0.12) 27px
    );
}

.receipt-perf {
    position: absolute;
    left: 0;
    right: 0;
    height: 12px;
    background-image: radial-gradient(circle at 6px 6px, var(--sherbet-cream) 5px, transparent 5.5px);
    background-size: 14px 14px;
    background-color: transparent;
}

.perf-top    { top: -7px; }
.perf-bottom { bottom: -7px; }

.receipt-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.receipt-line {
    text-transform: lowercase;
}

.receipt-head {
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--carbon-plum);
    text-align: center;
    margin-bottom: 4px;
    letter-spacing: 0.04em;
}

.receipt-thanks {
    font-family: var(--font-hand);
    font-size: 22px;
    color: var(--burnt-orange);
    text-align: center;
    margin-top: 6px;
}

.receipt-barcode {
    display: flex;
    gap: 1px;
    height: 28px;
    margin: 8px 0;
    align-items: stretch;
    justify-content: center;
}
.receipt-barcode span {
    display: block;
    width: 3px;
    background: var(--carbon-plum);
}
.receipt-barcode span:nth-child(2n)  { width: 1px; background: var(--jade-soda); }
.receipt-barcode span:nth-child(3n)  { width: 4px; }
.receipt-barcode span:nth-child(5n)  { width: 2px; background: var(--jade-soda); }
.receipt-barcode span:nth-child(7n)  { width: 5px; }

.speaker-toggle {
    margin-top: 8px;
    align-self: center;
    background: var(--sherbet-cream);
    border: 2px solid var(--carbon-plum);
    border-radius: 999px;
    padding: 5px 12px;
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--carbon-plum);
    cursor: none;
    box-shadow: 0 3px 0 var(--carbon-plum);
    transition: transform 200ms var(--bezier-bounce);
    text-transform: lowercase;
}
.speaker-toggle:hover { transform: scale(1.05); }
.speaker-toggle.on    { background: var(--jade-soda); }

/* === Custom Cursor ================================= */
.cursor-blob {
    position: fixed;
    width: 24px;
    height: 24px;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    transition: transform 180ms var(--bezier-bounce), filter 180ms ease;
    filter: drop-shadow(0 4px 6px rgba(46, 31, 42, 0.3));
    will-change: transform, left, top;
}

.cursor-blob.inflated {
    transform: translate(-50%, -50%) scale(1.4);
    filter: drop-shadow(0 6px 10px rgba(46, 31, 42, 0.4)) drop-shadow(0 0 6px rgba(244, 168, 192, 0.7));
}

.cursor-blob.inflated svg path {
    fill: var(--burnt-orange);
}

/* === Mobile Responsive ============================= */
@media (max-width: 1024px) {
    html, body { overflow: auto; }
    .lunchbox {
        position: relative;
        height: auto;
        min-height: 100vh;
        padding: 16px;
    }
    .bento {
        height: auto;
        width: 100%;
        max-width: 720px;
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        grid-template-areas:
            "c1"
            "c5"
            "c3"
            "c7"
            "c4"
            "c6"
            "c9"
            "c2"
            "c8";
        gap: 12px;
    }
    .cell { min-height: 220px; }
    .cell-1 { min-height: 280px; }
    .cell-5 { min-height: 320px; }
    .cell-1, .cell-3, .cell-5, .cell-7, .cell-9 { transform: rotate(-0.5deg); }
    .cell-2, .cell-4, .cell-6, .cell-8 { transform: rotate(0.5deg); }
    .cell-1 { width: 96%; margin-left: 0; }
    .cell-2 { width: 76%; margin-left: 22%; }
    .cell-3 { width: 88%; margin-left: 6%; }
    .cell-4 { width: 70%; margin-left: 0; }
    .cell-5 { width: 92%; margin-left: 4%; }
    .cell-6 { width: 64%; margin-left: 30%; }
    .cell-7 { width: 96%; margin-left: 0; }
    .cell-8 { width: 58%; margin-left: 36%; }
    .cell-9 { width: 86%; margin-left: 8%; }
    .quest-rail { flex-direction: column; }
    .quest-tab { flex-basis: auto; height: auto; min-height: 60px; width: 100%; }
}

@media (max-width: 768px) {
    .wordmark { font-size: clamp(2.8rem, 12vw, 5rem); }
    .cell { padding: 16px; }
    body { cursor: auto; }
    html, body { cursor: auto; }
    .cursor-blob { display: none; }
    .pill, .quest-tab, .speaker-toggle, .pet-stage, .orb-stage { cursor: pointer; }
}
