:root {
    --bg: #f5f5f5;
    --text: #222;
    --accent: #007bff;
    --accent-night: #ff9800;
    --error: #e53935;
    --quote-bg: #f2f8ff;
    --quote-bg-night: #23272f;
}

/* Universal box sizing and mobile-friendly base font */
html, body {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    width: 100vw;
    min-height: 100vh;
    font-size: 18px;
    overscroll-behavior: contain;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    position: relative;
}

body.night {
    --bg: #23272f;
    --text: #eee;
    --accent: var(--accent-night);
}

.container {
    width: 100vw;
    min-height: 100vh;
    margin: 0;
    padding: 32px 4vw 24px 4vw;
    background: rgba(255,255,255,0.92);
    text-align: center;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

body.night .container {
    background: rgba(30,30,40,0.98);
}

.theme-switcher {
    position: fixed;
    top: 18px;
    right: 18px;
    font-size: 1.7em;
    z-index: 99;
}

/* Titolo e form */
h1 {
    font-size: 1.28em;
    margin-bottom: 22px;
    margin-top: 0;
}

form label {
    font-size: 1em;
    margin-bottom: 6px;
    display: block;
}

input[type="text"] {
    width: 100%;
    padding: 15px 12px;
    margin: 14px 0 16px 0;
    font-size: 1.08em;
    border-radius: 10px;
    border: 1.5px solid var(--accent);
    outline: none;
    background: var(--bg);
    color: var(--text);
    box-sizing: border-box;
}

button {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 16px 0;
    cursor: pointer;
    font-size: 1.08em;
    margin-bottom: 16px;
    transition: background 0.2s;
}

button:hover {
    background: #0056b3;
}

#result {
    margin-top: 18px;
    font-style: italic;
    font-size: 1.12em;
    min-height: 32px;
    color: var(--accent);
}

.quote-box {
    background: var(--quote-bg);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    padding: 20px 12px 10px 12px;
    margin: 0 auto 14px auto;
    width: 100%;
    max-width: 98vw;
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.09);
    animation: fadein 0.7s;
}

body.night .quote-box {
    background: var(--quote-bg-night);
    border-left: 4px solid var(--accent-night);
}

.quote-box blockquote {
    margin: 0 0 10px 0;
    font-size: 1.15em;
    line-height: 1.4;
    quotes: "“" "”" "‘" "’";
}

.quote-box blockquote:before {
    content: open-quote;
    color: var(--accent);
    font-size: 1.5em;
    vertical-align: -0.2em;
}
.quote-box blockquote:after {
    content: close-quote;
    color: var(--accent);
    font-size: 1.5em;
    vertical-align: -0.2em;
}

.author {
    text-align: right;
    font-size: 1em;
    font-style: normal;
    color: var(--accent);
    margin-bottom: 2px;
}

#result .error, #result span[style*="red"] {
    color: var(--error) !important;
    font-style: normal;
}

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

/* --- Responsive tablet landscape e desktop --- */
@media (min-width: 700px) {
    html {
        font-size: 18px;
    }
    .container {
        max-width: 440px;
        min-height: 520px;
        margin: 40px auto;
        border-radius: 18px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.10);
        padding: 36px 32px 28px 32px;
        background: rgba(255,255,255,0.97);
    }
    body.night .container {
        background: rgba(30,30,40,0.97);
    }
    h1 {
        font-size: 1.5em;
        margin-bottom: 28px;
    }
    .quote-box {
        max-width: 340px;
        border-radius: 12px;
    }
}

/* --- Responsive tablet verticale --- */
@media (min-width: 600px) and (max-width: 899px) {
    .container {
        max-width: 90vw;
        padding-left: 5vw;
        padding-right: 5vw;
    }
    .quote-box {
        max-width: 70vw;
    }
}

/* --- Piccolissimi smartphone --- */
@media (max-width: 350px) {
    html {
        font-size: 16px;
    }
    .container {
        padding: 20px 2vw 16px 2vw;
    }
    .theme-switcher {
        font-size: 1.3em;
        top: 8px;
        right: 8px;
    }
}