/* Disable pull-to-refresh on mobile */
html, body {
    overscroll-behavior-y: contain;
}

/* Dark neutral body behind the location backdrop image.
   Overrides per-page purple gradients so no tint shows through. */
body {
    background: #1a1a2e !important;
    background-attachment: fixed;
}

/* Ensure all page content renders above the fixed backdrop.
   Content starts hidden and fades in once the backdrop image is ready. */
.container, .main-content, .store-container {
    position: relative;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.6s ease;
}

body.backdrop-ready .container,
body.backdrop-ready .main-content,
body.backdrop-ready .store-container {
    opacity: 1;
}

/* Make content wrappers transparent so location backdrop shows through.
   Individual cards/items should use solid backgrounds instead. */
.content {
    background: transparent !important;
    box-shadow: none !important;
}

/* Override for pages that need solid white content (guide, integrations) */
.content.solid-bg {
    background: white !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1) !important;
    border-radius: 15px;
}

/* Location Backdrop - appears instantly once loaded.
   Slightly oversized to absorb scrollbar/viewport shifts without visible resize. */
#location-backdrop,
#location-backdrop-next {
    position: fixed;
    top: -2%;
    left: -2%;
    width: 104%;
    height: 104%;
    object-fit: cover;
    z-index: 0;
    opacity: 0;
    pointer-events: none;
}

#location-backdrop.visible {
    opacity: 1;
}

/* Next backdrop sits on top for crossfade */
#location-backdrop-next {
    z-index: 0;
}

#location-backdrop-next.crossfade-in {
    opacity: 1;
    transition: opacity 8s ease;
}

#location-backdrop.crossfade-out {
    opacity: 0;
    transition: opacity 8s ease;
}

/* The dim over the location photo, everywhere (owner's call, 2026-10-19).
   The photo at full brightness behind every page was most of the lit panel
   on an OLED phone; location-detail already dimmed its own and now opts out
   with data-backdrop-dim="own", the world map shows no photo at all. The
   value is the same rgba(10,8,20,.55) location-detail starts from, so the
   two read as one treatment. Shown only while a photo is actually visible. */
#location-backdrop-scrim {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: rgba(10, 8, 20, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.2s ease;
}
#location-backdrop.visible ~ #location-backdrop-scrim,
#location-backdrop-next.crossfade-in ~ #location-backdrop-scrim {
    opacity: 1;
}
body[data-backdrop-dim="own"] #location-backdrop-scrim,
body[data-backdrop-dim="none"] #location-backdrop-scrim {
    display: none;
}

/* Simple Top Header Styles */
.simple-top-header {
    background: transparent;
    padding: 15px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.simple-top-header .header-logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.simple-top-header .header-logo > img {
    width: 58px;
    height: 58px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    padding: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.simple-top-header .header-logo h1 {
    font-size: 1.8em;
    color: #667eea;
    margin: 0;
}

.page-info-btn {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.7);
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 1.15rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}
.page-info-btn img { border-radius: 6px; }
.page-info-btn:hover { border-color: #fff; }

.simple-top-header .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.simple-top-header .home-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 11px 14px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.72em;
    font-weight: 600;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* CSS-based hamburger icon */
.home-button .hamburger-icon {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 25px;
    height: 18px;
}

.home-button .hamburger-icon span {
    display: block;
    height: 3.5px;
    background: white;
    border-radius: 2px;
}

.simple-top-header .home-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Dropdown Styles */
.dropdown {
    position: relative;
    display: inline-block;
}

/* Gold Display (header) */
.gold-display-header {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    padding: 8px 14px;
    border-radius: 20px;
    font-weight: 700;
    color: #7a5c00;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.gold-display-header:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.gold-icon-header {
    font-size: 1.38em;
}

.gold-count {
    font-size: 1.15em;
    min-width: 30px;
    text-align: center;
}

/* Motes Display */
.motes-display {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    padding: 8px 14px;
    border-radius: 20px;
    font-weight: 700;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.motes-display:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.4);
}

.motes-icon {
    font-size: 1.38em;
}

.motes-count {
    font-size: 1.15em;
    min-width: 30px;
    text-align: center;
}

/* Shards Display */
.shards-display {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
    padding: 8px 14px;
    border-radius: 20px;
    font-weight: 700;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.shards-display:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.shards-icon {
    font-size: 1.38em;
}

.shards-count {
    font-size: 1.15em;
    min-width: 30px;
    text-align: center;
}

/* === Trials button (header) ===
   Teal so it doesn't clash with shards (purple). Same height as the currency
   pills. Count shown as a notification-style corner badge, not inline. */
/* Rewards button — single icon-only header entry point to the canonical
   Rewards panel (replaces the old gold/motes/shards pills). */
.rewards-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-family: inherit;
    font-size: 1.72em;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
.rewards-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.rewards-button .rewards-icon { font-size: 1em; line-height: 1; }

.trials-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    color: white;
    padding: 0;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    font-size: 1.72em;
    line-height: 1;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: relative;
    box-sizing: border-box;
}
.trials-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.trials-button .trials-icon { font-size: 1em; line-height: 1; }

.schedule-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
    color: white;
    padding: 0;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-family: inherit;
    font-size: 1.72em;
    line-height: 1;
    cursor: pointer;
    box-sizing: border-box;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}
.schedule-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.schedule-button .schedule-icon { font-size: 1em; line-height: 1; }

/* Connection status — a signal-bars button that sits beside the logo. The bar
   colour reflects the live reachability of the server: green (connected), red
   (offline), amber (checking). A diagonal slash overlays the bars when offline
   so the "no connection" read holds even without colour. */
.conn-status {
    position: relative;
    background: rgba(255, 255, 255, 0.85);
    border: none;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.18s, box-shadow 0.18s;
}
.conn-status:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Signal bars — coloured via currentColor so the state class recolours all
   three at once. Idle/unknown = grey. */
.conn-status { color: #9ca3af; }
.conn-status .conn-bars .conn-bar {
    fill: currentColor;
    transition: fill 0.25s, opacity 0.25s;
}
.conn-status.online  { color: #16a34a; }
.conn-status.offline { color: #ef4444; }
.conn-status.checking { color: #f59e0b; }

/* Offline: dim the taller bars so it reads as "signal lost", and show the slash. */
.conn-status.offline .conn-bars .b2 { opacity: 0.4; }
.conn-status.offline .conn-bars .b3 { opacity: 0.4; }
.conn-status .conn-slash {
    position: absolute;
    width: 26px;
    height: 3px;
    border-radius: 2px;
    background: #ef4444;
    transform: rotate(-45deg);
    opacity: 0;
    transition: opacity 0.2s;
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85);
}
.conn-status.offline .conn-slash { opacity: 1; }

/* Checking: gentle pulse on the whole icon. */
.conn-status.checking .conn-bars { animation: conn-status-pulse 1s ease-in-out infinite; }
@keyframes conn-status-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* Notification-style corner badge for the Trials count. Distinct colour from
   the bell badge (red), so the two reads are unambiguous side by side. */
.trials-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 21px;
    height: 21px;
    background: #f59e0b; /* amber — distinct from bell red, doesn't clash with currency pills */
    color: #1a1a2e;
    border-radius: 10.5px;
    border: 2px solid white;
    font-size: 13px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    pointer-events: none;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
    /* Three breaths when it appears, then still (battery: no infinite paint). */
    animation: trials-pulse 2.4s ease-in-out 3;
}
@keyframes trials-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.08); }
}

/* Make every header pill the same height as the new Trials button.
   Buttons have a different default line-height than divs, so we
   normalise here. */
.gold-display-header,
.motes-display,
.shards-display,
.trials-button {
    line-height: 1;
    box-sizing: border-box;
}
.gold-icon-header,
.motes-icon,
.shards-icon,
.trials-icon { line-height: 1; }
.gold-count,
.motes-count,
.shards-count {
    line-height: 1;
    /* min-width allows compact "1.2k" etc. without jumping width when below 1000 */
    min-width: 28px;
}

@media (max-width: 640px) {
    .trials-button .trials-count { display: none; }
}

/* Header icon buttons - shared style */
.bell-button,
.zoom-toggle-button,
.mute-toggle-button {
    background: rgba(255, 255, 255, 0.85);
    border: none;
    font-size: 1.72em;
    cursor: pointer;
    padding: 9px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.bell-button:hover,
.zoom-toggle-button:hover,
.mute-toggle-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 21px;
    height: 21px;
    background: #e74c3c;
    color: white;
    border-radius: 10.5px;
    border: 2px solid white;
    font-size: 13px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

@keyframes bellRing {
    0%, 100% { transform: rotate(0deg); }
    10%, 30%, 50%, 70%, 90% { transform: rotate(-10deg); }
    20%, 40%, 60%, 80% { transform: rotate(10deg); }
}

.bell-ringing {
    /* Rings three times when something arrives, then rests (battery). */
    animation: bellRing 2s ease-in-out 3;
    transform-origin: top center;
}

/* User Avatar */
.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.38em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.user-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Install indicator - flashing dot on avatar when app not installed */
.user-avatar.install-available::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #27ae60;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.35);
}

/* The dot nudges twice every half minute (simple-header.js schedules the
   `.pulse` class), and is still in between. It used to pulse box-shadow
   forever, which repainted every frame on every page: measured at 60 to 100
   ms of main thread a second on an idle phone, i.e. nearly all of its idle
   CPU. transform/opacity only — those run on the compositor. */
.user-avatar.install-available.pulse::after {
    animation: installPulse 1.2s ease-in-out 2;
}

.user-avatar.install-available {
    position: relative;
}

@keyframes installPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.35);
        opacity: 0.75;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .simple-top-header {
        padding: 10px 15px;
    }

    .simple-top-header .header-logo h1 {
        font-size: 1.3em;
    }

    .simple-top-header .header-logo img {
        width: 46px;
        height: 46px;
    }

    .simple-top-header .home-button {
        font-size: 1.04em;
        padding: 9px 14px;
    }

    .team-icons {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .simple-top-header .header-logo h1 {
        font-size: 1.1em;
    }

    .simple-top-header .header-logo {
        gap: 10px;
    }

    .simple-top-header .header-right {
        gap: 8px;
    }

    .motes-display,
    .gold-display-header,
    .shards-display {
        padding: 7px 12px;
        font-size: 1.04em;
    }

    .home-button span:last-child {
        display: none;
    }
}

/* ============================================================================
 * Toolbar modals — CONTENT inside the guide shell.
 *
 * Every toolbar popup (logo tours, connection, rewards, trials, schedule,
 * notifications, account) opens through GameGuides.showCustom — the same modal
 * as the page-info "?" button — so the sheet, gold title, indigo h3s and the
 * footer button are the shell's, never ours. What lives here is only the content
 * vocabulary those bodies share (a tappable row, a key/value box, a pill),
 * scoped under .guide-body-shared per docs/GUIDE_MODAL.md, and sized from the
 * type scale (docs/TYPE_SYSTEM.md).
 * ==========================================================================*/
.guide-body-shared .tb-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 12px; }

/* A tappable row: icon · title over sub · meta/pill on the right. */
.guide-body-shared .tb-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: #ccc;
    font-family: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}
.guide-body-shared .tb-row:hover { background: rgba(102, 126, 234, 0.12); border-color: rgba(102, 126, 234, 0.45); }
.guide-body-shared .tb-row.is-static { cursor: default; }
.guide-body-shared .tb-row.is-static:hover { background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.08); }
.guide-body-shared .tb-row.is-read { opacity: 0.65; }
.guide-body-shared .tb-row-icon { font-size: var(--fs-h3, 1.5rem); width: 34px; text-align: center; flex-shrink: 0; line-height: 1; }
.guide-body-shared .tb-row-main { flex: 1 1 auto; min-width: 0; }
.guide-body-shared .tb-row-kicker {
    display: block;
    color: #a5b4fc;
    font-size: var(--fs-label, 0.9rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}
.guide-body-shared .tb-row-title { display: block; color: #fff; font-size: var(--fs-body, 1.3rem); font-weight: 600; line-height: 1.3; }
.guide-body-shared .tb-row-sub { display: block; color: #cbd5e1; font-size: var(--fs-ui, 1rem); line-height: 1.4; margin-top: 2px; }
.guide-body-shared .tb-row-alert { display: block; color: #fca5a5; font-size: var(--fs-ui, 1rem); font-weight: 600; line-height: 1.4; margin-top: 4px; }
.guide-body-shared .tb-row-meta { flex-shrink: 0; color: #cbd5e1; font-size: var(--fs-label, 0.9rem); white-space: nowrap; }

/* A row plus a secondary control beside it (buttons can't nest). */
.guide-body-shared .tb-row-wrap { display: flex; align-items: center; gap: 8px; }
.guide-body-shared .tb-row-wrap .tb-row { flex: 1 1 auto; width: auto; min-width: 0; }

/* Status pill / small secondary button. */
.guide-body-shared .tb-pill {
    flex-shrink: 0;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: var(--fs-label, 0.9rem);
    font-weight: 700;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
}
.guide-body-shared .tb-pill.current { background: rgba(102, 126, 234, 0.22); color: #c7d2fe; }
.guide-body-shared .tb-pill.done    { background: rgba(34, 197, 94, 0.18);  color: #86efac; }
.guide-body-shared .tb-pill.intro   { background: rgba(255, 215, 0, 0.16);  color: #ffd700; }
.guide-body-shared .tb-pill-btn {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: #cbd5e1;
    font-family: inherit;
    font-size: var(--fs-label, 0.9rem);
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
.guide-body-shared .tb-pill-btn:hover { background: rgba(34, 197, 94, 0.15); color: #86efac; border-color: rgba(34, 197, 94, 0.45); }

/* Key / value box (connection readout). */
.guide-body-shared .tb-kv {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    margin: 8px 0 12px;
}
.guide-body-shared .tb-kv-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; }
.guide-body-shared .tb-kv-row + .tb-kv-row { border-top: 1px solid rgba(255, 255, 255, 0.06); }
.guide-body-shared .tb-kv-label { color: #ccc; font-size: var(--fs-body, 1.3rem); }
.guide-body-shared .tb-kv-value { color: #fff; font-size: var(--fs-body, 1.3rem); font-weight: 600; }
.guide-body-shared .tb-kv-value.good { color: #22c55e; }
.guide-body-shared .tb-kv-value.fair { color: #f59e0b; }
.guide-body-shared .tb-kv-value.poor { color: #ef4444; }

/* Big status line: coloured dot + word (connection). */
.guide-body-shared .tb-status { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.guide-body-shared .tb-status-dot { width: 14px; height: 14px; border-radius: 50%; background: #9ca3af; flex: 0 0 auto; }
.guide-body-shared .tb-status-word { color: #fff; font-size: var(--fs-h3, 1.5rem); font-weight: 700; }

.guide-body-shared .tb-empty { text-align: center; padding: 16px 0; }

/* Extra footer buttons sit beside "Got it!" in the shell's own footer and use
   its .guide-close-btn look; this only stops a disabled one looking live. */
.guide-modal-shared .guide-close-btn:disabled { opacity: 0.55; cursor: default; }

/* Tours list (header-extras.js): the cued tour pulses in the coach's gold
   (the ring values from onboarding-coach.css, so the hand and the row agree),
   and completed tours sit in a folder with the collection's own toggle. */
.guide-body-shared .tb-row.is-cued {
    border-color: #ffd23f;
    box-shadow: 0 0 0 3px #ffd23f, 0 0 18px 4px rgba(255, 210, 63, 0.6);
    animation: tb-cue-pulse 1.6s ease-in-out infinite;
}
/* transform-only: an animated box-shadow repaints every frame (battery). */
@keyframes tb-cue-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.015); }
}
.guide-body-shared .tb-folder .toggle-icon { display: inline-block; transition: transform 0.3s; }
.guide-body-shared .tb-folder .toggle-icon.collapsed { transform: rotate(-90deg); }
.guide-body-shared .tb-folder-body { margin-left: 18px; }
.guide-body-shared .tb-folder-body[hidden] { display: none; }
