/* Geode Quest — kid-friendly, touch-first, transform/opacity animations only. */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Segoe UI", sans-serif;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    background: #1b1740;
}

button {
    font-family: inherit;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

.screen {
    position: fixed;
    inset: 0;
}

/* ============ SETUP / HOME ============ */

/* The welcome screen. Shown once, on first run, and again only when a player
   deliberately asks to change their look. */
#welcome-screen {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(180deg, #7ec8ff 0%, #b3e36d 70%, #6fb83f 100%);
    padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

#welcome-screen .setup-card { width: 100%; }
/* Do not let the column stretch it into a slab on a tall screen. */
#welcome-start { width: 100%; max-width: 420px; flex: 0 0 auto; }

/* What the public board will show. Said before they play rather than after, so
   a typed name is never a surprise on the high-score list. */
.board-preview.refused {
    background: #ffe3e3;
    color: #c92a2a;
}

.board-preview {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 12px;
    background: #eef2f6;
    color: #475569;
    font-size: 15px;
    font-weight: bold;
    text-align: center;
}

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

.me-chip {
    min-height: 48px;
    padding: 8px 18px;
    border-radius: 999px;
    border: 3px solid #fff;
    background: rgba(255, 255, 255, 0.92);
    color: #2b5d12;
    font-size: 20px;
    font-weight: 900;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
}

.me-chip:active { transform: translateY(3px); box-shadow: none; }

#me-big {
    font-size: 34px;
    font-weight: 900;
    text-align: center;
    color: #334155;
    padding: 10px 0;
}

#me-change { width: 100%; margin-top: 12px; }

#setup-screen {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(180deg, #7ec8ff 0%, #b3e36d 70%, #6fb83f 100%);
    padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.game-title {
    margin: 8px 0 0;
    font-size: clamp(36px, 8vw, 56px);
    color: #fff;
    text-shadow: 0 3px 0 #2f6f9f, 0 6px 14px rgba(0, 0, 0, 0.25);
    animation: title-bounce 2.4s ease-in-out infinite;
}

@keyframes title-bounce {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    50% { transform: translateY(-6px) rotate(1deg); }
}

.tagline {
    margin: 0;
    font-size: 17px;
    font-weight: bold;
    color: #2b5d12;
}

/* The pouch, on the first screen, at a size a child spots from across the
   room. Tapping it opens the shop, which is where sparkles go. */
.wallet-pill {
    min-height: 48px;
    margin: 10px 0 2px;
    padding: 8px 22px;
    border-radius: 999px;
    border: 3px solid #fff;
    background: linear-gradient(135deg, #74c0fc, #4dabf7);
    color: #fff;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 0 #1c7ed6, 0 6px 14px rgba(0, 0, 0, 0.18);
}

.wallet-pill:active { transform: translateY(3px); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18); }

.setup-card {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 22px;
    box-shadow: 0 8px 22px rgba(20, 60, 20, 0.25);
    padding: 14px 16px 16px;
    width: min(640px, 100%);
}

.setup-card h2 {
    margin: 0 0 10px;
    font-size: 19px;
    color: #38506b;
}

.picker-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.pick {
    background: #f1f5f9;
    border: 3px solid transparent;
    border-radius: 16px;
    min-height: 48px;
    font-size: 17px;
    font-weight: bold;
    color: #334155;
    padding: 6px 14px;
    transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.pick:active { transform: scale(0.92); }

.pick.selected {
    border-color: #339af0;
    background: #d0ebff;
    transform: scale(1.05);
}

.pick.avatar {
    width: 56px;
    height: 56px;
    padding: 0;
    font-size: 30px;
    border-radius: 50%;
}

.picker-grid.names { margin-top: 10px; }

#custom-name {
    display: block;
    width: 100%;
    margin-top: 10px;
    min-height: 48px;
    border: 3px solid #e2e8f0;
    border-radius: 16px;
    background: #f8fafc;
    padding: 6px 16px;
    font-family: inherit;
    font-size: 17px;
    font-weight: bold;
    color: #334155;
    text-align: center;
    -webkit-user-select: text;
    user-select: text;
}

#custom-name:focus {
    outline: none;
    border-color: #339af0;
    background: #fff;
}

.name-hint {
    display: block;
    margin-top: 8px;
    color: #94a3b8;
    font-size: 12px;
    line-height: 1.35;
    text-align: center;
}

.pick.world {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 104px;
    padding: 8px 10px;
    font-size: 14px;
}

.pick.world .world-ico { font-size: 30px; }

.pick.world small {
    font-size: 11px;
    color: #94a3b8;
    font-weight: normal;
}

.pick.world.locked {
    opacity: 0.6;
    cursor: default;
}

/* The world, as one row. A phone screen is about 660px tall and the old
   four-row world grid ate 390 of them, which put both Play buttons under the
   fold. This costs 64. */
.world-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(640px, 100%);
    min-height: 64px;
    padding: 8px 16px;
    border-radius: 20px;
    border: 3px solid #fff;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 6px 16px rgba(20, 60, 20, 0.25);
    text-align: left;
}

.world-strip:active { transform: scale(0.98); }

.world-strip .ws-ico { font-size: 32px; line-height: 1; }

.world-strip .ws-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.world-strip .ws-text small {
    font-size: 12px;
    font-weight: bold;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.world-strip .ws-text b {
    font-size: 20px;
    font-weight: 900;
    color: #38506b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.world-strip .ws-go {
    font-size: 15px;
    font-weight: bold;
    color: #339af0;
    white-space: nowrap;
}

.setup-actions {
    display: flex;
    gap: 12px;
    width: min(640px, 100%);
}

.cta {
    flex: 1;
    min-height: 66px;
    border-radius: 20px;
    font-size: clamp(18px, 4.5vw, 23px);
    font-weight: 900;
    color: #fff;
    background: linear-gradient(135deg, #ff8a3c, #ff5d5d);
    box-shadow: 0 6px 0 #c93d3d, 0 10px 18px rgba(0, 0, 0, 0.25);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    text-shadow: 0 2px 3px rgba(0, 0, 0, 0.25);
}

.cta.free {
    background: linear-gradient(135deg, #38d9a9, #4dabf7);
    box-shadow: 0 6px 0 #2b7fb8, 0 10px 18px rgba(0, 0, 0, 0.25);
}

.cta:active {
    transform: translateY(4px) scale(0.98);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

.setup-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.chip-btn {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 999px;
    min-height: 48px;
    padding: 8px 20px;
    font-size: 16px;
    font-weight: bold;
    color: #38506b;
    box-shadow: 0 4px 10px rgba(20, 60, 20, 0.25);
}

.chip-btn:active { transform: scale(0.95); }

.scores-card { margin-bottom: 12px; }

.install-steps {
    margin: 0;
    padding-left: 22px;
    color: #334155;
    font-size: 16px;
    line-height: 1.6;
}

.install-steps li { margin-bottom: 6px; }

.install-note {
    margin: 12px 0 0;
    color: #64748b;
    font-size: 14px;
    line-height: 1.45;
}

.board-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    color: #334155;
}

.board-row.first {
    background: linear-gradient(90deg, #fff3bf, #ffec99);
    font-size: 18px;
}

.board-rank { width: 30px; text-align: center; }
.board-name { flex: 1; text-align: left; }
.board-offline { color: #64748b; font-size: 15px; text-align: center; }

/* ============ GAME SCREEN ============ */

#game-screen { background: #1b1740; }

#play-area {
    position: absolute;
    inset: 0;
    overflow: hidden;
    touch-action: none;
}

/* World backdrops */
.wd-meadow { background: linear-gradient(180deg, #7ec8ff 0%, #b3e36d 60%, #6fb83f 100%); }
.wd-cave { background: linear-gradient(180deg, #3b2f6b 0%, #221b47 55%, #120e2b 100%); }
.wd-volcano { background: linear-gradient(180deg, #33100a 0%, #8a2a14 60%, #d9480f 100%); }
.wd-ice { background: linear-gradient(180deg, #d6f1ff 0%, #9bd6f2 60%, #e9f9ff 100%); }
.wd-space { background: linear-gradient(180deg, #05051f 0%, #1b1740 70%, #2c2456 100%); }
.wd-jungle { background: linear-gradient(180deg, #1f4d2e 0%, #3f7d3a 55%, #7bb356 100%); }
.wd-reef { background: linear-gradient(180deg, #0b3d5c 0%, #17698f 55%, #4aa3c4 100%); }
.wd-bones { background: linear-gradient(180deg, #ffd8a8 0%, #f0b27a 55%, #c98f5a 100%); }
.wd-sugar { background: linear-gradient(180deg, #ffe3f1 0%, #ffc2e0 55%, #f7a8d0 100%); }
.wd-peak { background: linear-gradient(180deg, #241018 0%, #5c2333 60%, #a63c3c 100%); }

#scenery {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* Stretched to whatever shape the screen is. The backdrop is composition, not
   objects, so distortion is fine and there is nothing to line up. */
#scenery .backdrop {
    width: 100%;
    height: 100%;
    display: block;
}

@keyframes floaty {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-12px) rotate(2deg); }
}

#geode-layer {
    position: absolute;
    inset: 0;
}

.geode {
    position: absolute;
    background: none;
    padding: 0;
    -webkit-touch-callout: none;
    animation: bob 3.2s ease-in-out infinite;
    animation-delay: var(--bob-delay, 0s);
    will-change: transform;
}

@keyframes bob {
    0%, 100% { transform: translateY(0) rotate(-1.5deg); }
    50% { transform: translateY(-8px) rotate(1.5deg); }
}

.geode-svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.3));
    pointer-events: none;
}

.geode .crack { opacity: 0; }

.geode.almost {
    animation: almost-pulse 0.6s ease-in-out infinite;
}

@keyframes almost-pulse {
    0%, 100% { transform: scale(1) rotate(-1deg); }
    50% { transform: scale(1.06) rotate(1deg); }
}

.geode.almost .geode-svg {
    filter: drop-shadow(0 0 14px #ffe066) drop-shadow(0 8px 8px rgba(0, 0, 0, 0.3));
}

/* The treasure that pops out of a burst geode */
.gem-pop {
    position: absolute;
    width: 76px;
    height: 76px;
    font-size: 62px;
    line-height: 76px;
    text-align: center;
    pointer-events: none;
    z-index: 5;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}

.gem-pop.rar-rare { filter: drop-shadow(0 0 12px #cc5de8); }
.gem-pop.rar-legendary { filter: drop-shadow(0 0 16px #ffd43b) drop-shadow(0 0 30px #ffb300); }

.gem-svg { width: 100%; height: 100%; display: block; }
.gem-emoji { display: block; line-height: 1; }

#pet {
    position: absolute;
    font-size: 42px;
    z-index: 6;
    pointer-events: none;
    transition: left 0.25s ease, top 0.25s ease;
    filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.3));
}

#pet.hop { animation: pet-hop 0.5s ease; }

@keyframes pet-hop {
    0% { transform: translateY(0) rotate(0deg); }
    40% { transform: translateY(-22px) rotate(-14deg); }
    70% { transform: translateY(2px) rotate(8deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

#fx-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

/* ============ HUD ============ */

#hud-top, #hud-bottom {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
    z-index: 20;
    pointer-events: none;
}

/* Two stacked rows. The second one is empty unless a combo is running or the
   +10s button is offered, so it takes no space the rest of the time. */
#hud-top {
    top: env(safe-area-inset-top, 0);
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}

#hud-bottom { bottom: max(6px, env(safe-area-inset-bottom)); }

.hud-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.hud-right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

/* Right-aligned and allowed to wrap: on a 320px screen a long combo bar and
   the +10s button together are wider than the screen. */
.hud-row-sub {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.hud-pill {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: clamp(16px, 3.5vw, 21px);
    font-weight: 900;
    color: #38506b;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
}

.hud-pill.pulse { animation: pill-pulse 0.4s ease; }

@keyframes pill-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

#hud-timer.urgent {
    background: #ff6b6b;
    color: #fff;
    animation: pill-pulse 1s ease infinite;
}

#hud-timer.boost {
    background: #51cf66;
    color: #fff;
    animation: pill-pulse 0.45s ease;
}

#btn-time {
    background: linear-gradient(135deg, #38d9a9, #20c997);
    color: #fff;
    font-size: clamp(14px, 3.2vw, 17px);
    padding: 0 14px;
    box-shadow: 0 4px 0 #12b886, 0 4px 10px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
}

#btn-time:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #12b886; }

#btn-time:disabled {
    background: rgba(255, 255, 255, 0.55);
    color: #94a3b8;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

/* The diamond count during a timed round is the round's haul, not the pouch,
   so it is tinted to say "this is a different number from the one at home". */
#hud-sparkles.round {
    background: linear-gradient(135deg, #74c0fc, #4dabf7);
    color: #fff;
}

#combo-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
    min-width: 0;
}

#combo-label {
    font-size: clamp(20px, 5vw, 30px);
    font-weight: 900;
    color: #fff;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
    animation: pill-pulse 0.3s ease;
}

#combo-track {
    width: min(160px, 30vw);
    height: 14px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 999px;
    overflow: hidden;
}

#combo-fill {
    height: 100%;
    background: #4dabf7;
    border-radius: 999px;
    transform-origin: left;
    transform: scaleX(1);
}

#combo-wrap.tier-2 #combo-fill { background: #ff922b; }
#combo-wrap.tier-2 #combo-label { color: #ffd8a8; }
#combo-wrap.tier-3 #combo-fill { background: #cc5de8; }
#combo-wrap.tier-3 #combo-label { color: #eebefa; transform: scale(1.15); }

.hud-btn {
    pointer-events: auto;
    min-width: 56px;
    min-height: 56px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.92);
    font-size: 22px;
    font-weight: 900;
    color: #38506b;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    transition: transform 0.1s ease;
}

.hud-btn:active { transform: scale(0.92); }

.hud-btn.wide {
    flex: 1;
    max-width: 220px;
    font-size: clamp(15px, 3.4vw, 19px);
}

.hud-pill, .hud-btn { pointer-events: auto; }

#wp-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 70px;
}

#wp-label {
    font-size: 15px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

#wp-track {
    width: min(110px, 18vw);
    height: 10px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 999px;
    overflow: hidden;
}

#wp-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffd43b, #ff922b);
    border-radius: 999px;
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

/* ============ MODALS ============ */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 12, 40, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 14px;
}

.modal-card {
    background: #fff;
    border-radius: 24px;
    width: min(580px, 100%);
    max-height: min(86vh, 86dvh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 18px 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.modal-head h2 {
    margin: 0;
    font-size: 24px;
    color: #38506b;
}

.close-x {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #f1f5f9;
    font-size: 18px;
    color: #64748b;
}

.close-x:active { transform: scale(0.9); }

/* Gem Book */

#book-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.book-tab {
    /* Grow to share a row, but never stretch a wrapped leftover across the
       whole width: with six worlds the last tab wraps, and flex-grow made it
       a full-width bar. Six tabs will not fit one row at 320px without going
       under the 56px target, so wrapping is correct and only had to look it. */
    flex: 0 1 calc(20% - 5px);
    min-width: 56px;
    min-height: 56px;
    border-radius: 16px;
    background: #f1f5f9;
    border: 3px solid transparent;
    font-size: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.book-tab small {
    font-size: 11px;
    font-weight: bold;
    color: #94a3b8;
}

.book-tab.selected {
    border-color: #339af0;
    background: #d0ebff;
}

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

.book-card {
    position: relative;
    background: #f8fafc;
    border-radius: 16px;
    border: 3px solid #e2e8f0;
    padding: 10px 6px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-height: 110px;
}

.book-card:active { transform: scale(0.95); }

.book-card.rar-uncommon { border-color: #8ce99a; }
.book-card.rar-rare { border-color: #e599f7; }
.book-card.rar-legendary {
    border-color: #ffd43b;
    background: linear-gradient(160deg, #fffbeb, #fef3c7);
}

.book-card.silhouette { border-color: #e2e8f0; background: #eef2f6; }

.book-card.silhouette .book-ico {
    filter: brightness(0) opacity(0.55);
}

.book-ico {
    width: 54px;
    height: 54px;
    font-size: 46px;
    line-height: 54px;
}

.book-name {
    font-size: 12.5px;
    font-weight: bold;
    color: #475569;
    text-align: center;
    line-height: 1.15;
}

.book-count {
    position: absolute;
    top: 4px;
    right: 6px;
    background: #339af0;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    border-radius: 999px;
    padding: 2px 7px;
}

#book-detail {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #f1f5f9;
    border-radius: 16px;
    padding: 12px 14px;
    margin-top: 12px;
}

.detail-ico {
    width: 64px;
    height: 64px;
    font-size: 54px;
    line-height: 64px;
    flex-shrink: 0;
    text-align: center;
}

.detail-ico.mystery { font-size: 44px; }

.detail-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    color: #334155;
}

.detail-text strong { font-size: 18px; }
.detail-text em { font-size: 14.5px; color: #475569; }
.detail-text small { color: #94a3b8; }
.rar-label { font-size: 13px; font-weight: 900; }

.badges-title {
    margin: 16px 0 8px;
    font-size: 18px;
    color: #38506b;
}

#badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: #f1f5f9;
    border-radius: 14px;
    padding: 8px 10px;
    min-width: 76px;
    min-height: 56px;
    filter: grayscale(1) opacity(0.55);
}

.badge.earned {
    filter: none;
    background: linear-gradient(160deg, #fff9db, #ffec99);
}

.badge span { font-size: 26px; }
.badge small { font-size: 10.5px; font-weight: bold; color: #64748b; }

/* Shop */

.shop-wallet {
    font-size: 19px;
    font-weight: 900;
    color: #38506b;
    text-align: center;
    background: #f1f5f9;
    border-radius: 14px;
    padding: 10px;
    margin-bottom: 12px;
}

#shop-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.shop-card {
    display: flex;
    align-items: center;
    /* The egg card carries a second row of hatched animals under its button. */
    flex-wrap: wrap;
    gap: 12px;
    background: #f8fafc;
    border: 3px solid #e2e8f0;
    border-radius: 18px;
    padding: 12px;
}

.shop-card.owned { background: #ebfbee; border-color: #8ce99a; }

.shop-ico { font-size: 42px; }

.shop-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: #334155;
}

.shop-info strong { font-size: 18px; }
.shop-info span { font-size: 14px; color: #64748b; }

.shop-buy {
    min-height: 52px;
    min-width: 92px;
    border-radius: 16px;
    background: linear-gradient(135deg, #38d9a9, #20c997);
    color: #fff;
    font-size: 17px;
    font-weight: 900;
    box-shadow: 0 4px 0 #12b886;
}

.shop-buy:active { transform: translateY(3px); box-shadow: none; }

.shop-buy:disabled {
    background: #ced4da;
    box-shadow: none;
    color: #868e96;
}

/* The hatched animals. One is active; tapping swaps which. */
.helper-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 2px dashed #e2e8f0;
}

.helper-pick {
    min-width: 48px;
    min-height: 48px;
    border-radius: 14px;
    border: 3px solid transparent;
    background: #f1f5f9;
    font-size: 26px;
    line-height: 1;
    opacity: 0.55;
}

.helper-pick.on {
    background: #e7f5ff;
    border-color: #4dabf7;
    opacity: 1;
}

.helper-pick:active { transform: scale(0.92); }

/* ============ WISHING WELL ============ */

.well-intro {
    margin: 0 0 10px;
    color: #64748b;
    font-size: 15px;
    line-height: 1.4;
    text-align: center;
}

.well-link {
    display: block;
    width: 100%;
    margin: 12px 0 4px;
}

#well-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.well-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
    border: 3px solid #e2e8f0;
    border-radius: 18px;
    padding: 12px;
}

.well-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* The treasures this world is still hiding. Same silhouette treatment as an
   undiscovered card in the Gem Book, so the two screens say the same thing. */
.well-missing {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    background: #eef2f6;
    border-radius: 14px;
}

.well-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    font-size: 27px;
    filter: brightness(0) opacity(0.55);
}

.well-card.done { background: #ebfbee; border-color: #8ce99a; }

.well-ico { font-size: 42px; }

.well-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: #334155;
}

.well-info strong { font-size: 18px; }
.well-info span { font-size: 14px; color: #64748b; }

.well-buy {
    min-height: 52px;
    min-width: 92px;
    border-radius: 16px;
    background: linear-gradient(135deg, #b197fc, #845ef7);
    color: #fff;
    font-size: 17px;
    font-weight: 900;
    box-shadow: 0 4px 0 #7048e8;
}

.well-buy:active { transform: translateY(3px); box-shadow: none; }

.well-buy:disabled {
    background: #ced4da;
    box-shadow: none;
    color: #868e96;
}

/* ============ OVERLAYS (discovery, world, result) ============ */

/* The book count on the discovery card: where the treasure just went. */
#disc-book {
    margin-top: 10px;
    padding: 8px 14px;
    border-radius: 14px;
    background: #eef2f6;
    color: #334155;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 0.5px;
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 12, 40, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
    padding: 18px;
}

#discovery-card, #world-card, #result-card {
    background: #fff;
    border-radius: 28px;
    padding: 22px 26px 26px;
    width: min(420px, 100%);
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

#discovery-card.legendary {
    background: linear-gradient(170deg, #fff9db, #ffe8a1);
    box-shadow: 0 0 60px rgba(255, 211, 59, 0.8), 0 24px 60px rgba(0, 0, 0, 0.5);
}

.disc-new {
    display: inline-block;
    background: #ff5d5d;
    color: #fff;
    font-size: 17px;
    font-weight: 900;
    border-radius: 999px;
    padding: 5px 18px;
    transform: rotate(-3deg);
    animation: pill-pulse 1.2s ease infinite;
}

#disc-icon {
    width: 130px;
    height: 130px;
    margin: 14px auto 4px;
    font-size: 106px;
    line-height: 130px;
    animation: floaty 3s ease-in-out infinite;
}

#disc-stars { font-size: 15px; font-weight: 900; }

#disc-name {
    margin: 6px 0 2px;
    font-size: 27px;
    color: #38506b;
}

#discovery-card p {
    margin: 4px 0 18px;
    font-size: 16.5px;
    color: #475569;
}

#discovery-card .cta, #world-card .cta, .result-actions .cta { width: 100%; }

#world-emoji {
    font-size: 96px;
    animation: floaty 3s ease-in-out infinite;
}

#world-card h2 {
    margin: 8px 0 2px;
    font-size: 30px;
    color: #38506b;
}

#world-card p {
    margin: 4px 0 18px;
    font-size: 17px;
    color: #475569;
}

#result-card h2 {
    margin: 0 0 6px;
    font-size: 26px;
    color: #38506b;
}

#result-score {
    font-size: 52px;
    font-weight: 900;
    color: #f59f00;
    text-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}

#result-stats {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 12px 0 18px;
    font-size: 16.5px;
    font-weight: bold;
    color: #475569;
}

.new-best {
    font-size: 20px;
    color: #e8590c;
    animation: pill-pulse 1s ease infinite;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.result-actions .chip-btn { width: 100%; }

/* ============ TOASTS ============ */

#toast-zone {
    position: fixed;
    bottom: max(86px, calc(env(safe-area-inset-bottom) + 80px));
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 200;
    pointer-events: none;
}

.toast {
    background: rgba(30, 30, 50, 0.92);
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    border-radius: 999px;
    padding: 11px 22px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    animation: toast-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 90vw;
    text-align: center;
}

.toast.out {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(20px) scale(0.8); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============ SMALL SCREENS / LANDSCAPE ============ */

@media (max-height: 480px) {
    /* Tablet/phone landscape: tighter HUD so the play field stays big. */
    .hud-btn { min-width: 48px; min-height: 48px; }
    .hud-pill { padding: 6px 12px; }
    #disc-icon { width: 90px; height: 90px; font-size: 72px; line-height: 90px; margin: 6px auto 2px; }
}

@media (prefers-reduced-motion: reduce) {
    .geode, .game-title, #disc-icon, #world-emoji { animation: none; }
}
