/* Fredoka (SIL Open Font License, see /fonts/OFL.txt), self-hosted so the CSP can stay at 'self'. */
@font-face {
    font-family: "Fredoka";
    src: url("../fonts/fredoka-latin-wght-normal.woff2") format("woff2");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --game-bg-1: #1b1446;
    --game-bg-2: #3a1f7a;
    --game-text: #ffffff;
    --game-text-soft: rgba(255, 255, 255, 0.78);
    --game-text-dark: #241b4d;
    --game-surface: #ffffff;
    --game-surface-soft: rgba(255, 255, 255, 0.12);
    --game-surface-glass: rgba(255, 255, 255, 0.1);
    --game-yellow: #ffd23f;
    --game-orange: #ff8a00;
    --game-pink: #ff4d8d;
    --game-purple: #7c4dff;
    --game-cyan: #2ee6d6;
    --game-green: #22c55e;
    --tabbar-height: 4.4rem;
    color-scheme: dark;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
    font-size: 1.08rem;
    color: var(--game-text);
    background-color: var(--game-bg-1);
    background-image:
        radial-gradient(2px 2px at 20% 30%, #fff 50%, transparent 51%),
        radial-gradient(1.5px 1.5px at 70% 15%, #fff 50%, transparent 51%),
        radial-gradient(2px 2px at 85% 60%, #ffe9a8 50%, transparent 51%),
        radial-gradient(1.5px 1.5px at 40% 80%, #fff 50%, transparent 51%),
        radial-gradient(1px 1px at 55% 45%, #fff 50%, transparent 51%),
        radial-gradient(1px 1px at 10% 90%, #fff 50%, transparent 51%),
        radial-gradient(ellipse at top, var(--game-bg-2), var(--game-bg-1) 70%);
    background-size: 380px 380px, 290px 290px, 450px 450px, 330px 330px, 210px 210px, 260px 260px, 100% 100%;
    background-attachment: fixed;
}

h1, h2, h3, h4, h5 {
    font-weight: 700;
}

h1:focus {
    outline: none;
}

a {
    color: var(--game-yellow);
}

a:hover {
    color: #ffe27a;
}

:focus-visible {
    outline: 3px solid var(--game-yellow);
    outline-offset: 2px;
}

/* Boot splash shown until the interactive app has rendered */
.boot-splash {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 1.2rem;
    color: var(--game-text-soft);
}

.boot-splash img {
    animation: boot-bob 1.4s ease-in-out infinite;
}

body:has(.app-shell) .boot-splash {
    display: none;
}

@keyframes boot-bob {
    0%, 100% {
        translate: 0 0;
    }

    50% {
        translate: 0 -10px;
    }
}

/* Layout */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem max(1rem, env(safe-area-inset-right)) 0.55rem max(1rem, env(safe-area-inset-left));
    background: rgba(27, 20, 70, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar-logo {
    text-decoration: none;
}

.player-chips {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.chip {
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: var(--game-surface-glass);
    white-space: nowrap;
}

.chip-level {
    background: var(--game-purple);
}

.chip-stars {
    color: #2a1a00;
    background: var(--game-yellow);
}

.chip-streak {
    background: var(--game-orange);
}

.app-main {
    flex: 1 0 auto;
    width: 100%;
    max-width: 62rem;
    margin: 0 auto;
    padding: 1.25rem 1rem calc(var(--tabbar-height) + 1.5rem);
}

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-around;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(27, 20, 70, 0.95);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.tabbar .tab {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    color: var(--game-text-soft);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
}

.tabbar .tab-icon {
    font-size: 1.5rem;
    line-height: 1;
    transition: transform 0.15s;
}

.tabbar .tab.active {
    color: var(--game-yellow);
}

.tabbar .tab.active .tab-icon {
    transform: scale(1.2) translateY(-2px);
}

@media (min-width: 768px) {
    .tabbar {
        left: 50%;
        right: auto;
        bottom: 1rem;
        translate: -50% 0;
        width: 34rem;
        border-radius: 999px;
        border: 1px solid rgba(255, 255, 255, 0.15);
        padding-bottom: 0;
        height: var(--tabbar-height);
    }
}

/* Cards and headings */
.card-game {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 1.75rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.page-title {
    font-size: clamp(1.8rem, 7vw, 2.4rem);
    margin-bottom: 0.3rem;
}

.page-intro {
    color: var(--game-text-soft);
    margin-bottom: 1rem;
}

.secret-code {
    display: inline-block;
    font-size: clamp(1.6rem, 8vw, 2.5rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #2a1a00;
    background: var(--game-yellow);
    border-radius: 1rem;
    padding: 0.45rem 1rem;
    user-select: all;
}

.error-page {
    max-width: 30rem;
    margin: 2rem auto;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 0.25rem;
}

.error-id {
    color: var(--game-text-soft);
    font-size: 0.9rem;
}

/* Buttons */
.btn-game {
    font-family: inherit;
    font-weight: 700;
    font-size: 1.15rem;
    border: none;
    border-radius: 1.2rem;
    padding: 0.7rem 1.3rem;
    color: #fff;
    transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
    touch-action: manipulation;
}

.btn-game:hover {
    filter: brightness(1.08);
    color: #fff;
}

.btn-game:active {
    transform: translateY(4px);
}

.btn-game:disabled {
    opacity: 0.55;
}

.btn-game-xl {
    font-size: 1.4rem;
    padding: 0.9rem 1.5rem;
}

.btn-game-primary {
    background: linear-gradient(180deg, #ff6aa2, var(--game-pink));
    box-shadow: 0 5px 0 #c2245f;
}

.btn-game-primary:active {
    box-shadow: 0 1px 0 #c2245f;
}

.btn-game-secondary {
    background: linear-gradient(180deg, #9b78ff, var(--game-purple));
    box-shadow: 0 5px 0 #4f2bc2;
}

.btn-game-secondary:active {
    box-shadow: 0 1px 0 #4f2bc2;
}

.btn-game-gold {
    color: #3b2600;
    background: linear-gradient(180deg, #ffe27a, var(--game-yellow));
    box-shadow: 0 5px 0 #c99a00;
}

.btn-game-gold:hover {
    color: #3b2600;
}

.btn-game-gold:active {
    box-shadow: 0 1px 0 #c99a00;
}

.btn-game-danger {
    background: linear-gradient(180deg, #ff7a7a, #e5383b);
    box-shadow: 0 5px 0 #a4161a;
}

.btn-game-ghost {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.35);
}

.link-game {
    color: var(--game-text-soft);
    text-decoration: none;
}

.link-game:hover {
    color: #fff;
}

/* Filters */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}

.filter-btn {
    font-family: inherit;
    font-weight: 600;
    border: 2px solid rgba(255, 255, 255, 0.25);
    background: transparent;
    color: var(--game-text);
    border-radius: 999px;
    padding: 0.3rem 0.85rem;
    min-width: 2.6rem;
}

.filter-btn.active {
    background: var(--game-yellow);
    border-color: var(--game-yellow);
    color: #2a1a00;
}

/* Forms */
.game-input {
    font-family: inherit;
    font-weight: 600;
    border-radius: 1rem;
    border: 3px solid transparent;
    background: #fff;
    color: var(--game-text-dark);
}

.game-input:focus {
    border-color: var(--game-yellow);
    box-shadow: none;
    background: #fff;
    color: var(--game-text-dark);
}

.code-input {
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.alert-game {
    margin: 0.8rem 0 0;
    padding: 0.6rem 0.9rem;
    border-radius: 1rem;
    background: rgba(255, 77, 141, 0.18);
    border: 2px solid var(--game-pink);
}

/* Progress bars (native element, no inline styles needed) */
.game-progress {
    appearance: none;
    display: block;
    width: 100%;
    height: 1rem;
    border: none;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.15);
}

.game-progress::-webkit-progress-bar {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
}

.game-progress::-webkit-progress-value {
    background: linear-gradient(90deg, var(--game-cyan), var(--game-purple), var(--game-pink));
    border-radius: 999px;
}

.game-progress::-moz-progress-bar {
    background: linear-gradient(90deg, var(--game-cyan), var(--game-purple), var(--game-pink));
    border-radius: 999px;
}

.goal-progress::-webkit-progress-value {
    background: linear-gradient(90deg, var(--game-yellow), var(--game-orange));
}

.goal-progress::-moz-progress-bar {
    background: linear-gradient(90deg, var(--game-yellow), var(--game-orange));
}

/* Confetti canvas created by js/effects.js */
.confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 2000;
}

/* Blazor error UI */
#blazor-error-ui {
    color-scheme: light only;
    background: #ffe27a;
    color: #2a1a00;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.8rem 1.25rem 0.9rem;
    position: fixed;
    width: 100%;
    z-index: 3000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
    .boot-splash img {
        animation: none;
    }

    .btn-game:active {
        transform: none;
    }
}
