/* Ensure all top bars and headers respect iOS safe areas and extend their heights */
.app-header {
    padding-top: env(safe-area-inset-top, 0px) !important;
    height: calc(56px + env(safe-area-inset-top, 0px)) !important;
    box-sizing: border-box !important;
    position: fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 100;
    width: 100%;
    left: 0;
    right: 0;
    top: 0;
}

#header {
    padding-top: calc(15px + env(safe-area-inset-top, 0px)) !important;
}

/* Specific exception for Arcade/play.php which uses a 50px header */
body:has(#content) #header {
    height: calc(50px + env(safe-area-inset-top, 0px)) !important;
}

button {
    min-height: 0;
}

/* Push down page contents to clear the expanded headers */
body {
    padding-top: calc(56px + env(safe-area-inset-top, 0px)) !important;
}

/* Specific body push for Arcade/play.php */
#content {
    margin-top: calc(50px + env(safe-area-inset-top, 0px)) !important;
}

/* ── Mascots Interactive Animation (Floating + Click) ── */
@keyframes mascotBreathe {

    0%,
    100% {
        translate: 0px 0px;
        scale: 1;
        filter: brightness(1);
    }

    50% {
        translate: 0px 4px;
        scale: 1.01;
        filter: brightness(1);
    }
}

.code-input-wrap {
    text-align: center
}

img[src*="_ui.png"] {
    /* Randomize animation delay using a neat trick if possible, or just default */
    animation: mascotBreathe 4s ease-in-out infinite alternate;
    cursor: pointer;
    will-change: translate, scale;
    /* Disable all default mobile interactions/frames when tapped */
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -webkit-user-drag: none !important;
    user-select: none !important;
    outline: none !important;
    /* Use a bouncy transition for clicks */
    transition: scale 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.3s ease;
}

img[src*="_ui.png"]:active {
    scale: 0.8 !important;
    filter: drop-shadow(0 0 30px rgba(0, 179, 136, 0.7)) brightness(1.2) !important;
    transition: scale 0.1s ease, filter 0.1s ease;
}

.help-opt {
    color: #fff;
}

/* ─── Top Bar ─────────────────────── */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
    background: var(--surface);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transform: translateY(-100%);
    animation: slideDown 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideDown {
    to {
        transform: translateY(0);
    }
}

.top-bar .logo {
    height: 22px !important;
}

.credits-badge {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.9rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    transition: all 0.2s;
}

.credits-badge small {
    font-size: 0.6rem;
    opacity: 0.6;
}

.profile-avatar-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    object-fit: cover;
    transition: all 0.2s;
    display: block;
    background: #000;
}

.header-title-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ─── Bottom Nav ─────────────────────── */
.app-nav,
#app-nav,
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    height: calc(75px + env(safe-area-inset-bottom, 0px)) !important;
    background: rgba(8, 8, 8, 0.92);
    backdrop-filter: blur(24px);
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    box-sizing: border-box !important;
    /* Horizontally center the fixed bar to match .app-container */
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 100% !important;
    max-width: 680px !important;
}

.app-nav {
    align-items: center;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-family: 'Outfit', sans-serif;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: .5px;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: color .2s;
}

.nav-item i {
    font-size: 1.2rem;
    transition: transform .2s;
}

.hero-icon {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 10px;
}

.page-content {
    padding-top: 0 !important
}

.hero h1 {
    background: linear-gradient(135deg, #fff 30%, var(--theme)) !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

[data-theme="light"] .hero h1 {
    background: linear-gradient(135deg, #1f2937 30%, var(--theme)) !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .hero h1 {
        background: linear-gradient(135deg, #1f2937 30%, var(--theme)) !important;
        background-clip: text !important;
        -webkit-text-fill-color: transparent !important;
    }
}

.mode-card.selected .mode-check,
.mode-opt.active .mode-check {
    background: var(--theme) !important;
    border-color: var(--theme) !important;
}

.pack-item.selected .pack-check {
    background: var(--theme);
    border-color: var(--theme);
    color: #000;
}

.bottom-nav .nav-item.active,
.app-nav .nav-item.active {
    color: var(--neon, var(--theme, var(--cyan, var(--red, var(--yellow, var(--purple, var(--acc, var(--acc2, var(--green, #0ea5e9))))))))) !important;
}

/* Fallback for rgb(var) in drop-shadow */
.nav-item.active i {
    transform: translateY(-2px);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.25));
}


/* Top Bar Extras */
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-back {
    display: flex;
    align-items: center;
}

/* ─── Standardized Game Inputs & Buttons ─────────────────────── */
.btn,
.btn-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 20px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    font-family: var(--font, 'Outfit', sans-serif);
    font-size: 1.1rem;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: transform 0.15s, box-shadow 0.15s;
    text-decoration: none;
    box-sizing: border-box;
}

.btn:active,
.btn-cta:active {
    transform: scale(0.97);
}

.btn-primary,
.btn-cta-primary {
    background: var(--neon, var(--theme, var(--cyan, var(--red, var(--yellow, var(--purple, var(--acc, var(--acc2, var(--green, #0ea5e9)))))))));
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.btn-secondary,
.btn-cta-secondary {
    background: var(--card, rgba(255, 255, 255, 0.04));
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}

.btn-ghost,
.btn-cta-ghost {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}

.code-input {
    width: 100%;
    padding: 22px 20px;
    font-size: 2.4rem;
    font-weight: 900;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 10px;
    text-indent: 10px;
    /* fixes optical alignment offset caused by letter-spacing */
    background: var(--card, rgba(255, 255, 255, 0.04));
    border: 2px solid var(--border, rgba(255, 255, 255, 0.08));
    border-radius: 16px;
    color: #fff;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: var(--font, 'Outfit', sans-serif);
    margin-bottom: 14px;
    box-sizing: border-box;
}

.code-input::placeholder {
    color: rgba(255, 255, 255, 0.15);
    letter-spacing: 6px;
    text-indent: 6px;
    font-size: 1.8rem;
}

.code-input:focus {
    border-color: var(--neon, var(--theme, var(--cyan, var(--red, var(--yellow, var(--purple, var(--acc, var(--acc2, var(--green, #0ea5e9)))))))));
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.code-input.error {
    border-color: #ef4444;
    animation: shake-err 0.3s;
}

@keyframes shake-err {

    0%,
    100% {
        transform: translateX(0)
    }

    25% {
        transform: translateX(-8px)
    }

    75% {
        transform: translateX(8px)
    }
}

.form-label,
.field-label,
.section-label {
    font-size: 0.68rem;
    font-weight: 900;
    color: var(--muted, rgba(255, 255, 255, 0.4));
    text-transform: uppercase;
    letter-spacing: 1.5px;
    display: block;
    margin-bottom: 6px;
}

.section-label {
    margin: 24px 0 12px;
}

.form-input,
.form-select,
.field-input,
.field-select {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 2px solid var(--border, rgba(255, 255, 255, 0.12));
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    outline: none;
    transition: 0.2s;
    font-family: var(--font, 'Outfit', sans-serif);
    text-align: center;
    box-sizing: border-box;
}

.form-input:focus,
.form-select:focus,
.field-input:focus,
.field-select:focus {
    border-color: var(--neon, var(--theme, var(--cyan, var(--red, var(--yellow, var(--purple, var(--acc, var(--acc2, var(--green, #0ea5e9)))))))));
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.form-select option,
.field-select option {
    background: #111;
}

.form-row,
.fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
}

.fields-grid.three {
    grid-template-columns: 1fr 1fr 1fr;
}

.cost-badge {
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-left: auto;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    font-weight: 800;
}

/* ─── Mode Cards ─────────────────────── */
.mode-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.mode-card {
    display: flex;
    align-items: center;
    padding: 18px 20px;
    background: var(--card, rgba(255, 255, 255, 0.04));
    border: 2px solid var(--border, rgba(255, 255, 255, 0.08));
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-card.active,
.mode-card.selected {
    border-color: var(--neon, var(--theme));
    background: rgba(var(--neon-rgb, 0, 179, 136), 0.1);
}

.mode-icon {
    font-size: 1.8rem;
    width: 44px;
    text-align: center;
    margin-right: 16px;
    flex-shrink: 0;
}

.mode-title {
    font-size: 1.05rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.mode-desc {
    font-size: 0.75rem;
    color: var(--muted, rgba(255, 255, 255, 0.6));
    line-height: 1.3;
}

.mode-check {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    margin-left: auto;
    transition: all 0.2s;
    flex-shrink: 0;
}

/* ─── Theme Buttons ─────────────────────── */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.theme-btn {
    padding: 16px 10px;
    background: var(--card, rgba(255, 255, 255, 0.04));
    border: 2px solid var(--border, rgba(255, 255, 255, 0.08));
    border-radius: 16px;
    color: var(--muted, rgba(255, 255, 255, 0.5));
    font-weight: 800;
    font-size: 0.8rem;
    font-family: var(--font, 'Outfit', sans-serif);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.theme-btn.active,
.theme-btn.selected {
    border-color: var(--neon, var(--theme));
    background: var(--neon, var(--theme));
    color: #111;
}

/* ─── Toggles (Action Vérité style) ─────────────────────── */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--card, rgba(255, 255, 255, 0.02));
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    border-radius: 16px;
    margin-bottom: 12px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
    pointer-events: none;
}

.toggle-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 34px;
    transition: .3s;
}

.toggle-track:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    border-radius: 50%;
    transition: .3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.toggle-switch input:checked+.toggle-track {
    background-color: var(--neon, var(--theme, #0ea5e9));
}

.toggle-switch input:checked+.toggle-track:before {
    transform: translateX(22px);
}

/* ─── Layout Utils ─────────────────────── */
.glass-card,
.card {
    background: var(--card, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    border-radius: 24px;
    padding: 24px 20px;
    margin-bottom: 24px;
}

.card-title,
.section-title {
    font-size: 0.85rem;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--muted, rgba(255, 255, 255, 0.5));
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ─── Global Drawer Mode Overrides (Styling injected game sessions natively) ─── */
.drawer-mode .hero,
.drawer-mode .card-label,
.drawer-mode .section-title,
.drawer-mode img {
    display: none !important;
}

/* Remove outer card backgrounds to let the list items shine */
.drawer-mode>.card,
.drawer-mode>div>.card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Restyle session-card or inner cards into modern minimalist list items */
.drawer-mode .session-card,
.drawer-mode .studio-card,
.drawer-mode .party-card,
.drawer-mode .game-item {
    background: rgba(128, 128, 128, 0.04) !important;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08)) !important;
    border-radius: 20px !important;
    padding: 16px !important;
    margin-bottom: 12px !important;
    text-align: left !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

/* Compact buttons in drawer */
.drawer-mode .btn,
.drawer-mode .btn-cta,
.drawer-mode .btn-open {
    padding: 12px 16px !important;
    font-size: 0.8rem !important;
    border-radius: 14px !important;
    margin-top: 4px !important;
    width: auto !important;
    display: inline-flex !important;
}

/* Empty states */
.drawer-mode .empty,
.drawer-mode .empty-state {
    padding: 30px 20px !important;
    background: rgba(128, 128, 128, 0.02) !important;
    border: 2px dashed rgba(128, 128, 128, 0.1) !important;
    border-radius: 20px !important;
    text-align: center !important;
    margin-top: 10px !important;
}

/* ═══════════════════════════════════════════════════════
   LIGHT MODE OVERRIDES
   Fixes hardcoded dark-only values in game.css classes
═══════════════════════════════════════════════════════ */

/* Bottom nav */
[data-theme="light"] .app-nav,
[data-theme="light"] #app-nav,
[data-theme="light"] .bottom-nav {
    background: rgba(255, 255, 255, 0.95) !important;
    border-top-color: rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .nav-item {
    color: rgba(0, 0, 0, 0.4) !important;
}

/* Credits badge */
[data-theme="light"] .credits-badge {
    background: rgba(0, 0, 0, 0.05) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    color: var(--text) !important;
}

/* Top bar border */
[data-theme="light"] .top-bar {
    border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}

/* Code input */
[data-theme="light"] .code-input {
    background: #ffffff !important;
    border-color: #d1d5db !important;
    color: #111827 !important;
}

[data-theme="light"] .code-input::placeholder {
    color: #9ca3af !important;
}

/* Form inputs */
[data-theme="light"] .form-input,
[data-theme="light"] .form-select,
[data-theme="light"] .field-input,
[data-theme="light"] .field-select {
    background: #ffffff !important;
    border-color: #d1d5db !important;
    color: #111827 !important;
}

[data-theme="light"] .form-input::placeholder,
[data-theme="light"] .field-input::placeholder {
    color: #9ca3af !important;
}

[data-theme="light"] .form-select option,
[data-theme="light"] .field-select option {
    background: #ffffff !important;
    color: #111827 !important;
}

/* Mode cards */
[data-theme="light"] .mode-card {
    background: rgba(0, 0, 0, 0.02) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .mode-title {
    color: var(--text) !important;
}

[data-theme="light"] .mode-check {
    border-color: rgba(0, 0, 0, 0.2) !important;
}

/* Theme/pack buttons */
[data-theme="light"] .theme-btn,
[data-theme="light"] .pack-item {
    background: rgba(0, 0, 0, 0.03) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
    color: var(--muted) !important;
}

/* Toggle row */
[data-theme="light"] .toggle-row {
    background: rgba(0, 0, 0, 0.02) !important;
    border-color: rgba(0, 0, 0, 0.06) !important;
}

[data-theme="light"] .toggle-label {
    color: var(--text) !important;
}

[data-theme="light"] .toggle-track {
    background-color: rgba(0, 0, 0, 0.12) !important;
}

/* Buttons */
[data-theme="light"] .btn-secondary,
[data-theme="light"] .btn-cta-secondary {
    background: rgba(0, 0, 0, 0.04) !important;
    color: var(--text) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .btn-ghost,
[data-theme="light"] .btn-cta-ghost {
    background: rgba(0, 0, 0, 0.04) !important;
    color: var(--text) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

/* Cards */
[data-theme="light"] .glass-card,
[data-theme="light"] .card {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.06) !important;
}

/* help-opt */
[data-theme="light"] .help-opt {
    color: var(--text) !important;
}