/* ===== STILE APPLE - AGGIORNATO ===== */

/* Stili Generali */
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #1d1d1f;
    line-height: 1.47059;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1 {
    color: #1d1d1f;
    text-align: center;
    margin-bottom: 8px;
    font-size: 48px;
    font-weight: 600;
    letter-spacing: -0.003em;
    line-height: 1.08349;
}

h2 {
    color: #1d1d1f;
    text-align: center;
    margin-bottom: 20px;
    font-size: 28px;
    font-weight: 500;
    letter-spacing: -0.002em;
    line-height: 1.14286;
}

h3 {
    color: #1d1d1f;
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.016em;
    margin: 20px 0 12px 0;
}

h4 {
    color: #6e6e73;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.022em;
    margin: 12px 0 8px 0;
}

/* Contenitori Viste */
#name-input-view, #start-menu, #waiting-room, #game-area, #error-view, #leaderboard-view {
    background-color: rgba(255, 255, 255, 0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    padding: 40px;
    margin: 20px auto;
    border-radius: 18px;
    box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.05);
    max-width: 90%;
    width: 580px;
    border: none;
    box-sizing: border-box;
    text-align: center;
}

/* Input Fields */
input[type="text"] {
    padding: 12px 16px;
    margin-bottom: 12px;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
    font-size: 17px;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    background-color: rgba(255, 255, 255, 0.8);
    transition: all 0.2s ease;
}

input[type="text"]:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

input[type="text"]::placeholder {
    color: #86868b;
}

/* Bottoni Generali */
button {
    background-color: #0071e3;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 980px;
    cursor: pointer;
    font-size: 17px;
    font-weight: 400;
    letter-spacing: -0.022em;
    margin: 8px 4px;
    transition: all 0.2s ease;
    width: auto;
    min-width: 140px;
    box-sizing: border-box;
    font-family: inherit;
}

button:hover {
    background-color: #0077ed;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.25);
}

button:active {
    transform: translateY(0px);
    box-shadow: 0 2px 6px rgba(0, 113, 227, 0.25);
}

button:disabled {
    background-color: #d2d2d7;
    color: #86868b;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

hr {
    margin: 30px 0;
    border: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

p {
    margin-bottom: 12px;
    text-align: center;
    font-size: 17px;
    letter-spacing: -0.022em;
    color: #1d1d1f;
}

/* Connection Status */
#connection-status {
    font-size: 19px;
    color: #6e6e73;
    font-style: normal;
    margin-top: 24px;
    margin-bottom: 24px;
    min-height: 1.5em;
    letter-spacing: -0.022em;
}

.error-text {
    color: #ff3b30;
    font-weight: 500;
    margin-top: 12px;
    text-align: center;
    min-height: 1.2em;
    font-size: 15px;
}

/* Scelta Nome */
.name-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

.name-buttons button {
    width: 45%;
    padding: 16px 20px;
    font-size: 19px;
    min-width: 120px;
}

/* Start Menu */
#start-menu #btn-inizia-partita {
    width: auto;
    padding: 12px 32px;
    background-color: #34c759;
    display: none;
    margin: 20px auto;
}

#start-menu #btn-inizia-partita:hover {
    background-color: #30b350;
}

/* Area di Gioco */
#game-area {
    text-align: center;
}

#scores {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.022em;
}

#scores span {
    color: #0071e3;
}

#question-image {
    max-width: 90%;
    max-height: 280px;
    height: auto;
    margin: 20px auto;
    display: block;
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

#question-text {
    font-size: 21px;
    margin: 24px 0;
    color: #1d1d1f;
    min-height: 3em;
    letter-spacing: -0.016em;
    font-weight: 400;
    line-height: 1.381;
}

#question-text strong {
    color: #1d1d1f;
    font-weight: 600;
}

#timer {
    font-size: 28px;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 28px;
    letter-spacing: -0.002em;
}

/* Answer Buttons Container */
#answer-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 28px;
    pointer-events: auto;
}

#answer-buttons button {
    width: auto;
    min-width: 140px;
    padding: 14px 28px;
    font-size: 17px;
    margin: 0;
    font-weight: 500;
    letter-spacing: -0.022em;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
}

/* Default state for exam mode - gray buttons */
.exam-mode #answer-buttons button {
    background-color: #f5f5f7;
    color: #1d1d1f;
    border: 1px solid #d2d2d7;
}

.exam-mode #answer-buttons button:hover:not(.selected-answer) {
    background-color: #e8e8ed;
    border-color: #b0b0b5;
}

/* Quiz mode colors (when NOT in exam mode) */
body:not(.exam-mode) #answer-buttons button[data-answer="V"] {
    background-color: #34c759;
    color: white;
    border: none;
}

body:not(.exam-mode) #answer-buttons button[data-answer="V"]:hover {
    background-color: #30b350;
}

body:not(.exam-mode) #answer-buttons button[data-answer="F"] {
    background-color: #ff3b30;
    color: white;
    border: none;
}

body:not(.exam-mode) #answer-buttons button[data-answer="F"]:hover {
    background-color: #e63428;
}

/* Exam mode selected states */
.exam-mode #answer-buttons button.selected-answer[data-answer="V"] {
    background-color: #34c759;
    color: white;
    border-color: #30b350;
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.3);
}

.exam-mode #answer-buttons button.selected-answer[data-answer="F"] {
    background-color: #ff3b30;
    color: white;
    border-color: #e63428;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.3);
}

/* Disabled state */
#answer-buttons button:disabled {
    background-color: #f5f5f7;
    color: #86868b;
    cursor: not-allowed;
    opacity: 0.6;
    border-color: #d2d2d7;
    transform: none;
    box-shadow: none;
}

/* Exam Navigation */
#exam-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    align-items: center;
}

#exam-nav button {
    min-width: 100px;
    font-size: 15px;
    padding: 10px 20px;
}

#exam-position {
    font-size: 17px;
    color: #6e6e73;
    margin-left: 12px;
    font-weight: 500;
}

/* Round Results */
#round-result {
    margin-top: 24px;
    font-weight: 500;
    min-height: 1.2em;
    font-size: 19px;
    letter-spacing: -0.022em;
}

.correct-answer {
    color: #34c759;
}

.wrong-answer {
    color: #ff3b30;
}

.no-answer {
    color: #ff9500;
}

/* Vista Errori */
#error-view {
    max-width: 800px;
    width: 95%;
}

#error-list {
    list-style: none;
    padding: 12px;
    max-height: 60vh;
    overflow-y: auto;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
    margin-bottom: 20px;
    background-color: rgba(255, 255, 255, 0.5);
}

.error-item {
    background-color: rgba(255, 255, 255, 0.9);
    margin-bottom: 12px;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid #e5e5ea;
    text-align: left;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.error-item p {
    text-align: left;
    margin: 6px 0;
    font-size: 15px;
}

.error-item strong {
    color: #1d1d1f;
    font-weight: 600;
}

.error-image {
    max-width: 180px;
    max-height: 120px;
    height: auto;
    display: block;
    margin: 12px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#error-pagination {
    text-align: center;
    margin-top: 20px;
}

#error-pagination button {
    width: auto;
    padding: 8px 16px;
    font-size: 15px;
    background-color: #f5f5f7;
    color: #1d1d1f;
    margin: 0 6px;
    min-width: 80px;
}

#error-pagination button:hover {
    background-color: #e8e8ed;
}

/* Bottoni speciali */
#btn-show-errors {
    background-color: #ff3b30;
    margin-top: 20px;
}

#btn-show-errors:hover {
    background-color: #e63428;
}

#btn-close-errors,
#btn-close-leaderboard {
    background-color: #86868b;
    margin-top: 24px;
}

#btn-close-errors:hover,
#btn-close-leaderboard:hover {
    background-color: #6e6e73;
}

#btn-show-leaderboard {
    background-color: #af52de;
    margin-top: 16px;
}

#btn-show-leaderboard:hover {
    background-color: #9f42ce;
}

/* Classifica */
#leaderboard-scores {
    margin: 28px 0;
    padding: 20px;
    background-color: rgba(245, 245, 247, 0.6);
    border: 1px solid #d2d2d7;
    border-radius: 12px;
}

.leaderboard-entry {
    font-size: 21px;
    font-weight: 600;
    margin: 12px 0;
    letter-spacing: -0.016em;
}

.leaderboard-entry span {
    color: #0071e3;
    font-size: 24px;
}

/* Mode Selection */
.mode-selection-container {
    margin: 24px 0 20px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 20px;
}

.mode-selection-container h4 {
    margin: 0 0 16px 0;
    color: #1d1d1f;
    font-size: 19px;
    font-weight: 600;
}

.mode-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.mode-btn {
    width: auto;
    min-width: 120px;
    padding: 10px 20px;
    font-size: 17px;
    background-color: #f5f5f7;
    border: 1px solid #d2d2d7;
    color: #1d1d1f;
    opacity: 1;
    transition: all 0.2s ease;
}

.mode-btn:hover:not(:disabled) {
    background-color: #e8e8ed;
    border-color: #b0b0b5;
}

.mode-btn.active {
    background-color: #0071e3;
    border-color: #0071e3;
    color: white;
    opacity: 1;
    font-weight: 500;
}

.mode-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f5f5f7;
}

.mode-btn.active:disabled {
    background-color: #0071e3;
    opacity: 0.5;
}

/* Game Settings */
.game-settings {
    margin-top: 20px;
    padding: 16px;
    background-color: rgba(245, 245, 247, 0.6);
    border-radius: 12px;
    border: 1px solid #d2d2d7;
}

.setting-slider {
    margin: 16px 0;
    text-align: left;
}

.setting-slider label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #1d1d1f;
    font-size: 15px;
    letter-spacing: -0.016em;
}

.setting-slider label span {
    color: #0071e3;
    font-size: 17px;
    font-weight: 600;
    float: right;
}

.setting-slider input[type="range"] {
    width: 100%;
    cursor: pointer;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #d2d2d7;
    border-radius: 2px;
}

.setting-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0071e3;
    cursor: pointer;
    transition: all 0.2s ease;
}

.setting-slider input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 6px rgba(0, 113, 227, 0.1);
}

.setting-slider input[type="range"]:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.setting-slider input[type="range"]:disabled::-webkit-slider-thumb {
    background: #86868b;
    cursor: not-allowed;
}

/* Media Query per Mobile */
@media (max-width: 600px) {
    body {
        padding: 12px;
        align-items: flex-start;
    }

    #name-input-view, #start-menu, #waiting-room, #game-area, #error-view, #leaderboard-view {
        padding: 24px;
        max-width: 100%;
        width: 100%;
        margin: 12px auto;
        border-radius: 16px;
    }

    h1 {
        font-size: 32px;
    }

    h2 {
        font-size: 24px;
    }

    button {
        font-size: 15px;
        padding: 10px 20px;
        min-width: 120px;
    }

    .name-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .name-buttons button {
        width: 100%;
        margin-bottom: 12px;
    }

    #answer-buttons {
        flex-direction: column;
        gap: 12px;
    }

    #answer-buttons button {
        width: 100%;
        min-width: 0;
    }

    #scores {
        flex-direction: column;
        align-items: center;
        font-size: 15px;
    }

    #error-list {
        max-height: 55vh;
    }

    .error-item {
        padding: 12px;
    }

    .error-image {
        max-width: 120px;
        max-height: 80px;
    }
}
