/* ============================================================
   Splorbit Web Demo — demo-only styles
   ============================================================
   Phase 2: start screen layout, character grid, Start button.
   Phase 3: + username field, two-column layout, leaderboard preview.
   Phase 4+ will add end screen, watermark. */

/* ---------- 1. Hide menu chrome the engine would normally show ---------- */
body[data-demo="desktop"] #openingScreen,
body[data-demo="desktop"] #characterSelectionScreen,
body[data-demo="desktop"] #controllerMappingScreen,
body[data-demo="desktop"] #ballLoadoutScreen,
body[data-demo="desktop"] #dungeonMapScreen,
body[data-demo="desktop"] #orientationMessage {
    display: none !important;
}

/* ---------- 2. Demo start screen overlay ---------- */
.demo-start-screen {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(91, 143, 185, 0.25), transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(212, 168, 75, 0.2), transparent 55%),
        linear-gradient(180deg, #11132a 0%, #1a1a2e 50%, #0d0e1a 100%);
    color: #f3eee0;
    font-family: 'Sora', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-y: auto;
    padding: 36px 28px 56px;
}

.demo-start-screen.demo-start-screen-visible {
    display: flex;
}

.demo-start-inner {
    width: 100%;
    max-width: 1180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

/* ---------- 3. Header ---------- */
.demo-start-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.demo-start-title-img {
    width: clamp(220px, 30vw, 340px);
    height: auto;
    filter: drop-shadow(0 8px 32px rgba(116, 185, 255, 0.45));
}

.demo-start-tagline {
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(243, 238, 224, 0.6);
}

/* ---------- 4. Two-column layout ---------- */
.demo-start-columns {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 36px;
    width: 100%;
    align-items: stretch;
}

@media (max-width: 920px) {
    .demo-start-columns {
        grid-template-columns: 1fr;
        gap: 28px;
    }
}

.demo-start-col-left,
.demo-start-col-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.demo-start-section-label {
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(243, 238, 224, 0.5);
    margin-bottom: 2px;
}

/* ---------- 5. Username input ---------- */
.demo-username-input {
    appearance: none;
    width: 100%;
    border: 2px solid rgba(243, 238, 224, 0.16);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    border-radius: 14px;
    padding: 16px 22px;
    color: #f3eee0;
    font: inherit;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.04em;
    transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.demo-username-input::placeholder {
    color: rgba(243, 238, 224, 0.32);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.demo-username-input:hover {
    border-color: rgba(116, 185, 255, 0.32);
}

.demo-username-input:focus {
    outline: none;
    border-color: rgba(116, 185, 255, 0.6);
    background: linear-gradient(180deg, rgba(116, 185, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%);
    box-shadow: 0 0 0 4px rgba(116, 185, 255, 0.14);
}

.demo-username-error {
    min-height: 16px;
    font-size: 12px;
    color: #ff8e8e;
    letter-spacing: 0.02em;
    margin-top: -4px;
}

/* ---------- 6. Character grid ---------- */
.demo-character-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
}

@media (max-width: 1080px) {
    .demo-character-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 10px;
    }
}

@media (max-width: 700px) {
    .demo-character-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 460px) {
    .demo-character-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.demo-char-card {
    appearance: none;
    border: 2px solid rgba(243, 238, 224, 0.12);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
    border-radius: 16px;
    padding: 12px 8px 14px;
    color: inherit;
    font: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition:
        transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1),
        border-color 180ms ease,
        background 180ms ease,
        box-shadow 180ms ease;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.demo-char-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(116, 185, 255, 0.18), transparent 70%);
    opacity: 0;
    transition: opacity 200ms ease;
    pointer-events: none;
}

.demo-char-card:hover {
    transform: translateY(-3px);
    border-color: rgba(116, 185, 255, 0.4);
    background: linear-gradient(180deg, rgba(116, 185, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
}

.demo-char-card:hover::before {
    opacity: 1;
}

.demo-char-card:focus-visible {
    outline: none;
    border-color: rgba(116, 185, 255, 0.55);
    box-shadow: 0 0 0 4px rgba(116, 185, 255, 0.18);
}

.demo-char-card-selected {
    transform: translateY(-3px) scale(1.02);
    border-color: #f1c40f;
    background: linear-gradient(180deg, rgba(241, 196, 15, 0.14) 0%, rgba(241, 196, 15, 0.04) 100%);
    box-shadow:
        0 0 0 1px rgba(241, 196, 15, 0.35) inset,
        0 12px 40px -8px rgba(241, 196, 15, 0.4);
}

.demo-char-card-selected::before {
    background: radial-gradient(ellipse at 50% 0%, rgba(241, 196, 15, 0.28), transparent 65%);
    opacity: 1;
}

.demo-char-portrait {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    object-position: center;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
}

.demo-char-no-portrait .demo-char-portrait {
    display: none;
}

.demo-char-name {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-align: center;
    color: #f3eee0;
}

.demo-char-desc {
    font-size: 10px;
    line-height: 1.35;
    color: rgba(243, 238, 224, 0.5);
    text-align: center;
    min-height: 26px;
    padding: 0 2px;
}

/* ---------- 7. Start button ---------- */
.demo-start-btn {
    appearance: none;
    border: none;
    cursor: pointer;
    font: inherit;
    margin-top: 14px;
    padding: 18px 36px;
    border-radius: 999px;
    background: linear-gradient(180deg, #f1c40f 0%, #d4a84b 100%);
    color: #1a1a2e;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    box-shadow:
        0 0 0 1px rgba(241, 196, 15, 0.6) inset,
        0 12px 40px -8px rgba(241, 196, 15, 0.55),
        0 6px 16px -4px rgba(0, 0, 0, 0.4);
    transition: transform 160ms ease, box-shadow 200ms ease, opacity 160ms ease;
    text-align: center;
    width: 100%;
}

.demo-start-btn:not(:disabled):hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow:
        0 0 0 1px rgba(241, 196, 15, 0.8) inset,
        0 18px 56px -8px rgba(241, 196, 15, 0.7),
        0 8px 20px -4px rgba(0, 0, 0, 0.5);
}

.demo-start-btn:not(:disabled):active {
    transform: translateY(0) scale(0.99);
}

.demo-start-btn:disabled {
    cursor: not-allowed;
    opacity: 0.4;
    background: rgba(243, 238, 224, 0.12);
    color: rgba(243, 238, 224, 0.45);
    box-shadow: none;
}

/* ---------- 8. Leaderboard ---------- */
.demo-lb-tabs {
    display: flex;
    gap: 6px;
    background: rgba(255, 255, 255, 0.03);
    padding: 5px;
    border-radius: 12px;
    border: 1px solid rgba(243, 238, 224, 0.08);
}

.demo-lb-tab {
    appearance: none;
    border: none;
    cursor: pointer;
    font: inherit;
    flex: 1;
    padding: 10px 12px;
    border-radius: 8px;
    background: transparent;
    color: rgba(243, 238, 224, 0.55);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: background 160ms ease, color 160ms ease;
}

.demo-lb-tab:hover {
    color: rgba(243, 238, 224, 0.85);
    background: rgba(255, 255, 255, 0.04);
}

.demo-lb-tab-active {
    background: linear-gradient(180deg, rgba(116, 185, 255, 0.2) 0%, rgba(116, 185, 255, 0.08) 100%);
    color: #f3eee0;
    box-shadow:
        0 0 0 1px rgba(116, 185, 255, 0.35) inset,
        0 4px 14px -4px rgba(116, 185, 255, 0.4);
}

.demo-lb-list-wrap {
    flex: 1;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(243, 238, 224, 0.08);
    border-radius: 14px;
    padding: 10px 14px;
    min-height: 360px;
    max-height: 480px;
    overflow-y: auto;
}

.demo-lb-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.demo-lb-row {
    display: grid;
    grid-template-columns: 32px 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-radius: 9px;
    transition: background 140ms ease;
    border-bottom: 1px solid rgba(243, 238, 224, 0.04);
}

.demo-lb-row:last-child { border-bottom: none; }

.demo-lb-row:hover {
    background: rgba(116, 185, 255, 0.06);
}

.demo-lb-rank {
    font-size: 14px;
    font-weight: 800;
    color: rgba(243, 238, 224, 0.45);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.demo-lb-row:nth-child(1) .demo-lb-rank { color: #f1c40f; }
.demo-lb-row:nth-child(2) .demo-lb-rank { color: #c9d1d9; }
.demo-lb-row:nth-child(3) .demo-lb-rank { color: #cd7f32; }

.demo-lb-name {
    font-size: 13px;
    font-weight: 700;
    color: #f3eee0;
    letter-spacing: 0.03em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.demo-lb-char {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(243, 238, 224, 0.42);
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(243, 238, 224, 0.06);
}

.demo-lb-kills {
    text-align: right;
}

.demo-lb-kills-num {
    font-size: 16px;
    font-weight: 800;
    color: #f1c40f;
    font-variant-numeric: tabular-nums;
}

.demo-lb-kills-lbl {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(243, 238, 224, 0.4);
    margin-left: 2px;
}

.demo-lb-loading,
.demo-lb-empty {
    padding: 40px 20px;
    text-align: center;
    font-size: 13px;
    color: rgba(243, 238, 224, 0.4);
    letter-spacing: 0.04em;
}

.demo-lb-footnote {
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(243, 238, 224, 0.32);
    text-align: center;
    margin-top: 4px;
}

/* ============================================================
   9. DEMO END SCREEN
   ============================================================ */

.demo-end-screen {
    position: fixed;
    inset: 0;
    z-index: 8500;
    display: none;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(116, 185, 255, 0.18), transparent 60%),
        radial-gradient(ellipse at 50% 90%, rgba(241, 196, 15, 0.12), transparent 55%),
        linear-gradient(180deg, rgba(8, 9, 18, 0.92) 0%, rgba(13, 14, 26, 0.96) 100%);
    color: #f3eee0;
    font-family: 'Sora', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-y: auto;
    padding: 32px 24px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.demo-end-screen.demo-end-screen-visible {
    display: flex;
    animation: demoEndFadeIn 220ms ease-out;
}

@keyframes demoEndFadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to   { opacity: 1; transform: scale(1); }
}

.demo-end-inner {
    width: 100%;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

/* ---------- 9a. Headline ---------- */
.demo-end-headline-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}

.demo-end-outcome {
    font-size: clamp(40px, 7vw, 64px);
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
    text-shadow: 0 4px 32px rgba(0, 0, 0, 0.6);
}

.demo-end-outcome-victory {
    color: #f1c40f;
    text-shadow:
        0 0 32px rgba(241, 196, 15, 0.55),
        0 4px 32px rgba(0, 0, 0, 0.6);
}

.demo-end-outcome-defeat {
    color: #ff8e8e;
    text-shadow:
        0 0 32px rgba(255, 142, 142, 0.4),
        0 4px 32px rgba(0, 0, 0, 0.6);
}

.demo-end-subhead {
    font-size: 13px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(243, 238, 224, 0.55);
}

/* ---------- 9b. Stat block ---------- */
.demo-end-statblock {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 28px;
    width: 100%;
    align-items: stretch;
}

@media (max-width: 620px) {
    .demo-end-statblock {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

.demo-end-bigstat {
    background:
        radial-gradient(ellipse at 50% 0%, rgba(241, 196, 15, 0.14), transparent 70%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 2px solid rgba(241, 196, 15, 0.28);
    border-radius: 18px;
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 12px 40px -8px rgba(241, 196, 15, 0.18);
}

.demo-end-bigstat-num {
    font-size: clamp(56px, 11vw, 96px);
    font-weight: 900;
    color: #f1c40f;
    line-height: 0.95;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 32px rgba(241, 196, 15, 0.5);
}

.demo-end-bigstat-lbl {
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(243, 238, 224, 0.6);
    margin-top: 8px;
}

.demo-end-meta {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(243, 238, 224, 0.1);
    border-radius: 14px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
}

.demo-end-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.demo-end-meta-lbl {
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(243, 238, 224, 0.45);
}

.demo-end-meta-val {
    font-size: 14px;
    font-weight: 700;
    color: #f3eee0;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
}

/* ---------- 9c. Ranks ---------- */
.demo-end-ranks-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.demo-end-section-label {
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(243, 238, 224, 0.5);
    text-align: center;
}

.demo-end-ranks {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(243, 238, 224, 0.08);
    border-radius: 14px;
    padding: 16px;
    min-height: 80px;
}

.demo-end-rank-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 6px;
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(116, 185, 255, 0.06) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 1px solid rgba(116, 185, 255, 0.15);
}

.demo-end-rank-period {
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(243, 238, 224, 0.5);
}

.demo-end-rank-value {
    font-size: 24px;
    font-weight: 900;
    color: #74b9ff;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 16px rgba(116, 185, 255, 0.35);
}

.demo-end-ranks-loading,
.demo-end-ranks-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 16px;
    font-size: 12px;
    letter-spacing: 0.06em;
    color: rgba(243, 238, 224, 0.45);
}

.demo-end-ranks-error { color: #ff8e8e; }

/* ---------- 9d. Action buttons ---------- */
.demo-end-actions {
    display: flex;
    gap: 14px;
    width: 100%;
    margin-top: 4px;
}

@media (max-width: 540px) {
    .demo-end-actions {
        flex-direction: column;
    }
}

.demo-end-btn {
    appearance: none;
    border: none;
    cursor: pointer;
    font: inherit;
    font-family: inherit;
    flex: 1;
    text-decoration: none;
    text-align: center;
    padding: 18px 24px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: transform 160ms ease, box-shadow 200ms ease, background 160ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.demo-end-btn-primary {
    background: linear-gradient(180deg, #f1c40f 0%, #d4a84b 100%);
    color: #1a1a2e;
    box-shadow:
        0 0 0 1px rgba(241, 196, 15, 0.6) inset,
        0 12px 40px -8px rgba(241, 196, 15, 0.55),
        0 6px 16px -4px rgba(0, 0, 0, 0.4);
}

.demo-end-btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow:
        0 0 0 1px rgba(241, 196, 15, 0.8) inset,
        0 18px 56px -8px rgba(241, 196, 15, 0.7),
        0 8px 20px -4px rgba(0, 0, 0, 0.5);
}

.demo-end-btn-primary:active { transform: translateY(0) scale(0.99); }

.demo-end-btn-secondary {
    background: rgba(116, 185, 255, 0.1);
    color: #f3eee0;
    border: 1px solid rgba(116, 185, 255, 0.4);
    box-shadow: 0 6px 20px -8px rgba(116, 185, 255, 0.3);
}

.demo-end-btn-secondary:hover {
    background: rgba(116, 185, 255, 0.18);
    border-color: rgba(116, 185, 255, 0.7);
    transform: translateY(-2px);
}

.demo-end-btn-secondary:active { transform: translateY(0); }

/* ============================================================
   10. CORNER WATERMARK PILL
   ============================================================
   Visible during demo gameplay only. Doubles as a low-key Wishlist CTA. */

.demo-watermark {
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: 7000;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 9px 16px 9px 14px;
    border-radius: 999px;
    background: rgba(13, 14, 26, 0.78);
    border: 1px solid rgba(116, 185, 255, 0.32);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    text-decoration: none;
    font-family: 'Sora', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    box-shadow:
        0 6px 24px -8px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    transition:
        transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
        background 180ms ease,
        border-color 180ms ease,
        box-shadow 200ms ease;
    pointer-events: auto;
}

.demo-watermark.demo-watermark-visible {
    display: inline-flex;
    animation: demoWatermarkSlideIn 380ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes demoWatermarkSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.demo-watermark:hover {
    transform: translateY(-2px) scale(1.03);
    background: rgba(13, 14, 26, 0.92);
    border-color: rgba(116, 185, 255, 0.6);
    box-shadow:
        0 12px 32px -8px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(116, 185, 255, 0.18) inset,
        0 0 24px -4px rgba(116, 185, 255, 0.4);
}

.demo-watermark:active {
    transform: translateY(0) scale(0.98);
}

.demo-watermark-tag {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #f1c40f;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(241, 196, 15, 0.12);
    border: 1px solid rgba(241, 196, 15, 0.32);
}

.demo-watermark-cta {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: rgba(243, 238, 224, 0.8);
}

@media (max-width: 540px) {
    .demo-watermark {
        bottom: 12px;
        right: 12px;
        padding: 7px 12px 7px 10px;
    }
    .demo-watermark-cta {
        font-size: 11px;
    }
}

