/**
 * Find It - Game Styling
 * Mobile-first, arcade-clean, ultra-responsive design.
 */

:root {
    --fi-bg: #f9f9ff;
    --fi-surface: #ffffff;
    --fi-card: #ffffff;
    --fi-card-hover: #f1f5f9;
    --fi-border: #e2e8f0;
    --fi-border-cell: #cbd5e1;
    --fi-primary: #7c3aed;
    --fi-primary-hover: #6d28d9;
    --fi-accent: #7c3aed;
    --fi-success: #10b981;
    --fi-danger: #ef4444;
    --fi-text-main: #0f172a;
    --fi-text-muted: #64748b;
    --fi-font-digits: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --fi-font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Override Funquizo base layout main.container (which is constrained to max-width: 1000px) */
main.container {
    max-width: none !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Breadcrumbs in game view */
.breadcrumb-container,
.gh-breadcrumbs {
    padding: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 20px !important;
    font-size: 0.85rem;
    text-align: left;
    width: 100%;
}

.gh-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--fi-text-muted);
}

.gh-breadcrumbs a {
    color: var(--fi-text-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.gh-breadcrumbs a:hover {
    color: var(--fi-primary);
}

.gh-breadcrumbs span.current,
.breadcrumb-item.active {
    color: var(--fi-text-main);
    font-weight: 700;
}

/* Outer Shell Container - matches 1280px */
.gh-game-container {
    width: min(1280px, calc(100% - 48px));
    margin-inline: auto;
    padding: 0.5rem 0 3.5rem;
}

@media (max-width: 760px) {
    .gh-game-container {
        width: calc(100% - 14px);
    }
}

.findit-wrap,
.findit-wrap * {
    box-sizing: border-box;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.findit-wrap {
    user-select: none;
    -webkit-user-select: none;
    max-width: 540px;
    width: 100%;
    margin: 0 auto 3rem;
    min-height: auto;
    display: flex;
    flex-direction: column;
    padding: 0.6rem 0.85rem 1.25rem;
    position: relative;
}

/* ==========================================================================
   TOP HUD BAR
   ========================================================================== */
.findit-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--fi-surface);
    border: 1px solid var(--fi-border);
    border-radius: 16px;
    padding: 0.5rem 0.85rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

.hud-item {
    display: flex;
    flex-direction: column;
}

.hud-label {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--fi-text-muted);
    text-transform: uppercase;
}

.hud-val {
    font-size: 1.2rem;
    font-weight: 900;
    font-family: var(--fi-font-digits);
    color: var(--fi-text-main);
    line-height: 1.15;
}

.hud-timer-box {
    transition: transform 0.15s ease, color 0.15s ease;
}

.hud-timer--penalty .hud-val {
    color: var(--fi-danger) !important;
    animation: pulseRed 0.3s ease;
}

.hud-actions {
    flex-direction: row;
    gap: 0.4rem;
}

.findit-btn-icon {
    background: #f1f5f9;
    border: 1px solid var(--fi-border);
    color: var(--fi-text-main);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.findit-btn-icon:hover {
    background: #e2e8f0;
}

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

/* ==========================================================================
   INTERACTIVE GRID STAGE & COMPACT TARGET BAR (PLACED DIRECTLY ABOVE GRID)
   ========================================================================== */
.findit-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 100%;
}

/* Target bar sits directly on top of the grid with zero visual gap */
.findit-target-bar {
    width: 100%;
    max-width: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    background: #ffffff;
    border: 2px solid #ddd6fe;
    border-radius: 14px;
    padding: 0.45rem 1rem;
    margin-bottom: 0.45rem;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.08);
    transition: all 0.2s ease;
}

.target-bar--boss {
    background: linear-gradient(135deg, #fef2f2, #fffbeb);
    border-color: var(--fi-danger);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.25);
    animation: bossPulse 1.2s infinite alternate;
}

.target-bar-label {
    font-size: 0.85rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    color: var(--fi-accent);
    text-transform: uppercase;
}

.target-bar-val {
    color: var(--fi-accent);
    font-family: var(--fi-font-digits);
    font-size: 2.2rem;
    font-weight: 950;
    letter-spacing: 0.04em;
    line-height: 1;
}

.findit-grid-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: 64vh;
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s ease;
}

.findit-grid {
    display: grid;
    gap: 6px;
    width: 100%;
    height: 100%;
}

.color-shape-object {
    display: block;
    width: clamp(24px, 55%, 42px);
    aspect-ratio: 1;
    margin: auto;
    border-radius: 50%;
}
.color-shape-object--square { border-radius: 8%; }
.color-shape-object--rounded-square { border-radius: 28%; }
.color-shape-object--triangle { clip-path: polygon(50% 0%, 100% 100%, 0% 100%); border-radius: 0; }
.color-shape-object--oval { border-radius: 50% / 34%; }

/* Adaptive cell sizing: Max 4 digits guarantees massive readable numbers */
.grid-cell {
    background: var(--fi-card);
    border: 1.5px solid var(--fi-border-cell);
    border-radius: 12px;
    color: var(--fi-text-main);
    font-family: var(--fi-font-digits);
    font-weight: 850;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.1s ease, transform 0.08s ease, border-color 0.1s ease;
    padding: 0.2rem;
    width: 100%;
    height: 100%;
    overflow: hidden;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.04);
}

.grid-cell:hover {
    background: var(--fi-card-hover);
    border-color: #94a3b8;
}

.grid-cell:active {
    transform: scale(0.93);
}

.cell-text-lg {
    font-size: clamp(1.5rem, 6.5vw, 2.2rem);
    border-radius: 16px;
}

.cell-text-md {
    font-size: clamp(1.2rem, 4.8vw, 1.7rem);
    border-radius: 12px;
}

.cell-text-sm {
    font-size: clamp(0.95rem, 3.8vw, 1.35rem);
    border-radius: 10px;
    letter-spacing: 0.01em;
}

/* Hit states */
.cell--correct {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    border-color: #047857 !important;
    color: #fff !important;
    transform: scale(1.08);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
    z-index: 10;
}

.cell--wrong {
    background: #fee2e2 !important;
    border-color: var(--fi-danger) !important;
    color: #b91c1c !important;
    animation: cellVibrate 0.24s ease;
}

.grid-shake {
    animation: stageShake 0.28s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ==========================================================================
   FLOATING SPEED & PENALTY BADGES
   ========================================================================== */
.findit-floating-feedback {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.float-badge {
    position: absolute;
    transform: translate(-50%, -50%);
    font-weight: 900;
    font-family: var(--fi-font-digits);
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    font-size: 1.15rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    z-index: 50;
    animation: floatUp 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.float-badge--success {
    background: #10b981;
    color: #fff;
    border: 1px solid #34d399;
}

.float-badge--penalty {
    background: #ef4444;
    color: #fff;
    border: 1px solid #f87171;
}

/* ==========================================================================
   FULLSCREEN OVERLAYS (START & RESULT)
   ========================================================================== */
.findit-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13, 17, 23, 0.93);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.25rem;
    z-index: 100;
    overflow-y: auto;
}

.overlay-card {
    background: var(--fi-surface);
    border: 1px solid var(--fi-border);
    border-radius: 24px;
    padding: 2rem 1.6rem;
    max-width: 450px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.overlay-badge {
    display: inline-block;
    padding: 0.3rem 0.85rem;
    background: rgba(124, 58, 237, 0.2);
    border: 1px solid rgba(124, 58, 237, 0.5);
    color: #c4b5fd;
    font-size: 0.75rem;
    font-weight: 800;
    border-radius: 99px;
    letter-spacing: 0.08em;
    margin-bottom: 0.8rem;
}

.overlay-title {
    font-size: 2.1rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    margin-bottom: 0.6rem;
    background: linear-gradient(135deg, #fff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.overlay-desc {
    color: var(--fi-text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.4rem;
}

.overlay-rules {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.6rem;
}

.rule-chip {
    background: var(--fi-card);
    border: 1px solid var(--fi-border);
    padding: 0.35rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #e2e8f0;
}

.overlay-seed-box {
    margin-top: 1.2rem;
    font-size: 0.85rem;
    color: var(--fi-text-muted);
}

.btn-link {
    background: none;
    border: none;
    color: var(--fi-accent);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
}

/* ==========================================================================
   START OVERLAY - AUTH & PLAYER BANNER
   ========================================================================== */
.overlay-auth-box {
    border-radius: 16px;
    padding: 0.85rem 1.1rem;
    margin: 0 auto 1.35rem auto;
    text-align: center;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
}

/* Logged out state */
.overlay-auth-box--guest {
    border-color: rgba(234, 179, 8, 0.22);
    background: rgba(234, 179, 8, 0.04);
}

.overlay-auth-box--guest:hover {
    border-color: rgba(234, 179, 8, 0.38);
    background: rgba(234, 179, 8, 0.06);
}

.auth-box-title {
    font-size: 0.9rem;
    font-weight: 800;
    color: #f8fafc;
    letter-spacing: -0.01em;
    margin-bottom: 0.2rem;
}

.auth-box-sub {
    font-size: 0.82rem;
    color: #94a3b8;
    margin-bottom: 0.4rem;
    line-height: 1.35;
}

.auth-box-link {
    display: inline-block;
    font-size: 0.82rem;
    font-weight: 700;
    color: #c4b5fd;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.15s ease, transform 0.1s ease;
}

.auth-box-link:hover {
    color: #ffffff;
    transform: translateY(-1px);
}

/* Logged in state */
.overlay-auth-box--user {
    border-color: rgba(124, 58, 237, 0.35);
    background: rgba(124, 58, 237, 0.08);
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.12);
}

.auth-box-user-greeting {
    font-size: 1rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 0.25rem;
}

.auth-box-username {
    color: #c4b5fd;
}

.auth-box-user-pb {
    font-size: 0.84rem;
    font-weight: 600;
    color: #cbd5e1;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn-cta {
    width: 100%;
    padding: 1.05rem 1.4rem;
    border-radius: 16px;
    border: none;
    font-size: 1.05rem;
    font-weight: 900;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-cta--primary {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.35);
}

.btn-cta--primary:hover {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(124, 58, 237, 0.45);
}

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

.btn-cta--secondary {
    background: var(--fi-card);
    border: 1px solid var(--fi-border);
    color: var(--fi-text-main);
    margin-top: 0.6rem;
}

.btn-cta--secondary:hover {
    background: var(--fi-card-hover);
}

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

/* ==========================================================================
   RESULT SCREEN SPECIFICS
   ========================================================================== */
.overlay-card--result {
    max-width: 480px;
    padding: 1.8rem 1.5rem;
}

.result-badge {
    display: inline-block;
    padding: 0.3rem 0.9rem;
    border-radius: 99px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid #10b981;
    color: #34d399;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin-bottom: 0.4rem;
}

.result-time-hero {
    font-size: clamp(2.4rem, 8vw, 3.2rem);
    font-weight: 950;
    font-family: var(--fi-font-digits);
    color: #fff;
    letter-spacing: -0.02em;
    margin-bottom: 0.6rem;
    text-shadow: 0 0 30px rgba(124, 58, 237, 0.4);
}

/* Status Row: Personbästa & All-time */
.result-status-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 99px;
    padding: 0.4rem 0.9rem;
    margin: 0 auto 1.1rem;
    max-width: fit-content;
}

.status-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: var(--fi-text-muted);
}

.status-icon {
    font-size: 0.9rem;
}

.status-label {
    font-weight: 700;
}

.status-val {
    color: #facc15;
    font-weight: 900;
    font-family: var(--fi-font-digits);
}

.status-val--unregistered {
    color: #94a3b8;
    font-family: var(--fi-font-main);
    font-size: 0.78rem;
    font-weight: 700;
}

.status-divider {
    color: var(--fi-border);
    font-size: 0.7rem;
}

/* Start screen PB indicator */
.overlay-pb-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(250, 204, 21, 0.12);
    border: 1px solid rgba(250, 204, 21, 0.3);
    border-radius: 99px;
    padding: 0.35rem 0.85rem;
    font-size: 0.82rem;
    color: #fef08a;
    font-weight: 800;
    margin-bottom: 0.9rem;
}

/* ==========================================================================
   HIGH SCORE & LEADERBOARD CONVERSION CARD (Positioned right under result)
   ========================================================================== */
.result-highscore-box {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(124, 58, 237, 0.15));
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 18px;
    padding: 1.1rem 1.15rem;
    margin-bottom: 1.1rem;
    text-align: left;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.hs-head {
    margin-bottom: 0.65rem;
}

.hs-est-rank {
    display: block;
    font-size: 1.05rem;
    font-weight: 950;
    color: #fef08a;
    letter-spacing: -0.01em;
}

.hs-benchmark-box {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.65rem;
}

.hs-benchmark-badge {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.bm-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.82rem;
    color: #cbd5e1;
}

.bm-row--gap {
    margin-top: 0.15rem;
}

.bm-label {
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
}

.bm-time {
    font-family: var(--fi-font-digits);
    color: #38bdf8;
    font-size: 0.95rem;
    font-weight: 900;
}

.bm-tip {
    font-size: 0.82rem;
    color: #cbd5e1;
}

.bm-tip strong {
    color: #f59e0b;
    font-family: var(--fi-font-digits);
    font-weight: 900;
}

.bm-tip--ahead {
    color: #34d399;
}

.bm-tip--ahead strong {
    color: #6ee7b7;
}

.hs-sub {
    font-size: 0.8rem;
    color: #cbd5e1;
    line-height: 1.35;
    margin-bottom: 0.85rem;
}

.hs-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.btn-hs-register {
    display: block;
    width: 100%;
    background: #f59e0b;
    color: #0f172a;
    text-align: center;
    font-weight: 900;
    font-size: 0.92rem;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    text-decoration: none;
    transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.25);
}

.btn-hs-register:hover {
    background: #fbbf24;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.35);
}

.btn-hs-login {
    display: block;
    text-align: center;
    color: var(--fi-text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: underline;
    padding: 0.2rem;
}

.btn-hs-login:hover {
    color: #fff;
}

.result-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    background: var(--fi-bg);
    border: 1px solid var(--fi-border);
    border-radius: 14px;
    padding: 0.7rem 0.4rem;
    margin-bottom: 0.9rem;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--fi-text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 0.15rem;
}

.stat-val {
    font-size: 0.9rem;
    font-weight: 800;
    font-family: var(--fi-font-digits);
    color: var(--fi-text-main);
}

.result-actions {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.1rem;
}

/* ==========================================================================
   SPLITS CHIPS
   ========================================================================== */
.splits-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.35rem;
    margin-top: 0.4rem;
}

.split-chip {
    background: var(--fi-bg);
    border: 1px solid var(--fi-border);
    border-radius: 8px;
    padding: 0.3rem 0.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.7rem;
    font-family: var(--fi-font-digits);
}

.split-num {
    color: var(--fi-text-muted);
    font-size: 0.6rem;
}

.split-time {
    font-weight: 800;
    color: #cbd5e1;
}

.split-chip--fast .split-time {
    color: #34d399;
}

/* ==========================================================================
   ANIMATION KEYFRAMES
   ========================================================================== */
@keyframes floatUp {
    0% {
        opacity: 0;
        transform: translate(-50%, -20%) scale(0.85);
    }
    30% {
        opacity: 1;
        transform: translate(-50%, -70%) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -150%) scale(0.95);
    }
}

@keyframes stageShake {
    0%, 100% { transform: translate3d(0, 0, 0); }
    20%, 60% { transform: translate3d(-6px, 0, 0); }
    40%, 80% { transform: translate3d(6px, 0, 0); }
}

@keyframes cellVibrate {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

@keyframes pulseRed {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.18); }
}

@keyframes bossPulse {
    0% {
        box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
    }
    100% {
        box-shadow: 0 0 30px rgba(239, 68, 68, 0.85);
    }
}
