/* Elementy — an alchemist's workshop at night.
   Deep ink sky, candle-gold light, one colour per classical element. */

:root {
    --ink: #0d1030;
    --ink-2: #161a45;
    --ink-3: #21265c;
    --ink-line: rgba(255, 236, 200, .12);
    --parchment: #fbeed3;
    --parchment-dim: rgba(251, 238, 211, .62);
    --gold: #ffc857;
    --gold-deep: #e79b1c;
    --fire: #ff6b3d;
    --water: #45b1ff;
    --earth: #7ccf7a;
    --air: #d7ecff;
    --danger: #ff7a8a;

    --radius: 22px;
    --radius-sm: 14px;
    --display: 'Baloo 2', system-ui, sans-serif;
    --body: 'Baloo 2', system-ui, sans-serif;
    --ease-pop: cubic-bezier(.34, 1.56, .64, 1);

    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

/* components set display; the hidden attribute must still win */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--body);
    font-size: 18px;
    line-height: 1.35;
    color: var(--parchment);
    background-color: var(--ink);
    /* a few painted stars and the glow of the cauldron at the bottom */
    background-image:
        radial-gradient(1.5px 1.5px at 12% 18%, rgba(255,255,255,.7), transparent 60%),
        radial-gradient(1px 1px at 78% 9%, rgba(255,255,255,.6), transparent 60%),
        radial-gradient(1.5px 1.5px at 64% 31%, rgba(255,255,255,.45), transparent 60%),
        radial-gradient(1px 1px at 32% 46%, rgba(255,255,255,.5), transparent 60%),
        radial-gradient(1.5px 1.5px at 90% 57%, rgba(255,255,255,.4), transparent 60%),
        radial-gradient(1px 1px at 6% 72%, rgba(255,255,255,.45), transparent 60%),
        radial-gradient(120% 60% at 50% 110%, rgba(231, 155, 28, .22), transparent 70%),
        radial-gradient(90% 50% at 50% -10%, rgba(69, 177, 255, .14), transparent 70%);
    background-attachment: fixed;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* ---------- shell ---------- */

.shell {
    max-width: 980px;
    margin: 0 auto;
    padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
}

.topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0 14px;
}

.brand {
    font-family: var(--display); font-weight: 800;
    font-size: 28px;
    letter-spacing: .5px;
    color: var(--gold);
    text-shadow: 0 2px 0 var(--gold-deep), 0 0 24px rgba(255, 200, 87, .35);
    margin-right: auto;
    white-space: nowrap;
}
.brand span { color: var(--parchment); text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.topbar .icon-btn { flex: none; }
/* on phones the team name does not fit next to the buttons */
@media (max-width: 520px) {
    .brand { white-space: normal; line-height: 1; }
    .brand span { display: block; font-size: 16px; margin-top: 2px; }
}

.icon-btn {
    display: inline-grid; place-items: center;
    min-width: 48px; height: 48px; padding: 0 12px;
    border: 1px solid var(--ink-line);
    border-radius: 16px;
    background: var(--ink-2);
    font-size: 22px;
    text-decoration: none;
    color: var(--parchment);
    cursor: pointer;
    transition: transform .15s var(--ease-pop), background .2s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn[aria-pressed="false"] { opacity: .55; }

/* ---------- tabs ---------- */

.tabs {
    display: grid; grid-template-columns: 1fr 1fr 1fr;
    gap: 6px; padding: 6px;
    border-radius: 20px;
    background: rgba(0,0,0,.25);
    border: 1px solid var(--ink-line);
    margin-bottom: 16px;
}
.tab {
    height: 50px; border: 0; border-radius: 15px;
    background: transparent;
    font-family: var(--display); font-weight: 800; font-size: 20px; letter-spacing: .3px;
    color: var(--parchment-dim);
    text-decoration: none;
    display: grid; place-items: center;
    cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--ink-3); color: var(--parchment); box-shadow: inset 0 -3px 0 var(--gold); }
.tab small { font-family: var(--body); font-size: 15px; opacity: .8; margin-left: 6px; }

/* ---------- gift banner ---------- */

.gift-banner {
    display: flex; align-items: center; gap: 14px;
    width: 100%;
    margin-bottom: 16px;
    padding: 14px 18px;
    border: 0; border-radius: var(--radius);
    background:
        repeating-linear-gradient(135deg, rgba(255,255,255,.08) 0 14px, transparent 14px 28px),
        linear-gradient(180deg, #ff8a5c, var(--fire));
    box-shadow: 0 6px 0 #b8401c, 0 14px 30px rgba(255, 107, 61, .35);
    color: #fff; text-align: left;
    cursor: pointer;
    animation: gift-bob 2.2s ease-in-out infinite;
}
.gift-banner[hidden] { display: none; }
.gift-banner__box { font-size: 46px; filter: drop-shadow(0 3px 0 rgba(0,0,0,.2)); animation: gift-wiggle 2.2s ease-in-out infinite; }
.gift-banner__text { font-family: var(--display); font-weight: 800; font-size: 24px; line-height: 1.1; }
.gift-banner__text small { display: block; font-family: var(--body); font-size: 16px; font-weight: 600; opacity: .92; }
@keyframes gift-bob { 50% { transform: translateY(-4px); } }
@keyframes gift-wiggle { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-12deg); } 86% { transform: rotate(10deg); } 94% { transform: rotate(-5deg); } }

/* ---------- workbench ---------- */

.bench {
    position: relative;
    padding: 20px 16px 22px;
    border-radius: 28px;
    background:
        radial-gradient(80% 90% at 50% 100%, rgba(255, 200, 87, .16), transparent 70%),
        linear-gradient(180deg, var(--ink-2), #12153a);
    border: 1px solid var(--ink-line);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 20px 40px rgba(0,0,0,.35);
    margin-bottom: 18px;
}

.bench__row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    max-width: 520px;
    margin: 0 auto;
}

.slot {
    aspect-ratio: 1;
    display: grid; place-items: center; align-content: center; gap: 2px;
    border-radius: 50%;
    border: 3px dashed rgba(251, 238, 211, .28);
    background: rgba(0,0,0,.22);
    cursor: pointer;
    padding: 8px;
    transition: transform .25s var(--ease-pop), border-color .2s, background .2s;
}
.slot__emoji { font-size: clamp(44px, 12vw, 72px); line-height: 1; }
.slot__name { font-weight: 700; font-size: 16px; text-align: center; line-height: 1.1; }
.slot__hint { color: var(--parchment-dim); font-size: 15px; text-align: center; }
.slot.is-filled {
    border-style: solid;
    border-color: var(--gold);
    background: radial-gradient(circle at 50% 35%, rgba(255, 200, 87, .25), rgba(0,0,0,.25) 70%);
    animation: slot-in .35s var(--ease-pop);
}
@keyframes slot-in { from { transform: scale(.6); } }

.bench__plus {
    font-family: var(--display); font-weight: 800; font-size: 40px; color: var(--gold);
    text-shadow: 0 0 18px rgba(255, 200, 87, .6);
}

.bench.is-shaking .slot { animation: shake .5s; }
@keyframes shake {
    20% { transform: translateX(-10px) rotate(-4deg); }
    40% { transform: translateX(9px) rotate(3deg); }
    60% { transform: translateX(-6px) rotate(-2deg); }
    80% { transform: translateX(4px); }
}
.bench.is-mixing .slot:first-child { animation: mix-left .5s ease-in forwards; }
.bench.is-mixing .slot:last-child { animation: mix-right .5s ease-in forwards; }
@keyframes mix-left { to { transform: translateX(60%) scale(.4); opacity: 0; } }
@keyframes mix-right { to { transform: translateX(-60%) scale(.4); opacity: 0; } }

.combine {
    display: block;
    width: min(100%, 360px);
    height: 64px;
    margin: 18px auto 0;
    border: 0; border-radius: 20px;
    background: linear-gradient(180deg, #ffd77e, var(--gold));
    color: #3a2400;
    font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: .5px;
    box-shadow: 0 6px 0 var(--gold-deep), 0 12px 26px rgba(255, 200, 87, .3);
    cursor: pointer;
    transition: transform .12s, box-shadow .12s, opacity .2s, filter .2s;
}
.combine:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--gold-deep); }
.combine:disabled { filter: grayscale(.8); opacity: .45; cursor: default; }

.bench__message {
    min-height: 28px; margin: 12px 0 0;
    text-align: center; font-weight: 600; color: var(--parchment-dim);
}
.bench__message.is-error { color: var(--danger); }

/* ---------- element tiles (inventory and book) ---------- */

.toolbar {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    margin-bottom: 12px;
}
.toolbar h2 { font-family: var(--display); font-weight: 800; font-size: 24px; margin: 0 auto 0 0; }

.search {
    flex: 1 1 180px; max-width: 280px;
    height: 46px; padding: 0 16px 0 42px;
    border-radius: 14px;
    border: 1px solid var(--ink-line);
    background: var(--ink-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%23fbeed3' stroke-opacity='.6' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='8.5' cy='8.5' r='6'/%3E%3Cpath d='m13 13 5 5'/%3E%3C/svg%3E") no-repeat 14px 50%;
    color: var(--parchment); font: inherit; font-size: 17px;
}
.search::placeholder { color: var(--parchment-dim); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: none; height: 40px; padding: 0 14px;
    border-radius: 999px; border: 1px solid var(--ink-line);
    background: var(--ink-2); color: var(--parchment-dim);
    font-weight: 700; font-size: 15px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--parchment); color: var(--ink); border-color: var(--parchment); }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
}

.tile {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-height: 108px; padding: 10px 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--ink-line);
    background: linear-gradient(180deg, var(--ink-3), var(--ink-2));
    box-shadow: 0 4px 0 rgba(0,0,0,.35);
    cursor: pointer;
    text-align: center;
    transition: transform .15s var(--ease-pop);
    content-visibility: auto;
    contain-intrinsic-size: 96px 108px;
}
.tile:active { transform: scale(.93); }
.tile__emoji { font-size: 40px; line-height: 1; white-space: nowrap; }
.tile__emoji--pair { font-size: 28px !important; letter-spacing: -2px; }
.tile__name { font-weight: 700; font-size: 15px; line-height: 1.1; overflow-wrap: anywhere; }
.tile__count {
    position: absolute; top: -7px; right: -5px;
    min-width: 28px; height: 28px; padding: 0 7px;
    display: grid; place-items: center;
    border-radius: 999px;
    background: var(--gold); color: #3a2400;
    font-weight: 800; font-size: 15px;
    box-shadow: 0 2px 0 var(--gold-deep);
}
.tile.is-selected { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold), 0 4px 0 rgba(0,0,0,.35); }
.tile.is-empty { opacity: .38; }
.tile--base { background: linear-gradient(180deg, #2a2f6e, var(--ink-2)); }
.tile--water .tile__emoji { filter: drop-shadow(0 0 10px var(--water)); }
.tile--fire .tile__emoji { filter: drop-shadow(0 0 10px var(--fire)); }
.tile--earth .tile__emoji { filter: drop-shadow(0 0 10px var(--earth)); }
.tile--air .tile__emoji { filter: drop-shadow(0 0 10px var(--air)); }

.tile--unknown {
    cursor: default;
    background: repeating-linear-gradient(135deg, rgba(255,255,255,.025) 0 8px, transparent 8px 16px), rgba(0,0,0,.25);
    box-shadow: none;
    border-style: dashed;
}
.tile--unknown .tile__emoji { font-family: var(--display); font-weight: 800; font-size: 34px; color: rgba(251,238,211,.18); }
.tile--unknown:active { transform: none; }

.empty {
    padding: 28px 16px; text-align: center; color: var(--parchment-dim);
    border: 2px dashed var(--ink-line); border-radius: var(--radius);
}
.empty strong { display: block; font-family: var(--display); font-weight: 800; font-size: 22px; color: var(--parchment); margin-bottom: 4px; }

/* progress bar in the book */
.progress { margin: 0 0 16px; }
.progress__bar { height: 14px; border-radius: 999px; background: rgba(0,0,0,.3); overflow: hidden; border: 1px solid var(--ink-line); }
.progress__fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--water), var(--earth), var(--gold), var(--fire)); transition: width .8s ease; }
.progress__label { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 6px; }
.progress__label span:last-child { color: var(--gold); }

/* ---------- overlay: discoveries, gift reveal, hints ---------- */

.overlay {
    position: fixed; inset: 0; z-index: 20;
    display: grid; place-items: center;
    padding: 16px;
    background: rgba(6, 8, 26, .78);
    backdrop-filter: blur(4px);
    animation: fade-in .2s ease;
}
.overlay[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } }

.card {
    position: relative;
    width: min(100%, 440px);
    max-height: calc(100dvh - 32px);
    overflow: auto;
    padding: 28px 22px 22px;
    border-radius: 30px;
    background: linear-gradient(180deg, #262b6a, var(--ink-2));
    border: 1px solid rgba(255, 236, 200, .2);
    box-shadow: 0 30px 60px rgba(0,0,0,.5);
    text-align: center;
    animation: card-in .45s var(--ease-pop);
}
@keyframes card-in { from { transform: scale(.7) translateY(30px); opacity: 0; } }

.card__kicker {
    display: inline-block;
    padding: 4px 14px; border-radius: 999px;
    background: var(--gold); color: #3a2400;
    font-family: var(--display); font-weight: 800; font-size: 18px; letter-spacing: .4px;
    margin-bottom: 10px;
}
.card__kicker--quiet { background: var(--ink-3); color: var(--parchment); }
.card__title { font-family: var(--display); font-weight: 800; font-size: 34px; line-height: 1.05; margin: 8px 0 4px; }
.card__text { color: var(--parchment-dim); margin: 4px 0 0; }

.card__items { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin: 10px 0 6px; }
.card__item { display: grid; justify-items: center; gap: 2px; min-width: 90px; }
.card__item-emoji {
    font-size: 84px; line-height: 1.05;
    animation: bloom .6s var(--ease-pop) both;
}
.card__item-name { font-family: var(--display); font-weight: 800; font-size: 24px; }
.card__item.is-new .card__item-emoji { filter: drop-shadow(0 0 24px rgba(255, 200, 87, .8)); }
@keyframes bloom { from { transform: scale(0) rotate(-30deg); } }

.card__rays {
    position: absolute; inset: -40px; z-index: -1; pointer-events: none;
    background: repeating-conic-gradient(from 0deg, rgba(255, 200, 87, .16) 0 10deg, transparent 10deg 24deg);
    mask-image: radial-gradient(circle, #000 20%, transparent 65%);
    animation: spin 18s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }

.card__button {
    width: 100%; height: 58px; margin-top: 18px;
    border: 0; border-radius: 18px;
    background: linear-gradient(180deg, #ffd77e, var(--gold));
    color: #3a2400;
    font-family: var(--display); font-weight: 800; font-size: 24px;
    box-shadow: 0 5px 0 var(--gold-deep);
    cursor: pointer;
}
.card__button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--gold-deep); }

/* gift reveal: pieces pop out one after another */
.reveal { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 10px; margin: 14px 0 4px; }
.reveal__piece { display: grid; justify-items: center; font-size: 46px; animation: bloom .5s var(--ease-pop) both; }
.reveal__piece small { font-size: 14px; font-weight: 700; color: var(--parchment-dim); }
.gift-big { font-size: 110px; line-height: 1; margin: 6px 0; cursor: pointer; animation: gift-wiggle 1.4s ease-in-out infinite; display: inline-block; background: none; border: 0; }
.gift-big.is-bursting { animation: burst .45s ease-in forwards; }
@keyframes burst { 60% { transform: scale(1.3) rotate(8deg); } to { transform: scale(0); opacity: 0; } }

/* confetti dots for discoveries */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confetti i {
    position: absolute; top: -12px; width: 10px; height: 14px; border-radius: 3px;
    animation: fall linear forwards;
}
@keyframes fall { to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--r)); } }

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

/* ---------- login & parent ---------- */

.center-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }

.panel {
    width: min(100%, 420px);
    padding: 28px 22px;
    border-radius: 28px;
    background: linear-gradient(180deg, var(--ink-2), #12153a);
    border: 1px solid var(--ink-line);
    box-shadow: 0 24px 50px rgba(0,0,0,.4);
}
.panel--wide { width: min(100%, 620px); }
.panel h1 { font-family: var(--display); font-weight: 800; font-size: 34px; margin: 0 0 6px; text-align: center; color: var(--gold); }
.panel p.lead { text-align: center; color: var(--parchment-dim); margin: 0 0 20px; }

.elements-row { display: flex; justify-content: center; gap: 12px; font-size: 34px; margin-bottom: 8px; }
.elements-row span { animation: gift-bob 2.4s ease-in-out infinite; }
.elements-row span:nth-child(2) { animation-delay: .3s; }
.elements-row span:nth-child(3) { animation-delay: .6s; }
.elements-row span:nth-child(4) { animation-delay: .9s; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 700; font-size: 16px; }
.field input {
    height: 54px; padding: 0 16px;
    border-radius: 14px; border: 1px solid var(--ink-line);
    background: rgba(0,0,0,.25); color: var(--parchment);
    font: inherit; font-size: 19px;
}
.field input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 200, 87, .25); }

.alert { padding: 12px 14px; border-radius: 14px; background: rgba(255, 122, 138, .14); border: 1px solid rgba(255, 122, 138, .45); color: #ffd0d6; margin-bottom: 14px; text-align: center; font-weight: 600; }

.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 6px 0 20px; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--parchment-dim); transition: background .15s, transform .15s var(--ease-pop); }
.pin-dots i.is-on { background: var(--gold); border-color: var(--gold); transform: scale(1.15); }
.pin-dots.is-wrong { animation: shake .45s; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 300px; margin: 0 auto; }
.key {
    height: 66px; border-radius: 18px; border: 1px solid var(--ink-line);
    background: var(--ink-3); font-family: var(--display); font-weight: 800; font-size: 28px;
    box-shadow: 0 4px 0 rgba(0,0,0,.35); cursor: pointer;
}
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.key--quiet { background: transparent; box-shadow: none; font-family: var(--body); font-size: 17px; font-weight: 700; color: var(--parchment-dim); }

.give {
    position: relative;
    display: grid; place-items: center; gap: 4px;
    width: 100%; aspect-ratio: 16 / 9; max-height: 280px;
    border: 0; border-radius: 30px;
    background:
        repeating-linear-gradient(135deg, rgba(255,255,255,.08) 0 18px, transparent 18px 36px),
        linear-gradient(180deg, #ff8a5c, var(--fire));
    box-shadow: 0 8px 0 #b8401c, 0 20px 40px rgba(255, 107, 61, .3);
    color: #fff; cursor: pointer;
    transition: transform .1s;
}
.give:active { transform: translateY(6px); box-shadow: 0 2px 0 #b8401c; }
.give__emoji { font-size: 64px; line-height: 1; }
.give__label { font-family: var(--display); font-weight: 800; font-size: 30px; }
.give.is-bump .give__emoji { animation: bloom .35s var(--ease-pop); }

.gift-count { text-align: center; margin: 18px 0 8px; font-size: 20px; }
.gift-count strong { font-family: var(--display); font-weight: 800; font-size: 44px; color: var(--gold); display: block; line-height: 1; }

.row-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.btn {
    height: 50px; padding: 0 18px; border-radius: 16px;
    border: 1px solid var(--ink-line); background: var(--ink-3);
    font-weight: 700; font-size: 17px; cursor: pointer; text-decoration: none;
    display: inline-grid; place-items: center; color: var(--parchment);
}
.btn:disabled { opacity: .4; cursor: default; }
.btn--primary { background: linear-gradient(180deg, #ffd77e, var(--gold)); color: #3a2400; border: 0; box-shadow: 0 4px 0 var(--gold-deep); font-family: var(--display); font-weight: 800; font-size: 21px; width: 100%; height: 58px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 24px 0 10px; }
.stat { padding: 14px; border-radius: 18px; background: rgba(0,0,0,.22); border: 1px solid var(--ink-line); }
.stat strong { display: block; font-family: var(--display); font-weight: 800; font-size: 30px; color: var(--gold); }
.stat span { color: var(--parchment-dim); font-size: 15px; }

.history { list-style: none; padding: 0; margin: 8px 0 0; }
.history li { display: flex; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--ink-line); font-size: 16px; }
.history li span:last-child { color: var(--parchment-dim); }
.section-title { font-family: var(--display); font-weight: 800; font-size: 22px; margin: 22px 0 4px; }

@media (min-width: 700px) {
    .grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; }
    .tile { min-height: 122px; }
    .tile__emoji { font-size: 46px; }
}

/* ---------- tree: how an element was made ---------- */

.tree-box {
    max-height: min(52vh, 460px);
    overflow: auto;
    margin: 14px -6px 0;
    padding: 12px 10px;
    border-radius: 18px;
    background: rgba(0, 0, 0, .22);
    border: 1px solid var(--ink-line);
    text-align: left;
    overscroll-behavior: contain;
}
.tree-box__title { font-family: var(--display); font-weight: 800; font-size: 18px; margin: 0 0 6px 4px; color: var(--gold); }

.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree__kids {
    position: relative;
    margin: 4px 0 6px 20px !important;
    padding-left: 14px !important;
    border-left: 2px dashed rgba(255, 200, 87, .35);
}
.tree__kids > li { position: relative; }
.tree__kids > li:not(.tree__plus)::before {
    content: ''; position: absolute; left: -14px; top: 23px; width: 12px;
    border-top: 2px dashed rgba(255, 200, 87, .35);
}
.tree__plus { font-family: var(--display); font-weight: 800; color: var(--gold); font-size: 18px; line-height: 1; padding: 0 0 0 16px; }

.tree details > summary { list-style: none; cursor: pointer; }
.tree details > summary::-webkit-details-marker { display: none; }
.tree details > summary .tree__node::after {
    content: '▾'; margin-left: 2px; color: var(--parchment-dim); font-size: 14px; transition: transform .2s;
}
.tree details:not([open]) > summary .tree__node::after { transform: rotate(-90deg); display: inline-block; }

.tree__node {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 46px; margin: 2px 0; padding: 4px 12px 4px 6px;
    border-radius: 14px;
    background: linear-gradient(180deg, var(--ink-3), var(--ink-2));
    border: 1px solid var(--ink-line);
    box-shadow: 0 3px 0 rgba(0,0,0,.3);
}
.tree__node[data-action] { cursor: pointer; }
.tree > li > details > summary .tree__node { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 200, 87, .35), 0 3px 0 rgba(0,0,0,.3); }
.tree__emoji { font-size: 28px; line-height: 1; min-width: 36px; text-align: center; white-space: nowrap; }
.tree__name { font-weight: 800; font-size: 17px; }
.tree__badge {
    font-size: 13px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
    background: rgba(255,255,255,.08); color: var(--parchment-dim);
}
.tree__badge--start { background: rgba(69, 177, 255, .2); color: #bfe3ff; }
.tree__badge--again { background: transparent; }

.card--wide { width: min(100%, 560px); }
.card__link {
    margin-top: 12px; height: 48px; padding: 0 18px;
    border-radius: 14px; border: 1px solid var(--ink-line);
    background: var(--ink-3); color: var(--parchment);
    font-weight: 800; font-size: 17px; cursor: pointer;
}

/* parent: pick a discovery, see its tree and alternatives */
.picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; max-height: 240px; overflow: auto; padding: 2px; }
.pick {
    display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 12px 0 8px;
    border-radius: 999px; border: 1px solid var(--ink-line); background: var(--ink-3);
    font-weight: 700; font-size: 15px; cursor: pointer;
}
.pick[aria-pressed="true"] { background: var(--parchment); color: var(--ink); }
.pick span { font-size: 20px; }
.ways { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.ways li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ways .is-ours { font-size: 13px; font-weight: 700; color: var(--gold); }

/* ---------- tree screen: the whole catalog by generation ---------- */

.tree-summary { margin: 0 0 14px; color: var(--parchment-dim); }
.tree-summary strong { color: var(--gold); }

.bands-wrap { position: relative; }
.lines { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: visible; }
.line { fill: none; stroke-width: 3; stroke-linecap: round; }
.line--from { stroke: var(--gold); filter: drop-shadow(0 0 4px rgba(255, 200, 87, .7)); }
.line--to { stroke: var(--water); stroke-dasharray: 2 7; filter: drop-shadow(0 0 4px rgba(69, 177, 255, .7)); }

.bands { display: grid; gap: 12px; padding-bottom: 12px; }
.band {
    padding: 10px 10px 12px;
    border-radius: 20px;
    background: linear-gradient(180deg, var(--ink-2), rgba(22, 26, 69, .6));
    border: 1px solid var(--ink-line);
}
.band--dark { background: rgba(0, 0, 0, .18); border-style: dashed; }
.band__head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 4px 8px; }
.band__title { font-family: var(--display); font-weight: 800; font-size: 18px; }
.band--dark .band__title { color: var(--parchment-dim); }
.band__count { font-weight: 700; font-size: 14px; color: var(--parchment-dim); }
.band__nodes { display: flex; flex-wrap: wrap; gap: 6px; }

.tnode {
    display: grid; place-items: center;
    width: 46px; height: 46px;
    border-radius: 12px;
    font-size: 26px; line-height: 1;
    border: 1px solid var(--ink-line);
    background: linear-gradient(180deg, var(--ink-3), var(--ink-2));
    box-shadow: 0 3px 0 rgba(0,0,0,.35);
    cursor: pointer; padding: 0;
    white-space: nowrap; overflow: hidden;
    transition: transform .15s var(--ease-pop), box-shadow .2s;
}
.tnode--base { background: linear-gradient(180deg, #2a2f6e, var(--ink-2)); }
.tnode--pair { font-size: 17px; }
.tnode--hidden {
    cursor: default;
    font-family: var(--display); font-weight: 800; font-size: 18px; color: rgba(251, 238, 211, .16);
    background: rgba(0,0,0,.22); border-style: dashed; box-shadow: none;
}
.tnode.is-selected { transform: scale(1.18); position: relative; z-index: 3; box-shadow: 0 0 0 3px var(--parchment), 0 0 22px rgba(255, 236, 200, .6); }
.tnode.is-from { position: relative; z-index: 3; box-shadow: 0 0 0 3px var(--gold); }
.tnode.is-to { position: relative; z-index: 3; box-shadow: 0 0 0 3px var(--water); }

.tinfo {
    position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 5;
    margin-top: 6px; padding: 14px 16px;
    border-radius: 22px;
    background: linear-gradient(180deg, #262b6a, var(--ink-2));
    border: 1px solid rgba(255, 236, 200, .22);
    box-shadow: 0 -10px 40px rgba(0,0,0,.45);
    animation: card-in .3s var(--ease-pop);
    max-height: 46vh; overflow: auto;
}
.tinfo[hidden] { display: none; }
.tinfo__head { display: flex; align-items: center; gap: 12px; }
.tinfo__emoji { font-size: 44px; line-height: 1; white-space: nowrap; }
.tinfo__name { display: block; font-family: var(--display); font-weight: 800; font-size: 24px; line-height: 1.1; }
.tinfo__sub { color: var(--parchment-dim); font-size: 15px; }
.tinfo__close { margin-left: auto; flex: none; }
.tinfo__label { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; font-weight: 800; font-size: 15px; color: var(--parchment-dim); }
.tinfo__row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tinfo__row .tree__node { cursor: pointer; }
.tinfo__hint { margin: 12px 0 0; font-weight: 600; }
.tinfo__hint strong { color: var(--gold); }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot--from { background: var(--gold); }
.dot--to { background: var(--water); }

/* unlockable base elements, between the elements and the first step */
.band--bases { background: linear-gradient(180deg, rgba(255, 200, 87, .1), rgba(22, 26, 69, .6)); border-color: rgba(255, 200, 87, .25); }
.bases { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 14px; }
.base { display: flex; gap: 10px; align-items: center; min-width: 0; }
.base .tnode { flex: none; }
.tnode--locked { cursor: default; filter: grayscale(1) brightness(.6); opacity: .55; border-style: dashed; box-shadow: none; }
.base__text { display: grid; gap: 2px; min-width: 0; font-size: 14px; line-height: 1.2; }
.base__text strong { font-size: 16px; }
.base__when { color: var(--parchment-dim); }
.base__done { color: var(--earth); font-weight: 700; }
.base__bar { display: block; height: 7px; border-radius: 999px; background: rgba(0,0,0,.35); overflow: hidden; }
.base__bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); }
.base__count { font-size: 13px; font-weight: 700; color: var(--gold); }

/* ---------- parent: password and PIN ---------- */

.settings__card {
    margin-top: 18px; padding: 16px 16px 18px;
    border-radius: 22px; background: rgba(0,0,0,.2); border: 1px solid var(--ink-line);
}
.settings__card .section-title { margin-top: 0; }
.settings__hint { margin: 0 0 14px; color: var(--parchment-dim); font-size: 15px; }
.settings__form .btn--primary { margin-top: 4px; }
.field.has-error input { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(255, 122, 138, .2); }
.field__error { margin: 0; color: #ffc2ca; font-size: 15px; font-weight: 600; }
.notice {
    margin: 0 0 6px; padding: 12px 14px; border-radius: 14px; text-align: center; font-weight: 700;
    background: rgba(124, 207, 122, .14); border: 1px solid rgba(124, 207, 122, .45); color: #d6f5d5;
}

/* ---------- admin ---------- */

.muted { color: var(--parchment-dim); font-weight: 600; font-size: .8em; }
.btn--accent { background: linear-gradient(180deg, #ffd77e, var(--gold)); color: #3a2400; border: 0; box-shadow: 0 4px 0 var(--gold-deep); }
.btn--danger { background: linear-gradient(180deg, #ff95a2, var(--danger)); color: #3a0010; border: 0; box-shadow: 0 4px 0 #b8394b; width: 100%; height: 54px; font-family: var(--display); font-weight: 800; font-size: 19px; }
.field__help { margin: 0; color: var(--parchment-dim); font-size: 14px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.admin-panel { margin: 0 auto; }
.settings__card--danger { border-color: rgba(255, 122, 138, .35); background: rgba(255, 122, 138, .06); }
.subhead { font-family: var(--display); font-weight: 800; font-size: 16px; margin: 18px 0 8px; color: var(--parchment-dim); }

.accounts { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.account-card {
    display: grid; gap: 10px; padding: 16px;
    border-radius: 22px; text-decoration: none; color: inherit;
    background: linear-gradient(180deg, var(--ink-2), #12153a);
    border: 1px solid var(--ink-line);
    box-shadow: 0 6px 0 rgba(0,0,0,.25);
    transition: transform .15s var(--ease-pop), border-color .2s;
}
.account-card:hover { border-color: rgba(255, 200, 87, .45); }
.account-card:active { transform: scale(.98); }
.account-card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.account-card__head strong { font-family: var(--display); font-weight: 800; font-size: 20px; }
.pill { justify-self: start; padding: 4px 10px; border-radius: 999px; background: rgba(255, 107, 61, .18); color: #ffc7b3; font-weight: 700; font-size: 14px; }

.aprog__bar { height: 12px; border-radius: 999px; background: rgba(0,0,0,.35); overflow: hidden; border: 1px solid var(--ink-line); }
.aprog__bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--water), var(--earth), var(--gold), var(--fire)); }
.aprog__label { margin-top: 6px; font-size: 15px; display: flex; gap: 6px; align-items: baseline; }
.aprog__label strong { color: var(--gold); font-size: 18px; }
.aprog__label span { margin-left: auto; color: var(--parchment-dim); font-weight: 700; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 0; }
.facts--wide { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-top: 14px; }
.facts div { min-width: 0; }
.facts dt { font-size: 13px; color: var(--parchment-dim); font-weight: 700; }
.facts dd { margin: 0; font-weight: 800; }

.tierbars { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.tierbars li { display: grid; grid-template-columns: 70px 1fr 56px; align-items: center; gap: 10px; font-size: 14px; }
.tierbars__name { font-weight: 700; color: var(--parchment-dim); }
.tierbars__bar { height: 9px; border-radius: 999px; background: rgba(0,0,0,.35); overflow: hidden; }
.tierbars__bar i { display: block; height: 100%; background: var(--gold); border-radius: inherit; }
.tierbars__count { text-align: right; font-weight: 700; }

.recent { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; }
.recent li { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.recent li .muted { margin-left: auto; font-size: 13px; }
.recent__emoji { font-size: 22px; min-width: 32px; text-align: center; white-space: nowrap; }

/* ---------- trophy shelf: final elements, which combine with nothing ---------- */

.shelf {
    margin-top: 22px;
    padding: 6px 10px 12px;
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255, 200, 87, .09), rgba(255, 200, 87, .02)),
        rgba(0, 0, 0, .14);
    border: 1px solid rgba(255, 200, 87, .22);
    /* the "plank" the trophies stand on */
    box-shadow: inset 0 -6px 0 rgba(231, 155, 28, .18);
}
.shelf[hidden] { display: none; }
.shelf__head {
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 10px;
    width: 100%; padding: 8px 4px 10px;
    border: 0; background: none; text-align: left; cursor: pointer;
}
.shelf__title { font-family: var(--display); font-weight: 800; font-size: 22px; color: var(--gold); }
.shelf__count { color: var(--parchment-dim); font-size: 18px; }
.shelf__sub { grid-column: 1; font-size: 14px; color: var(--parchment-dim); font-weight: 600; }
.shelf__chevron { grid-row: 1 / span 2; grid-column: 2; font-size: 20px; color: var(--parchment-dim); transition: transform .2s; }
.shelf.is-closed .shelf__chevron { transform: rotate(-90deg); }
.shelf.is-closed { padding-bottom: 4px; box-shadow: none; }

.tile--trophy {
    background: linear-gradient(180deg, rgba(255, 200, 87, .1), rgba(22, 26, 69, .9));
    border-color: rgba(255, 200, 87, .35);
    box-shadow: 0 3px 0 rgba(0,0,0,.3);
}
.tile--trophy .tile__emoji { filter: saturate(.85); }
.tile--trophy .tile__name { color: var(--parchment-dim); }
.tile--trophy .tile__count { background: rgba(255, 200, 87, .25); color: var(--gold); box-shadow: none; }

.tile__badge {
    position: absolute; top: 5px; left: 6px;
    font-size: 15px; line-height: 1;
    filter: drop-shadow(0 1px 0 rgba(0,0,0,.4));
}

.tnode--final { position: relative; border-color: rgba(255, 200, 87, .55); }
.tnode--final::after {
    content: '🏆'; position: absolute; right: 2px; bottom: 2px;
    font-size: 11px; line-height: 1;
}
