:root {
    --bg-dark: #0a0a1a;
    --accent-primary: #a8d8f0; /* Pastel Blue */
    --accent-secondary: #8b5cf6;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: fixed;
    width: 100%;
    background-image: url('bg-fox.png');
    background-size: cover;
    background-position: center;
    transition: background-image 1s ease;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom, rgba(10,10,26,0.3) 0%, rgba(10,10,26,0.75) 100%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 0;
}

#app {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    padding: 0 16px 16px;
    box-sizing: border-box;
    height: 100dvh;
    overflow: hidden;
}

/* Glassmorphism utilities */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.screen {
    display: none;
    animation: fadeIn 0.35s ease forwards;
}
.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    overflow-y: auto;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

h1 { font-size: clamp(1.5rem, 6vw, 2rem); font-weight: 700; text-align: center; margin-bottom: 1rem; }
h2 { font-size: 1.4rem; color: var(--accent-primary); margin-bottom: 0.5rem; }
p { text-align: center; color: var(--text-muted); line-height: 1.6; }

/* Header / Nav */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    margin-bottom: 12px;
    flex-shrink: 0;
}
.logo { font-weight: 800; font-size: 1.1rem; color: var(--accent-primary); letter-spacing: 1px; }
.nav-icons { display: flex; gap: 10px; align-items: center; }
.nav-btn {
    position: relative;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
}
.nav-btn:hover, .nav-btn.active {
    background: var(--accent-primary);
    color: var(--bg-dark);
}

/* Badge compteur ♥ */
.nav-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #f59e0b;
    color: #000;
    border-radius: 10px;
    font-size: 0.6rem;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    box-sizing: border-box;
    display: none;
    animation: badgePop 0.3s cubic-bezier(0.28, 0.84, 0.42, 1);
}
@keyframes badgePop {
    0% { transform: scale(0); }
    70% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.lang-btn {
    font-size: 1.1rem;
    background: none; border: none; cursor: pointer; opacity: 0.7;
    transition: opacity 0.2s;
}
.lang-btn:hover { opacity: 1; }

/* Input & Buttons */
input[type="text"] {
    width: 100%;
    padding: 14px 18px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: rgba(0,0,0,0.25);
    color: white;
    font-size: 1.05rem;
    margin-bottom: 16px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
input[type="text"]:focus {
    border-color: var(--accent-primary);
}
input[type="text"]::placeholder { color: rgba(255,255,255,0.35); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #e6c888);
    color: var(--bg-dark);
    font-weight: 700;
    font-size: 1.05rem;
    border: none;
    padding: 15px 30px;
    border-radius: 30px;
    cursor: pointer;
    width: 100%;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 20px rgba(168, 216, 240, 0.3);
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:hover { box-shadow: 0 6px 28px rgba(168, 216, 240, 0.5); }

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    margin-top: 12px;
    transition: background 0.2s, color 0.2s;
    font-size: 0.95rem;
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-main);
}

/* ── Card ───────────────────────────────────────────── */
#screen-random {
    padding: 0;
    gap: 10px;
}

.name-card {
    position: relative;
    width: 100%;
    max-width: 380px;
    /* Height fills available space between header and progress bar */
    flex: 1;
    min-height: 0;
    text-align: center;
    perspective: 1200px;
    margin: 0 auto;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
    transform-style: preserve-3d;
}

.name-card.is-flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    padding: 44px 20px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* glass directly on face — but use -webkit-backdrop on front only */
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}

/* Only apply backdrop blur on front (avoids Safari 3D bug on back face) */
.card-front {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.card-back {
    transform: rotateY(180deg);
    justify-content: flex-start;
    padding-top: 54px;
}

.extended-desc {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-main);
    text-align: left;
    margin-bottom: 10px;
    width: 100%;
}

.btn-info {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-main);
    border-radius: 50%;
    width: 30px; height: 30px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: background 0.2s;
    flex-shrink: 0;
}
.btn-info:hover { background: rgba(255,255,255,0.25); }

.name-large {
    font-size: clamp(2.2rem, 12vw, 3.8rem);
    font-weight: 800;
    margin: 6px 0 4px;
    color: white;
    line-height: 1.1;
    word-break: break-word;
}
.name-phonetic {
    color: var(--accent-primary);
    font-family: monospace;
    font-size: 1rem;
    margin-bottom: 14px;
    min-height: 1.2em;
}
.name-meta {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Stars */
.stars-container {
    display: flex;
    gap: 6px;
    margin-top: 16px;
    margin-bottom: 8px;
}
.star {
    font-size: clamp(1.8rem, 8vw, 2.4rem);
    color: rgba(255,255,255,0.2);
    cursor: pointer;
    transition: transform 0.15s, color 0.15s, filter 0.15s;
    user-select: none;
    -webkit-user-select: none;
}
@media (hover: hover) {
    .star:hover {
        transform: scale(1.3);
        filter: drop-shadow(0 0 8px gold);
    }
}
.star.active { color: #ffd700; transform: scale(1.2); filter: drop-shadow(0 0 6px gold); }

/* Progress */
.progress-bar {
    width: 100%;
    height: 5px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), #e6c888);
    width: 0%;
    transition: width 0.4s ease;
}
.progress-text { margin: 6px 0 0; font-size: 0.82rem; color: var(--text-muted); }

/* Tags */
.tag {
    background: rgba(255,255,255,0.1);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
    white-space: nowrap;
}

/* List views */
.names-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.07);
}
.list-name { font-size: 1.1rem; font-weight: 600; }
.mini-stars { display: flex; gap: 4px; }
.mini-star { font-size: 1.1rem; color: rgba(255,255,255,0.2); cursor: pointer; transition: color 0.1s; }
.mini-star.active { color: #ffd700; }

/* Star Animations - Base set */
@keyframes star-fall {
    0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translateY(40px) rotate(60deg) scale(0.5); opacity: 0; }
}
@keyframes star-shake {
    0%, 100% { transform: translateX(0) rotate(0); }
    20% { transform: translateX(-6px) rotate(-10deg); }
    40% { transform: translateX(6px) rotate(10deg); }
    60% { transform: translateX(-4px) rotate(-6deg); }
    80% { transform: translateX(4px) rotate(6deg); }
}
@keyframes star-nod {
    0%, 100% { transform: translateY(0) scale(1); }
    30% { transform: translateY(-6px) scale(1.1); }
    60% { transform: translateY(3px) scale(0.95); }
}
@keyframes star-bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    40% { transform: translateY(-18px) scale(1.15); }
    70% { transform: translateY(-6px) scale(1.05); }
}
@keyframes star-pulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 4px gold); }
    50% { transform: scale(1.4); filter: drop-shadow(0 0 16px gold); }
}
@keyframes star-explode {
    0% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 0px gold); }
    30% { transform: scale(1.6) rotate(90deg); filter: drop-shadow(0 0 20px gold); }
    60% { transform: scale(0.9) rotate(200deg); filter: drop-shadow(0 0 30px #ffd700); }
    100% { transform: scale(1.2) rotate(360deg); filter: drop-shadow(0 0 10px gold); }
}
@keyframes star-celebrate {
    0% { transform: scale(1) rotate(0); }
    15% { transform: scale(1.5) rotate(-15deg); filter: drop-shadow(0 0 20px #ff6b6b); }
    30% { transform: scale(1.3) rotate(10deg); filter: drop-shadow(0 0 25px #ffd700); }
    50% { transform: scale(1.6) rotate(-8deg) translateY(-8px); filter: drop-shadow(0 0 30px #a8d8f0); }
    70% { transform: scale(1.2) rotate(5deg) translateY(4px); }
    100% { transform: scale(1.2) rotate(0); filter: drop-shadow(0 0 8px gold); }
}

/* Star Animations - Extended creative set */
@keyframes star-spin {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.3); filter: drop-shadow(0 0 12px #ffd700); }
    100% { transform: rotate(360deg) scale(1); }
}
@keyframes star-heartbeat {
    0%, 100% { transform: scale(1); }
    14% { transform: scale(1.3); }
    28% { transform: scale(1); }
    42% { transform: scale(1.4); filter: drop-shadow(0 0 18px #ff4d88); }
    70% { transform: scale(1.1); }
}
@keyframes star-rainbow {
    0%   { filter: drop-shadow(0 0 8px #ff0000); }
    16%  { filter: drop-shadow(0 0 8px #ff8800); }
    33%  { filter: drop-shadow(0 0 8px #ffff00); }
    50%  { filter: drop-shadow(0 0 12px #00ff00); }
    66%  { filter: drop-shadow(0 0 8px #0088ff); }
    83%  { filter: drop-shadow(0 0 8px #8800ff); }
    100% { filter: drop-shadow(0 0 12px #ffd700); }
}
@keyframes star-ripple {
    0%   { transform: scale(1); opacity: 1; }
    25%  { transform: scale(1.5); opacity: 0.8; }
    50%  { transform: scale(0.9); opacity: 1; }
    75%  { transform: scale(1.3); opacity: 0.9; }
    100% { transform: scale(1.1); opacity: 1; }
}
@keyframes star-firework {
    0%   { transform: scale(0.5) translateY(20px); opacity: 0; }
    40%  { transform: scale(1.6) translateY(-8px); opacity: 1; filter: drop-shadow(0 0 24px #ffd700); }
    70%  { transform: scale(0.9) translateY(4px); }
    100% { transform: scale(1.2) translateY(0); filter: drop-shadow(0 0 10px gold); }
}
@keyframes star-spiral {
    0%   { transform: scale(0) rotate(0deg) translateX(0); opacity: 0; }
    50%  { transform: scale(1.3) rotate(180deg) translateX(5px); opacity: 1; filter: drop-shadow(0 0 16px #ffd700); }
    100% { transform: scale(1) rotate(360deg) translateX(0); }
}
@keyframes star-glitch {
    0%   { transform: translate(0); filter: drop-shadow(0 0 0 transparent); }
    10%  { transform: translate(-3px, 2px); filter: drop-shadow(3px 0 0 #ff00ff); }
    20%  { transform: translate(3px, -2px); filter: drop-shadow(-3px 0 0 #00ffff); }
    30%  { transform: translate(-2px, 1px) scale(1.1); filter: drop-shadow(0 0 12px gold); }
    40%  { transform: translate(2px, -1px); }
    50%  { transform: translate(0) scale(1.2); filter: drop-shadow(0 0 20px #ffd700); }
    100% { transform: translate(0) scale(1.1); filter: drop-shadow(0 0 8px gold); }
}
@keyframes star-boing {
    0%   { transform: scaleX(1)   scaleY(1); }
    25%  { transform: scaleX(1.4) scaleY(0.6); }
    50%  { transform: scaleX(0.8) scaleY(1.4); }
    75%  { transform: scaleX(1.2) scaleY(0.9); }
    100% { transform: scaleX(1)   scaleY(1.15); filter: drop-shadow(0 0 8px gold); }
}
@keyframes star-flip3d {
    0%   { transform: perspective(200px) rotateY(0deg) scale(1); }
    30%  { transform: perspective(200px) rotateY(90deg) scale(1.2); filter: drop-shadow(0 0 16px #ffd700); }
    60%  { transform: perspective(200px) rotateY(200deg) scale(1.1); }
    100% { transform: perspective(200px) rotateY(360deg) scale(1.15); }
}
@keyframes star-confetti {
    0%   { transform: scale(1) rotate(0deg); }
    20%  { transform: scale(1.8) rotate(-20deg); filter: drop-shadow(0 0 30px #ff6b6b); }
    40%  { transform: scale(1.4) rotate(15deg) translateY(-10px); filter: drop-shadow(0 0 25px #ffd700); }
    60%  { transform: scale(1.6) rotate(-10deg) translateY(-6px); filter: drop-shadow(0 0 30px #a8d8f0); }
    80%  { transform: scale(1.3) rotate(8deg) translateY(-3px); filter: drop-shadow(0 0 20px #8b5cf6); }
    100% { transform: scale(1.2) rotate(0deg); filter: drop-shadow(0 0 12px gold); }
}

/* Animation classes */
.anim-fall     { animation: star-fall     0.5s forwards; }
.anim-shake    { animation: star-shake    0.45s ease-in-out; }
.anim-nod      { animation: star-nod      0.4s ease-in-out; }
.anim-bounce   { animation: star-bounce   0.5s cubic-bezier(0.28, 0.84, 0.42, 1); }
.anim-pulse    { animation: star-pulse    0.5s ease-in-out; }
.anim-explode  { animation: star-explode  0.7s cubic-bezier(0.28, 0.84, 0.42, 1) forwards; }
.anim-celebrate{ animation: star-celebrate 0.8s cubic-bezier(0.28, 0.84, 0.42, 1) forwards; }
.anim-spin     { animation: star-spin     0.6s cubic-bezier(0.28, 0.84, 0.42, 1); }
.anim-heartbeat{ animation: star-heartbeat 0.7s ease-in-out; }
.anim-rainbow  { animation: star-rainbow  0.8s linear; }
.anim-ripple   { animation: star-ripple   0.5s ease-in-out; }
.anim-firework { animation: star-firework 0.6s cubic-bezier(0.28, 0.84, 0.42, 1) forwards; }
.anim-spiral   { animation: star-spiral   0.7s cubic-bezier(0.28, 0.84, 0.42, 1) forwards; }
.anim-glitch   { animation: star-glitch   0.6s steps(1) forwards; }
.anim-boing    { animation: star-boing    0.5s cubic-bezier(0.28, 0.84, 0.42, 1); }
.anim-flip3d   { animation: star-flip3d   0.6s cubic-bezier(0.28, 0.84, 0.42, 1) forwards; }
.anim-confetti { animation: star-confetti 0.9s cubic-bezier(0.28, 0.84, 0.42, 1) forwards; }
