:root {
    --ink: #243042;
    --muted: #657086;
    --blue: #4f8cff;
    --green: #33b679;
    --yellow: #ffd166;
    --pink: #ff6b9a;
    --paper: #fffaf0;
    --panel: #ffffff;
    --line: #dfe6f3;
    --shadow: 0 18px 45px rgba(36, 48, 66, 0.14);
    --pop-shadow: 0 24px 70px rgba(255, 107, 154, 0.22);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: "Trebuchet MS", Arial, sans-serif;
    background:
        radial-gradient(circle at 16% 8%, rgba(255, 209, 102, 0.48), transparent 22rem),
        radial-gradient(circle at 84% 14%, rgba(79, 140, 255, 0.18), transparent 25rem),
        radial-gradient(circle at 76% 82%, rgba(51, 182, 121, 0.14), transparent 24rem),
        linear-gradient(135deg, #f7fbff 0%, #fff8df 54%, #f1fff7 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

.child-page {
    overflow-x: hidden;
    position: relative;
}

.child-page::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(120deg, rgba(255, 107, 154, 0.1), transparent 34%),
        linear-gradient(300deg, rgba(79, 140, 255, 0.12), transparent 36%);
    animation: backgroundDrift 12s ease-in-out infinite alternate;
}

.food-background {
    position: fixed;
    inset: 0;
    z-index: 2;
    overflow: hidden;
    pointer-events: none;
}

.food-background span {
    position: absolute;
    display: grid;
    place-items: center;
    width: clamp(42px, 5vw, 72px);
    height: clamp(42px, 5vw, 72px);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.62);
    box-shadow: 0 18px 42px rgba(36, 48, 66, 0.12);
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
    font-size: clamp(1.5rem, 3vw, 2.45rem);
    left: 0;
    top: 0;
    opacity: var(--trail-opacity, 0);
    transform:
        translate3d(var(--mouse-x, -120px), var(--mouse-y, -120px), 0)
        translate3d(var(--trail-offset-x, 0px), var(--trail-offset-y, 0px), 0)
        scale(var(--trail-scale, 1));
    transition: opacity 220ms ease;
    animation: foodFloat 18s ease-in-out infinite;
    animation-delay: calc(var(--i) * -2.2s);
}

.food-background span:nth-child(1) {
    --trail-offset-x: -12px;
    --trail-offset-y: -14px;
    --trail-scale: 1;
}

.food-background span:nth-child(2) {
    --trail-offset-x: 30px;
    --trail-offset-y: 18px;
    --trail-scale: 0.88;
}

.food-background span:nth-child(3) {
    --trail-offset-x: -48px;
    --trail-offset-y: 30px;
    --trail-scale: 0.82;
}

.food-background span:nth-child(4) {
    --trail-offset-x: 52px;
    --trail-offset-y: -34px;
    --trail-scale: 0.76;
}

.food-background span:nth-child(5) {
    --trail-offset-x: -70px;
    --trail-offset-y: -42px;
    --trail-scale: 0.7;
}

.food-background span:nth-child(6) {
    --trail-offset-x: 76px;
    --trail-offset-y: 46px;
    --trail-scale: 0.66;
}

.food-background span:nth-child(7) {
    --trail-offset-x: -92px;
    --trail-offset-y: 10px;
    --trail-scale: 0.62;
}

.food-background span:nth-child(8) {
    --trail-offset-x: 96px;
    --trail-offset-y: -4px;
    --trail-scale: 0.58;
}

.shell {
    position: relative;
    z-index: 1;
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 42px 0 56px;
}

.hero,
.admin-header,
.welcome-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.child-page .hero {
    align-items: center;
    min-height: 240px;
    padding: 10px 0 18px;
}

.hero-copy {
    max-width: 660px;
    animation: slideUp 640ms ease both;
}

.hero-actions {
    display: grid;
    justify-items: end;
    gap: 12px;
    animation: slideUp 780ms ease 90ms both;
}

.hero-art-wrap {
    position: relative;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.56);
    box-shadow: 0 24px 70px rgba(36, 48, 66, 0.12);
}

.hero-art {
    display: block;
    width: min(360px, 34vw);
    aspect-ratio: 15 / 7;
    border-radius: 8px;
    box-shadow: none;
    object-fit: cover;
    animation: heroBob 5s ease-in-out infinite;
}

.hero h1,
.admin-header h1 {
    margin: 0;
    font-size: clamp(2.35rem, 6vw, 4.4rem);
    line-height: 0.96;
    max-width: 760px;
    overflow-wrap: anywhere;
}

.child-page .hero h1 {
    max-width: 640px;
    text-wrap: balance;
}

.hero-subtitle {
    max-width: 580px;
    margin: 18px 0 0;
    color: #40506a;
    font-size: 1.25rem;
    font-weight: 800;
}

.eyebrow {
    margin: 0 0 8px;
    color: #006d77;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.panel {
    background: rgba(255, 255, 255, 0.92);
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 22px;
}

.login-panel {
    width: min(520px, 100%);
}

.front-grid {
    display: grid;
    grid-template-columns: minmax(280px, 620px) minmax(220px, 1fr);
    align-items: stretch;
    gap: 22px;
}

.child-page .login-panel {
    position: relative;
    overflow: hidden;
    width: 100%;
    border: 3px solid rgba(255, 255, 255, 0.95);
    background:
        linear-gradient(#ffffff, #ffffff) padding-box,
        linear-gradient(135deg, var(--pink), var(--yellow), var(--green), var(--blue)) border-box;
    box-shadow: 0 28px 80px rgba(36, 48, 66, 0.16);
    animation: cardPop 620ms ease 180ms both;
}

.front-note {
    display: grid;
    gap: 12px;
    align-content: center;
    padding: 24px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.62);
    border: 2px solid rgba(255, 255, 255, 0.84);
    box-shadow: 0 22px 55px rgba(36, 48, 66, 0.1);
    animation: slideUp 700ms ease 220ms both;
}

.front-note div {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 54px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-weight: 900;
    box-shadow: 0 10px 22px rgba(36, 48, 66, 0.08);
}

.front-note strong {
    display: inline-grid;
    place-items: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--yellow);
    color: #243042;
}

.child-page .login-panel::after {
    content: "";
    position: absolute;
    right: -58px;
    bottom: -62px;
    width: 170px;
    height: 170px;
    border-radius: 50%;
    background: rgba(255, 209, 102, 0.26);
}

h1,
h2,
h3 {
    letter-spacing: 0;
}

h2,
h3 {
    margin-top: 0;
}

.stack {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 2px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    padding: 12px 13px;
    background: #fff;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.emoji,
.emoji-picker,
input[name="emoji"] {
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    outline: 3px solid rgba(79, 140, 255, 0.18);
    transform: translateY(-1px);
}

.emoji-picker {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 8px;
}

.emoji-picker button {
    background: #fff;
    border: 2px solid var(--line);
    color: var(--ink);
    font-size: 1.35rem;
    min-height: 44px;
    padding: 6px;
}

.emoji-picker button:hover,
.emoji-picker button:focus {
    border-color: var(--blue);
    outline: 3px solid rgba(79, 140, 255, 0.18);
}

button,
.big-button,
.parent-link,
.small-link {
    border: 0;
    border-radius: 8px;
    background: var(--blue);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 15px;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
    max-width: 100%;
    transition: transform 170ms ease, box-shadow 170ms ease, filter 170ms ease;
}

.big-button {
    background: linear-gradient(135deg, var(--pink), #ff8a3d);
    font-size: 1.18rem;
    min-height: 58px;
    box-shadow: 0 14px 28px rgba(255, 107, 154, 0.26);
}

button:hover,
.big-button:hover,
.parent-link:hover,
.small-link:hover {
    filter: brightness(1.03);
    transform: translateY(-2px);
}

.child-page .big-button:hover {
    animation: buttonBounce 500ms ease;
}

.parent-link,
.small-link {
    background: #243042;
}

.choice-form {
    display: grid;
    gap: 22px;
    animation: slideUp 620ms ease both;
}

.meal-section {
    background: rgba(255, 255, 255, 0.72);
    border: 2px solid rgba(255, 255, 255, 0.86);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 16px 36px rgba(36, 48, 66, 0.1);
}

.choice-rank {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.choice-rank h4 {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin: 0;
    border-radius: 999px;
    background: #243042;
    color: #fff;
    font-size: 0.95rem;
    letter-spacing: 0;
    padding: 8px 13px;
}

.food-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
}

.food-card {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 10px;
    min-height: 148px;
    border: 3px solid transparent;
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 10px 22px rgba(36, 48, 66, 0.1);
    color: var(--ink);
    cursor: pointer;
    padding: 18px 12px;
    text-align: center;
    transition: transform 170ms ease, border-color 170ms ease, box-shadow 170ms ease;
}

.food-card.second-choice-card {
    background: #fffaf0;
}

.food-card:hover {
    transform: translateY(-4px) rotate(-0.5deg);
    box-shadow: 0 18px 32px rgba(36, 48, 66, 0.14);
}

.food-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.food-card:has(input:checked) {
    border-color: var(--green);
    background: #effff7;
    transform: translateY(-5px) rotate(0.5deg);
}

.emoji {
    font-size: 3.1rem;
    line-height: 1;
    transition: transform 170ms ease;
}

.food-card:hover .emoji,
.food-card:has(input:checked) .emoji {
    transform: scale(1.13) rotate(-5deg);
}

.note-box {
    color: var(--ink);
}

.send-button {
    width: min(420px, 100%);
    justify-self: center;
}

.flash {
    border-radius: 8px;
    color: #fff;
    font-weight: 800;
    margin-bottom: 18px;
    padding: 14px 16px;
}

.flash.success {
    background: var(--green);
}

.flash.error {
    background: #e5484d;
}

.flash.warning {
    background: #b7791f;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: 18px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 8px;
    text-align: left;
    vertical-align: middle;
}

.inline-form {
    display: flex;
    gap: 8px;
    min-width: 260px;
}

.food-list,
.pick-list {
    display: grid;
    gap: 10px;
}

.food-row,
.pick {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) auto auto minmax(130px, 170px) minmax(130px, 170px) auto auto auto;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.food-row.muted {
    opacity: 0.55;
}

.danger-button {
    background: #e5484d;
}

.pick {
    grid-template-columns: repeat(auto-fit, minmax(150px, auto));
    justify-content: start;
}

small,
em {
    color: var(--muted);
}

@media (max-width: 1080px) {
    .food-row {
        grid-template-columns: minmax(170px, 1fr) minmax(110px, auto) minmax(110px, auto);
    }

    .food-row span,
    .food-row small {
        grid-column: 1 / -1;
    }

    .food-row select,
    .food-row button {
        width: 100%;
    }
}

@media (max-width: 880px) {
    .front-grid {
        grid-template-columns: 1fr;
    }

    .front-note {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        padding: 16px;
    }

    .child-page .hero {
        min-height: 0;
    }

    .hero-art {
        width: min(360px, 46vw);
    }
}

@media (max-width: 720px) {
    .shell {
        width: min(100% - 20px, 1180px);
        padding: 16px 0 32px;
    }

    .hero,
    .admin-header,
    .welcome-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
    }

    .hero-actions {
        justify-items: start;
        width: 100%;
    }

    .front-grid {
        grid-template-columns: 1fr;
    }

    .front-note {
        padding: 16px;
    }

    .hero-art {
        width: 100%;
        max-width: 420px;
    }

    .hero h1,
    .admin-header h1 {
        font-size: clamp(2.25rem, 13vw, 3rem);
        line-height: 1;
    }

    .hero-subtitle {
        margin-top: 12px;
    }

    .panel {
        padding: 16px;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .emoji-picker {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .food-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .food-card {
        min-height: 126px;
        padding: 14px 8px;
    }

    .emoji {
        font-size: 2.5rem;
    }

    .food-row,
    .pick {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .inline-form {
        min-width: 0;
        flex-direction: column;
    }

    .inline-form button,
    .food-row button,
    .food-row select,
    .send-button,
    .big-button,
    .parent-link,
    .small-link {
        width: 100%;
    }

    table {
        min-width: 620px;
    }
}

@media (max-width: 440px) {
    .shell {
        width: min(100% - 14px, 1180px);
    }

    .front-note {
        grid-template-columns: 1fr;
    }

    .food-background span {
        opacity: 0.28;
    }

    .hero h1,
    .admin-header h1 {
        font-size: clamp(2rem, 12vw, 2.45rem);
    }

    .hero-subtitle {
        font-size: 1.05rem;
    }

    .food-grid {
        grid-template-columns: 1fr;
    }

    .meal-section {
        padding: 12px;
    }

    .emoji-picker {
        gap: 6px;
    }

    button,
    .big-button,
    .parent-link,
    .small-link {
        white-space: normal;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
    }

    .food-background span {
        transform: none !important;
    }
}

@keyframes backgroundDrift {
    from {
        transform: translate3d(-1%, -1%, 0) scale(1);
    }
    to {
        transform: translate3d(1%, 1%, 0) scale(1.03);
    }
}

@keyframes foodFloat {
    0%,
    100% {
        margin: -4px 0 0 -4px;
    }
    50% {
        margin: 10px 0 0 8px;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(22px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cardPop {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes heroBob {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

@keyframes buttonBounce {
    0%,
    100% {
        transform: translateY(-2px) scale(1);
    }
    50% {
        transform: translateY(-4px) scale(1.02);
    }
}
