/* Global Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #000;
    color: #fff;
    height: 100vh;
    width: 100vw;
    overflow: auto; /* allow viewport resize on mobile keyboard */
    overflow-x: hidden; /* block horizontal scroll */
    position: relative; /* don't fix body - let browser handle viewport changes */
}

/* Hint to supporting browsers to avoid overscroll chaining / pull-to-refresh */
html, body { overscroll-behavior-y: none; overflow-x: hidden; }

/* Main App Container */
.app-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
    overflow-x: hidden;
    max-width: 100vw;
    touch-action: pan-y;
}

/* Video Placeholder (simulate live stream) */
.video-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    opacity: 0.6; /* Dim video slightly for text readability */
}

/* Top Bar */
.top-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 16px 20px;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%);
}

/* Admin view: move profile icon to left and push brand slightly right on mobile */
.top-bar.admin-view .profile-link {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.top-bar.admin-view .brand-logo {
    margin-left: 40px; /* make room for the avatar */
    font-size: 12px; /* slightly smaller for admin */
    height: 36px; /* match avatar height */
    display: inline-flex;
    align-items: center; /* vertically center text next to avatar */
}

/* Ensure top-bar-right contents are shifted a bit to avoid overlap on very small screens */
@media (max-width: 420px) {
    .top-bar.admin-view .brand-logo { margin-left: 44px; }
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
    color: white;
    text-decoration: none;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Profile Link (Avatar top right) */
.profile-link {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.0);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.0);
    text-decoration: none;
    color: white;
}

.profile-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Viewer Count */
.viewer-count {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.viewer-count .icon {
    color: #fe2c55; /* TikTok red/pink */
}

/* Chat Panel - Overlay su Video */
.chat-panel {
    position: absolute;
    bottom: 28px; /* Closer to input bar */
    left: 0;
    width: 100%;
    max-width: 100vw;
    padding: 0 16px;
    z-index: 10;
    max-height: 300px; /* Limit height for messages */
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none; /* Let clicks pass through to video if not on message */
    transition: bottom 0.2s ease-out; /* Smooth movement when keyboard opens */
    overflow-x: hidden;
}

.chat-messages-overlay {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(3 * 90px); /* Show up to 3 messages at a time */
    pointer-events: auto; /* Re-enable clicks on messages */
    mask-image: linear-gradient(to top, black 80%, transparent 100%);
    -webkit-mask-image: linear-gradient(to top, black 80%, transparent 100%);
    touch-action: pan-y;
    -ms-touch-action: pan-y;
}

/* When keyboard/emoji is open, this class will be added via JS */
.chat-panel.shifted-up {
    bottom: 190px; /* Closer to keyboard-adjusted input */
}

/* STILE TUO — NON RIMUOVERE */
.welcome-message {
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    padding: 12px;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    text-align: center;

    /* AGGIUNTA PER CENTRARLA */
    align-self: center;

    /* AGGIUNTA PER ANIMAZIONE */
    animation: welcomeFade 6.0s ease-out forwards;
}

.welcome-message p {
    margin: 4px 0;
}

/* ANIMAZIONE */
@keyframes welcomeFade {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
    70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: scale(0.95);
    }
}



/* ===== PINNED MESSAGE (TikTok Style) ===== */
.pinned-message {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 24px);
    max-width: 600px;
    z-index: 80;
    animation: pinned-slide-down 0.3s ease-out;
}

@keyframes pinned-slide-down {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.pinned-message.hiding {
    animation: pinned-slide-up 0.3s ease-out forwards;
}

@keyframes pinned-slide-up {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

.pinned-content {
    background: rgba(254, 44, 85, 0.15);
    backdrop-filter: blur(12px);
    border: 2px solid rgba(254, 44, 85, 0.4);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pinned-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.pinned-message-body {
    flex: 1;
    min-width: 0;
}

.pinned-username {
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 2px;
}

.pinned-text {
    font-size: 13px;
    color: #fff;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
}

.pinned-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
    padding: 0;
}

.pinned-close:hover,
.pinned-close:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Chat Message (TikTok Style) */
.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: slideInBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 90%;
    touch-action: pan-y;
}

@keyframes slideInBounce {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    60% {
        transform: translateY(-5px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    /* Allow full width so chat-overlay-poc.css controls the constraint via .chat-message */
    max-width: 100%;
    /* Ensure the flex child (bubble) can shrink below its content width when needed */
    min-width: 0;
}

.msg-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
    flex-shrink: 0;
}

.msg-avatar-placeholder {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message-bubble {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 4px 6px;
    border-radius: 0;
    border: none;
    margin-bottom: 2px;
    position: relative;
    display: inline-block;
    /* Prefer to grow and avoid shrinking when layout is tight */
    flex: 1 0 auto; /* grow:1, shrink:0, basis:auto */
    /* Increase max-width so messages can hold more text before wrapping */
    max-width: min(85vw, 600px);
    min-width: 0;
    vertical-align: top;
    white-space: normal;
    overflow-x: hidden;
    word-wrap: break-word;
}

.message-bubble .username {
    color: #fe2c55;
    font-weight: 700;
    font-size: 13px;
    display: block;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-bubble .message-text {
    color: rgba(255,255,255,0.95);
    font-size: 15px;
    line-height: 1.5;
    display: block;
    white-space: pre-wrap;
    overflow-x: hidden;
    overflow-y: visible;
    word-break: break-word;
    overflow-wrap: anywhere;
    text-overflow: clip;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

/* Evidenziazione parole di interesse (es. "mio") */
.interest-highlight {
    color: #FFD700;
    font-weight: 700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

/* Marquee helper (optional): apply only to long, single-line messages */
.message-bubble .message-text.marquee{ overflow: hidden; white-space: nowrap; }
.message-bubble .message-text.marquee .marquee-inner{ display:inline-block; white-space:nowrap; will-change: transform; animation: chat-marquee var(--marquee-duration, 8s) linear infinite; }
.message-bubble .message-text.marquee:hover .marquee-inner{ animation-play-state: paused; }

@keyframes chat-marquee{
    from { transform: translateX(0); }
    to { transform: translateX(calc(-1 * var(--marquee-translation, 100%))); }
}

/* Messaggio di interesse (con badge stella) — rimosso lo stile speciale (nessun bordo/gradiente rosso) */

.interest-badge { display:none; }

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* ===== CHAT INPUT TIKTOK STYLE ===== */
.chat-input-overlay {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-input-overlay.fixed-top {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(20px);
    /* Add safe-area inset so controls don't sit under soft nav bars */
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 12px));
    z-index: 200;
    border-top: 1px solid rgba(255,255,255,0.1);
    box-sizing: border-box;
}

.message-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 6px 10px; /* increased to give more vertical space */
    border: 1px solid rgba(255,255,255,0.06);
    min-height: 48px; /* keep controls vertically centered across devices */
    box-sizing: border-box;
}

.message-input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 15px;
    padding: 10px 0;
    outline: none;
    line-height: 20px; /* consistent vertical alignment */
    min-height: 32px;
}

.message-input-wrapper input::placeholder {
    color: rgba(255,255,255,0.6);
}

.share-btn-inline {
    width: 44px;
    height: 44px;
    background: transparent; /* no white background */
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.14s ease, background 0.14s ease;
    flex-shrink: 0;
}
.send-button, .share-btn-inline, .emoji-btn {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

/* Leaderboard overlay styles */
.leaderboard-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  z-index: 9999;
  animation: lb-fade-in .22s ease;
}
.leaderboard-card {
  width: min(720px, 94%);
  background: #fff;
  color: #111;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 18px 60px rgba(0,0,0,.45);
  transform: translateY(6px);
  animation: lb-slide-up .32s cubic-bezier(.2,.8,.2,1);
  overflow: hidden;
}
.leaderboard-header h2 { margin:0; font-size:20px; color:#111; }
.leaderboard-list { margin-top:12px; }
.leaderboard-item { display:flex; align-items:center; gap:12px; padding:10px 6px; border-bottom:1px solid #f1f1f1; }
.leaderboard-item:last-child { border-bottom:0; }
.rank { width:44px; font-weight:800; color:#333; text-align:center; }
.avatar { width:48px; height:48px; border-radius:50%; object-fit:cover; border:2px solid #fff; box-shadow:0 4px 10px rgba(0,0,0,.12); }
.meta { flex:1; min-width:0; }
.name { font-weight:700; color:#222; font-size:15px; }
.progress { width:100%; height:8px; background:#f3f3f3; border-radius:999px; margin-top:6px; overflow:hidden; }
.progress-fill {
  height:100%;
  background: linear-gradient(90deg, #ff4b6e 0%, #b07cff 100%);
  transition: width .6s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 4px 10px rgba(176,124,255,0.12);
}
.likes { min-width:72px; text-align:right; font-weight:800; color:#ff4b6e; }
.leaderboard-actions { margin-top:12px; text-align:right; }
.btn { padding:8px 12px; border-radius:8px; background:#222; color:#fff; border:none; cursor:pointer; }
.leaderboard-item.medal-gold .rank::after{ content:" 🏅"; margin-left:6px; }
.leaderboard-item.medal-silver .rank::after{ content:" 🥈"; margin-left:6px; }
.leaderboard-item.medal-bronze .rank::after{ content:" 🥉"; margin-left:6px; }

@keyframes lb-slide-up { from { transform: translateY(12px); opacity:0 } to { transform: translateY(0); opacity:1 } }
@keyframes lb-fade-in { from { opacity:0 } to { opacity:1 } }

/* responsive tweaks */
@media (max-width:520px) {
  .leaderboard-card { padding:12px; border-radius:10px; }
  .name { font-size:14px; }
  .rank { width:36px; }
  .avatar { width:40px; height:40px; }
}

.share-btn-inline:hover {
    background: rgba(254,44,85,0.06);
    transform: scale(1.05);
}

.share-btn-inline:active {
    transform: scale(0.95);
}

.emoji-btn {
    width: 44px;
    height: 44px;
    background: transparent; /* no white background */
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.14s ease, background 0.14s ease;
    flex-shrink: 0;
    font-size: 18px;
}

.emoji-btn:hover {
    background: rgba(254,44,85,0.06);
    transform: scale(1.05);
}

.emoji-btn:active {
    transform: scale(0.95);
}

.emoji-btn.active {
    background: rgba(254,44,85,0.18);
    border-color: rgba(254,44,85,0.4);
}

/* ===== EMOJI PANEL ===== */
.emoji-panel {
    position: fixed;
    bottom: 100%;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 150;
    display: none;
    padding: 12px;
}

.emoji-panel.show {
    display: block;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 8px;
    max-height: 160px;
    overflow-y: auto;
}

.emoji-item {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.emoji-item:hover {
    background: rgba(255,255,255,0.1);
}

.emoji-item:active {
    background: rgba(255,255,255,0.2);
    transform: scale(0.9);
}

.vci-emoji-footer {
    padding-top: 8px;
    margin-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: flex-end;
}

.vci-backspace {
    font-size: 20px;
    width: 48px;
    height: 38px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    border-radius: 8px;
    cursor: pointer;
}

.vci-backspace:hover {
    background: rgba(255,255,255,0.2);
}

.vci-backspace:active {
    background: rgba(255,255,255,0.3);
    transform: scale(0.95);
}

/* ===== ANIMAZIONI SPECIALI EMOJI ===== */
.animations-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}


.flying-heart {
    position: absolute;
    bottom: 20%;
    font-size: 32px;
    animation: flyUp 3s ease-out forwards;
    pointer-events: none;
    z-index: 101;
}

@keyframes flyUp {
    0% {
        bottom: 20%;
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        bottom: 80%;
        opacity: 0;
        transform: scale(0.8) rotate(-20deg);
    }
}

/* Animated emoji overlay (APNG / animated WebP / GIF) */
.animated-emoji {
    position: absolute;
    left: 50%;
    bottom: 25%;
    transform: translateX(-50%) translateY(0);
    width: 120px;
    height: auto;
    pointer-events: none;
    z-index: 101;
    opacity: 0;
    transition: opacity 120ms ease-in;
    animation: animatedEmojiFloat 2.2s ease-out forwards;
}

/* Centered small variant for greetings */
.animated-emoji.center-hello {
    width: 96px; /* ridotta */
    left: 50%;
    bottom: 50%;
    transform: translate(-50%, -50%);
    z-index: 10050; /* portala sopra quasi tutto */
    animation: animatedEmojiFloatCenter 1.9s ease-out forwards;
}

@keyframes animatedEmojiFloat {
    0% {
        transform: translateX(-50%) translateY(0) scale(1);
        opacity: 1;
    }
    60% {
        transform: translateX(-50%) translateY(-90px) scale(1.05);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) translateY(-160px) scale(0.9);
        opacity: 0;
    }
}

@keyframes animatedEmojiFloatCenter {
    0% {
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 1;
    }
    70% {
        transform: translate(-50%, -95%) scale(1.02);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -140%) scale(0.95);
        opacity: 0;
    }
}

/* Smaller heart variant when shown near action buttons */
.animated-emoji.heart-like {
    width: 48px; /* ridotta per evitare che sia troppo grande */
    height: auto;
    transition: opacity 80ms ease-in;
    animation: animatedEmojiFloatSmall 1.6s ease-out forwards;
}

/* Admin applause floating button (left side, mobile) */
.admin-applause-floating {
    position: fixed;
    left: 12px;
    top: 64px; /* adjusted to sit below profile icon */
    z-index: 2000;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-applause-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.25);
    padding: 0;
}

.admin-applause-btn.admin-effect-btn { cursor: pointer; }

/* Hide floating button on wide screens (use top-bar for desktop if desired) */
@media (min-width: 900px) {
    .admin-applause-floating { display: none !important; }
} 

@keyframes animatedEmojiFloatSmall {
    0% {
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 1;
    }
    60% {
        /* aumentiamo la distanza negativa per farli salire decisamente più in alto */
        transform: translate(-50%, calc(var(--float-ty, -160px))) scale(1.02);
        opacity: 1;
    }
    100% {
        /* termine leggermente sotto il picco (più alto rispetto a prima) */
        transform: translate(-50%, calc(var(--float-ty, -160px) + 30px)) scale(0.9);
        opacity: 0;
    }
}

/* Responsive: ancora più piccolo sui telefoni */
@media (max-width: 480px) {
    .animated-emoji.heart-like { width: 40px; }
}

/* Screen-reader only utility (visually hidden but accessible) */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}


.flying-kiss {
    position: absolute;
    bottom: 20%;
    font-size: 40px;
    animation: kissFly 2.5s ease-out forwards;
    pointer-events: none;
    z-index: 101;
}

@keyframes kissFly {
    0% {
        bottom: 20%;
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.9;
        transform: scale(1.3) translateY(-30px);
    }
    100% {
        bottom: 60%;
        opacity: 0;
        transform: scale(0.5) translateY(-60px);
    }
}

.flying-confetti {
    position: absolute;
    top: -20px;
    font-size: 24px;
    animation: confettiFall 4s ease-out forwards;
    pointer-events: none;
    z-index: 101;
}

@keyframes confettiFall {
    0% {
        top: -20px;
        opacity: 1;
        transform: rotate(0deg) scale(1);
    }
    50% {
        opacity: 0.8;
        transform: rotate(180deg) scale(1.2);
    }
    100% {
        top: 100vh;
        opacity: 0;
        transform: rotate(360deg) scale(0.5);
    }
}

.fire-effect {
    position: absolute;
    bottom: 30%;
    font-size: 36px;
    animation: fireFlicker 2s ease-in-out forwards;
    pointer-events: none;
    z-index: 101;
}

@keyframes fireFlicker {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    25% {
        opacity: 0.8;
        transform: scale(1.1);
    }
    50% {
        opacity: 0.9;
        transform: scale(0.9);
    }
    75% {
        opacity: 0.7;
        transform: scale(1.2);
    }
}

.send-button {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #fe2c55 0%, #ff6b8a 100%);
    border: none;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(254,44,85,0.3);
}

.send-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(254,44,85,0.5);
    background: linear-gradient(135deg, #ff6b8a 0%, #fe2c55 100%);
}

.send-button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 6px rgba(254,44,85,0.4);
}

/* Generic icon button used across UI (emoji/share/logout) */
.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.06);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease;
}
.icon-btn:hover { background: rgba(254,44,85,0.06); transform: scale(1.05); }

/* ===== TIKTOK-STYLE VERTICAL ACTIONS (Right Side) ===== */
.tiktok-actions {
    position: fixed;
    right: 12px;
    bottom: 450px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 70;
    pointer-events: auto;
}

.action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease;
}

/* Disabled state for action buttons (e.g., greet cooldown) */
.action-item.disabled {
    opacity: 0.45;
    /* Allow pointer events so clicks can still be handled (we show an explanatory message on attempts)
       but give a not-allowed cursor to indicate the action is blocked */
    pointer-events: auto;
    cursor: not-allowed;
}

.action-item:active {
    transform: scale(0.9);
}

.action-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
}

.action-item:active .action-icon {
    background: rgba(0, 0, 0, 0.5);
    transform: scale(1.1);
}

#like-action .action-icon {
    font-size: 22px;
}

#like-action.liked .action-icon {
    background: rgba(254, 44, 85, 0.3);
    border-color: #fe2c55;
    animation: pulse-like 0.3s ease;
}

@keyframes pulse-like {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.action-count,
.action-label {
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    text-align: center;
}

.action-count {
    min-width: 20px;
}

/* ===== SIDE BAR DESTRA (Action Buttons) ===== */
.side-actions {
    position: absolute;
    right: 12px;
    bottom: 100px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 60;
}

.action-btn {
    width: 38px;
    height: 38px;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.action-btn:hover {
    transform: scale(1.1);
    background: rgba(255,255,255,0.2);
}

.action-btn svg {
    width: 24px;
    height: 24px;
    stroke: white;
}

.action-label {
    color: white;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    margin-top: 4px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .top-bar {
        padding: 16px 12px;
    }
    .message-content { max-width: 66%; gap: 6px; }
    
    .viewer-count {
        padding: 5px 10px;
    }
    
    .chat-panel {
        padding: 0 8px 16px;
    }
    
    .message-bubble {
        padding: 8px 12px;
    }
    .msg-avatar, .msg-avatar-placeholder { width: 40px; height: 40px; }
    .message-content { max-width: 72%; gap: 8px; }
    
    .chat-messages-overlay {
        max-height: calc(3 * 110px); /* Adjust for slightly smaller messages on mobile */
    }
    
    .side-actions {
        right: 8px;
        bottom: 100px;
        gap: 16px;
    }
    
    .action-btn {
        width: 44px;
        height: 44px;
    }
    
    .send-button, .share-btn-inline, .emoji-btn {
        width: 42px;
        height: 42px;
    }
    
    .logout-btn {
        padding: 6px 10px;
        min-height: 40px;
        border-radius: 8px;
        max-width: 120px;
    }
}

@media (max-width: 480px) {
    .brand-logo { max-width: calc(100% - 120px); }
    .msg-avatar, .msg-avatar-placeholder { width: 36px; height: 36px; }
    .message-content { max-width: 70%; gap: 8px; }
    .send-button, .share-btn-inline, .emoji-btn { width: 40px; height: 40px; }
    .logout-btn { padding: 6px 10px; min-height: 40px; border-radius: 8px; max-width: 120px; }
    .viewer-count { display: inline-flex; align-items:center; gap:6px; padding:4px 8px; border-radius:12px; background: rgba(255,255,255,0.03); min-width:36px; }
}

@media (max-width: 420px) {
    .top-bar { padding: 12px 10px; }
    .brand-logo { max-width: calc(100% - 120px); }
    .top-bar-right { gap: 8px; }
    .profile-link { width: 34px; height:34px; }
    .msg-avatar, .msg-avatar-placeholder { width: 34px; height: 34px; }
    .message-content { max-width: 68%; gap: 6px; }
}

@media (max-width: 360px) {
    .viewer-count .icon { display: none; }
    .viewer-count .count { padding: 4px 6px; }
    .brand-logo { max-width: calc(100% - 80px); }
    .top-bar { padding: 10px 8px; }
}

/* ===== LOGOUT BUTTON ===== */
.logout-btn {
    display:inline-flex;
    gap:8px;
    align-items:center;
    justify-content:center;
    padding:8px 14px;
    min-height:40px;
    background: #fe2c55; /* plain red filled */
    border: none;
    color: white;
    border-radius: 8px; /* small rounded rectangle */
    font-weight: 600;
    font-size: 14px;
    cursor:pointer;
    transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
    touch-action: manipulation;
    padding-left: 12px;
    padding-right: 12px;
    max-width: 140px; /* prevent from growing too wide */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* removed ::before because we now inline icon SVG */

.logout-btn:hover {
    filter: brightness(0.92);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

.logout-btn svg {
    width: 18px;
    height: 18px;
}

.logout-text {
    color: white;
    font-weight: 600;
    font-size: 13px;
}

.logout-btn:hover .logout-text { color: #fff; }

/* Spinner shown when logout is in loading state */
/* remove spinner class as we want simple button */
/* .logout-btn.loading removed to keep button simple */

/* ===== TIKTOK-STYLE NATIVE INPUT BAR ===== */
.tiktok-input-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 6px 12px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    z-index: 9999;
    display: flex;
    gap: 10px;
    border-top: 2px solid rgba(255, 50, 50, 0.8);
}

/* Chat panel: spazio per la barra input in basso
   Use CSS variable so JS can control exact height without needing !important.
   Default fallback kept small so we don't leave a large gap on older browsers. */
.chat-panel {
    padding-bottom: calc(var(--chat-input-height, 0px) + env(safe-area-inset-bottom, 0px) + 12px);
}
#message-input-native {
    flex: 1;
    background: rgba(50, 50, 50, 0.9);
    border: 1px solid rgba(255, 50, 50, 0.6);
    border-radius: 20px;
    padding: 8px 16px;
    color: white;
    font-size: 16px;
    line-height: 20px;
    height: 36px;
    min-height: 36px;
    max-height: 36px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    resize: none;
    overflow: hidden;
}

#message-input-native::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

#message-input-native:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(20, 20, 20, 0.6);
}

/* Voice Button */
.voice-btn {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    background: rgba(102, 126, 234, 0.2);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.5) inset;
}

.voice-btn svg {
    color: #667eea;
    transition: all 0.3s ease;
}

.voice-btn:hover {
    background: rgba(102, 126, 234, 0.3);
    transform: scale(1.05);
}

.voice-btn:active {
    transform: scale(0.95);
}

/* Voice Button States */
.voice-btn.listening {
    background: rgba(254, 44, 85, 0.3);
    box-shadow: 0 0 0 2px #fe2c55 inset;
    animation: pulse-voice 1.5s ease-in-out infinite;
}

.voice-btn.listening svg {
    color: #fe2c55;
}

.voice-btn.processing {
    background: rgba(255, 193, 7, 0.3);
    box-shadow: 0 0 0 2px #ffc107 inset;
}

.voice-btn.processing svg {
    color: #ffc107;
    animation: spin 1s linear infinite;
}

.voice-btn.error {
    background: rgba(220, 53, 69, 0.3);
    box-shadow: 0 0 0 2px #dc3545 inset;
}

.voice-btn.error svg {
    color: #dc3545;
}

.voice-btn.not-supported {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Voice Status Indicator */
.voice-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid rgba(30, 30, 30, 0.95);
    display: none;
}

.voice-btn.listening .voice-status {
    display: block;
    background: #fe2c55;
    animation: pulse-dot 1s ease-in-out infinite;
}

.voice-btn.processing .voice-status {
    display: block;
    background: #ffc107;
}

/* Animations */
@keyframes pulse-voice {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(254, 44, 85, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(254, 44, 85, 0);
    }
}

@keyframes pulse-dot {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.send-btn-native {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    background: linear-gradient(135deg, #fe2c55 0%, #ff6b8a 100%);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    color: white;
}

.send-btn-native:hover {
    transform: scale(1.05);
}

.send-btn-native:active {
    transform: scale(0.95);
}

.send-btn-native svg {
    width: 22px;
    height: 22px;
}

/* Animazioni messaggi più fluide (TikTok-style) */
@keyframes slideInMessage {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message {
    animation: slideInMessage 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .send-btn-native {
        width: 36px;
        height: 36px;
    }
}

/* Leaderboard overlay styles */
.leaderboard-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2200;
  background: rgba(0,0,0,0.45);
}
.leaderboard-card {
  background: white;
  padding: 18px;
  border-radius: 12px;
  width: min(760px, 96%);
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
  color: #222;
}
.leaderboard-list { max-height: 60vh; overflow:auto; margin-top:12px; }
.leaderboard-item { display:flex; align-items:center; gap:12px; padding:8px 6px; border-bottom:1px solid #f0f0f0; }
.leaderboard-item .rank { font-weight:700; width:40px; text-align:center; font-size:18px; }
.leaderboard-item .meta { flex:1; }
.leaderboard-item .name { font-weight:700; }
.leaderboard-item .likes { color:#666; font-size:13px; }
/* Ensure hearts are red in overlay and admin preview */
.leaderboard-overlay .likes,
#leaderboard-preview-modal .likes,
.leaderboard-card .likes { color: #ff4b6e; }

/* Improve contrast in admin preview */
#leaderboard-preview-modal .likes { color: #ff4b6e; font-weight:800; }