* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    overflow-x: hidden;
    background-color: #0f172a;
    background-image:
        linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%),
        radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(16, 185, 129, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(139, 92, 246, 0.05) 0%, transparent 30%);
    background-repeat: no-repeat;
    background-size: cover;
}

body {
    background-color: #0f172a;
    background-image: none;
    color: #ececf1;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    margin: 0;
    padding: max(20px, env(safe-area-inset-top)) 20px 20px;
    overflow-x: hidden;
    position: relative;
    isolation: isolate;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.skip-link:focus {
    left: 16px;
    top: 16px;
    width: auto;
    height: auto;
    padding: 10px 14px;
    border-radius: 8px;
    background: #10b981;
    color: #0f172a;
    font-weight: 700;
    z-index: 10000;
}

/* Animated background particles */
body::before {
    display: none;
}

.container {
    width: 100%;
    max-width: 650px;
    text-align: center;
    position: relative;
    z-index: 1;
    padding: clamp(8px, 2vh, 20px) 0 0;
    min-width: 0;
}

/* Logo/Icon */
.logo-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, #10b981 0%, #6366f1 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    box-shadow: 0 10px 40px rgba(99, 102, 241, 0.3);
    animation: float 3s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

h1 {
    font-size: clamp(2rem, 8vw, 3rem);
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -1px;
    overflow-wrap: anywhere;
}

.subtitle {
    color: #9ca3af;
    margin: 0 0 32px 0;
    font-size: clamp(0.9rem, 3.5vw, 1.1rem);
    font-weight: 400;
    line-height: 1.6;
    padding: 0 10px;
    overflow-wrap: anywhere;
}

.subtitle .emoji {
    font-size: 1.2em;
}

/* Input Box modernizzato */
.input-box {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 8px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    position: relative;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.input-box:focus-within {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow:
        0 4px 32px rgba(99, 102, 241, 0.2),
        0 0 0 1px rgba(99, 102, 241, 0.3) inset;
}

textarea, input {
    background: transparent;
    border: none;
    color: white;
    width: 100%;
    min-width: 0; /* Fix for flexbox overflow */
    font-size: 16px; /* Prevent zoom on iOS */
    font-family: inherit;
    outline: 2px solid transparent;
    padding: 12px;
    flex: 1;
    line-height: 1.5;
}

a:focus-visible, button:focus-visible {
    outline: 2px solid #10b981;
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

textarea {
    resize: none;
    overflow: hidden;
    min-height: 24px;
    max-height: 200px;
    field-sizing: content; /* Modern browsers auto-sizing */
}

textarea::placeholder, input::placeholder {
    color: #6b7280;
}

/* Bottone principale */
button {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    flex-shrink: 0;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

button:active {
    transform: translateY(0);
}

button svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Area Risultato */
#result-area {
    margin-top: 24px;
    display: none;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 16px;
    animation: slideUp 0.4s ease;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

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

#result-area p {
    margin: 0 0 12px 0;
    color: #9ca3af;
    font-size: 14px;
}

#generated-link {
    color: #10b981;
    word-break: break-all;
    margin-bottom: 16px;
    display: block;
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    padding: 12px 14px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    transition: all 0.2s ease;
    line-height: 1.5;
}

#generated-link:hover {
    background: rgba(16, 185, 129, 0.15);
}

.copy-btn {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: none !important;
    padding: 12px 20px !important;
    width: 100%;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    box-shadow: none !important;
    transform: none;
}

/* Features section */
.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 48px;
    text-align: center;
    width: 100%;
    max-width: 100%;
}

.seo-copy {
    margin-top: 32px;
    text-align: left;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 18px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.seo-copy h2 {
    margin: 0 0 12px 0;
    font-size: 1.05rem;
    color: #f3f4f6;
}

.seo-copy p {
    margin: 0 0 12px 0;
    color: #cbd5e1;
    line-height: 1.65;
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}

.seo-copy p:last-child {
    margin-bottom: 0;
}

.site-footer {
    margin-top: 24px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 14px;
    font-size: 0.85rem;
    width: 100%;
}

.site-footer a {
    color: #9ca3af;
    text-decoration: none;
}

.site-footer a:hover {
    color: #e5e7eb;
    text-decoration: underline;
}

.feature {
    padding: 16px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    min-width: 0;
}

.feature-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.feature-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    color: #e5e7eb;
}

.feature-desc {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

/* Fake Cursor per l'animazione */
#fake-cursor {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 9999;
    display: none;
    transition: top 0.6s ease-in-out, left 0.6s ease-in-out;
    transform: translate(-2px, -2px);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Messaggio sarcastico finale */
#sarcasm-msg {
    display: none;
    margin-top: 24px;
    font-size: 1.1rem;
    color: #10b981;
    animation: fadeIn 1s;
    padding: 16px 20px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    overflow-wrap: anywhere;
}

/* === PLAYBACK MODE STYLES === */
body.playback-mode {
    background: #212121;
}

body.playback-mode::before {
    display: none;
}

body.playback-mode .input-box {
    background: #2f2f2f;
    border: 1px solid #424242;
    border-radius: 24px;
    padding: 12px 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    max-width: 700px;
    margin: 0 auto;
}

body.playback-mode .input-box:focus-within {
    border-color: #525252;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
}

body.playback-mode textarea {
    padding: 8px 12px;
    font-size: 15px;
}

body.playback-mode h1 {
    background: none;
    -webkit-text-fill-color: white;
    font-size: 1.5rem;
    margin-bottom: 24px;
}

/* Bottone invio stile ChatGPT */
.send-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0 !important;
    border-radius: 50% !important;
    background: #676767 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: none !important;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #7a7a7a !important;
    transform: none !important;
}

.send-btn.active {
    background: white !important;
}

.send-btn svg {
    width: 18px;
    height: 18px;
    stroke: #212121;
}

.send-btn.inactive svg {
    stroke: #9a9a9a;
}

/* Animazione pulse per il bottone quando pronto */
@keyframes sendPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.send-btn.pulse {
    animation: sendPulse 0.5s ease;
}

/* Typing indicator - cursore lampeggiante */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: #10b981;
    margin-left: 2px;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

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

/* Responsive - Tablet */
@media (max-width: 768px) {
    body {
        padding: 16px;
    }

    .features {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        margin-top: 40px;
    }

    .feature {
        padding: 14px 10px;
    }

    .feature-icon {
        font-size: 22px;
    }

    .feature-title {
        font-size: 12px;
    }

    .feature-desc {
        font-size: 10px;
    }
}

/* Responsive - Mobile */
@media (max-width: 480px) {
    body {
        padding: 12px;
        justify-content: flex-start;
        padding-top: calc(12vh + env(safe-area-inset-top));
    }

    .logo-icon {
        width: 64px;
        height: 64px;
        font-size: 32px;
        margin-bottom: 16px;
        border-radius: 16px;
    }

    h1 {
        font-size: 2rem;
        margin-bottom: 0.3rem;
    }

    .subtitle {
        font-size: 0.9rem;
        margin-bottom: 24px;
        padding: 0 5px;
    }

    .input-box {
        flex-direction: column;
        padding: 12px;
        gap: 12px;
    }

    body.playback-mode .input-box {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    textarea, input {
        width: 100%;
        text-align: left;
        padding: 14px 12px;
        min-height: 48px;
    }

    button {
        width: 100%;
        padding: 14px 20px;
        font-size: 15px;
        justify-content: center;
    }

    #action-btn span {
        display: inline;
    }

    .features {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-top: 32px;
    }

    .feature {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
        text-align: left;
    }

    .feature-icon {
        font-size: 24px;
        margin-bottom: 0;
    }

    .feature-content {
        flex: 1;
        min-width: 0;
    }

    .feature-title {
        font-size: 13px;
        margin-bottom: 2px;
    }

    .feature-desc {
        font-size: 11px;
    }

    #result-area {
        padding: 16px;
        margin-top: 20px;
    }

    #generated-link {
        font-size: 12px;
        padding: 10px 12px;
    }

    #sarcasm-msg {
        font-size: 1rem;
        padding: 14px 16px;
    }

    .seo-copy {
        padding: 16px;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    body {
        padding: 10px;
        padding-top: 5vh;
    }

    .logo-icon {
        width: 56px;
        height: 56px;
        font-size: 28px;
    }

    h1 {
        font-size: 1.7rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    button {
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* Landscape mobile fix */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        justify-content: flex-start;
        padding-top: 20px;
        min-height: auto;
    }

    .logo-icon {
        width: 50px;
        height: 50px;
        font-size: 26px;
        margin-bottom: 12px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        margin-bottom: 16px;
        font-size: 0.85rem;
    }

    .features {
        margin-top: 24px;
    }
}
