:root {
    --bg-a: #f7f4ea;
    --bg-b: #f0e3c8;
    --ink: #1f2633;
    --ink-soft: #5a6477;
    --card: #fffdf7;
    --line: #e4d7bc;
    --accent: #1f7a6a;
    --accent-strong: #145145;
    --danger: #b42318;
    --warning: #8f5a00;
    --shadow: 0 18px 50px rgba(31, 38, 51, 0.12);
    --mask-radius: 200px;
    --mask-solid-stop: 38%;
    --mask-fade-mid: 62%;
    --mask-fade-soft: 84%;
    --placeholder-color: #767e8a;
    --placeholder-color-secondary: #b0bac8;
    --placeholder-opacity: 0.3;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Manrope", sans-serif;
    color: var(--ink);
    background: radial-gradient(circle at 90% 8%, #f8dca4 0%, transparent 35%),
        radial-gradient(circle at 15% 85%, #d8e6d9 0%, transparent 30%),
        linear-gradient(130deg, var(--bg-a), var(--bg-b));
    padding: 20px;
}

.app-shell {
    width: min(980px, 100%);
    margin: 0 auto;
    position: relative;
    z-index: 2;
    display: grid;
    gap: 18px;
}

.app-header {
    background: rgba(255, 253, 247, 0.9);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.app-header h1 {
    font-family: "Sora", sans-serif;
    margin: 0;
    font-size: clamp(1.6rem, 2.4vw, 2.2rem);
    letter-spacing: -0.03em;
}

.app-header p {
    margin: 8px 0 0;
    color: var(--ink-soft);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-chip {
    background: #edf7f3;
    border: 1px solid #b9ded1;
    color: #1d5d4d;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 0.88rem;
    font-weight: 700;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.user-chip:hover {
    background: #d4f0e7;
    border-color: #7ec9b4;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: clamp(18px, 3vw, 26px);
    animation: rise-in 280ms ease both;
}

.card h2 {
    margin-top: 0;
    margin-bottom: 8px;
    font-family: "Sora", sans-serif;
}

.auth-card {
    text-align: center;
}

.auth-card p {
    color: var(--ink-soft);
}

.auth-message {
    min-height: 24px;
    color: var(--danger);
    font-weight: 700;
}

#home-screen {
    display: grid;
    gap: 20px;
}

#home-screen .card {
    padding: 22px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
    position: relative;
}

.search-box-inline {
    grid-column: 1 / -1;
    margin-bottom: 0;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 10px;
}

@media (max-width: 700px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .search-box-inline {
        grid-column: 1 / -1;
    }
}

.stat-card {
    background: #fcf5e8;
    border: 1px solid #ead4ac;
    border-radius: 14px;
    padding: 14px;
}

.stat-card h3 {
    margin: 0;
    font-size: 1.5rem;
}

.stat-card p {
    margin: 4px 0 0;
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.home-tools {
    display: grid;
    gap: 10px;
}

.home-tools label {
    font-weight: 700;
}

.home-tools input,
input[type="text"] {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    font: inherit;
    background: #fff;
}

.home-tools input:focus,
input[type="text"]:focus {
    border-color: var(--accent);
    outline: 2px solid rgba(31, 122, 106, 0.2);
}

.quiz-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.quiz-card {
    display: grid;
    gap: 12px;
}

.quiz-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.quiz-card h3 {
    margin: 0;
    font-size: 1.06rem;
}

.quiz-card p {
    margin: 0;
    color: var(--ink-soft);
}

.quiz-card .btn {
    margin-top: 6px;
    width: fit-content;
}

.quiz-status {
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 0.74rem;
    font-weight: 700;
}

.quiz-status.available {
    background: #eaf7f3;
    color: #1d5d4d;
}

.quiz-status.completed {
    background: #e9f0ff;
    color: #224a8b;
}

.quiz-status.cancelled {
    background: #fff0ef;
    color: #9d2f2f;
}

.quiz-meta {
    margin: 0;
    padding-left: 0px;
    color: var(--ink-soft);
    display: grid;
    gap: 4px;
    list-style-type: none;
}

.form-grid {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

/* Start screen: melhorar layout e espaçamento dos botões */
#start-screen .form-grid {
    display: flex;
    flex-direction: row;
    gap: 18px;
    justify-content: center;
    align-items: center;
    margin-top: 18px;
    flex-wrap: wrap;
}

#start-screen #start-quiz-button,
#start-screen .form-grid .btn {
    min-width: 220px;
    max-width: 340px;
    flex: 1 1 220px;
    padding: 16px 24px;
    font-size: 1.05rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(31, 38, 51, 0.08);
    margin: 0;
}

#start-screen #start-quiz-button {
    box-shadow: 0 18px 40px rgba(20, 81, 69, 0.18);
}

@media (max-width: 640px) {
    #start-screen .form-grid {
        flex-direction: column;
        gap: 12px;
    }

    #start-screen #start-quiz-button,
    #start-screen .form-grid .btn {
        max-width: 100%;
        min-width: 0;
        padding: 14px 18px;
        font-size: 1rem;
    }
}

.form-grid label {
    font-weight: 700;
}

.quiz-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
}

.progress-text {
    margin: 0;
    color: var(--ink-soft);
    font-weight: 700;
}

.question-description {
    margin-top: 6px;

    color: var(--ink-soft);
}

.answers-list {
    position: relative;
    margin-top: 12px;
    display: grid;
    gap: 10px;
}



.answers-list.masked .answer-option {
    background: #fff;
    border: 1px solid var(--line);
    pointer-events: auto;
    transition: border-color 0.2s, background 0.2s;
}

.answers-list.masked .answer-option input {
    opacity: 1;
}

.answer-option-content {
    position: relative;
    flex: 1;
    min-width: 0;
}

.answer-placeholders {
    display: none;
}

.answers-list.masked .answer-placeholders {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    max-width: 74%;
    pointer-events: none;
    transition: opacity 0.12s;
    opacity: var(--placeholder-opacity);
}

.answers-list.masked .answer-option:hover .answer-placeholders {
    opacity: 0;
}

.answer-placeholder-block {
    display: block;
    height: 0.52em;
    border-radius: 3px;
    background: var(--placeholder-color);
}

.answer-placeholder-block-secondary {
    background: var(--placeholder-color);
}

.answers-list .answer-option.selected {
    border-color: #a8c6b2;
    background: #f4faf6;
}

.answers-list .answer-option.selected .answer-placeholder-block,
.answers-list .answer-option.selected .answer-placeholder-block-secondary {
    background: #9fb7a5;
}

.answers-list.masked .answer-text {
    position: relative;
    display: block;
    color: transparent;
    user-select: none;
    transition: none;
}

.answers-list.masked .answer-text::after {
    content: attr(data-label);
    position: absolute;
    top: 0;
    left: 0;
    color: var(--ink);
    pointer-events: none;
    width: 100%;
    height: 100%;
    display: inline-block;
    background: transparent;
    opacity: 0;
    transition: opacity 0.12s ease;
}

/* opacidade questão */
.answers-list.masked .answer-option:hover .answer-text::after {
    opacity: 1;
}

/* Selected answer text turns light green */
.answers-list .answer-option.selected .answer-text::after {
    color: #a3bda3;
    opacity: 0;
}

/* Also when masked (reveal through mask) verde */
.answers-list.masked .answer-option.selected .answer-text::after {
    color: #a3bda3;
    opacity: 0;
}

.answers-list.masked .answer-option.selected:hover .answer-placeholders {
    opacity: var(--placeholder-opacity);
}

.answers-list.masked .answer-option:hover {
    border-color: var(--accent);
}

.answers-list.question-timeout-locked .answer-option {
    pointer-events: none;
}

.answers-list.question-timeout-locked .answer-text::after {
    display: none;
}

.answers-list.question-timeout-locked .answer-placeholders {
    display: none;
}

.answer-option {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
}

.answer-option input {
    accent-color: var(--accent);
}

.quiz-actions,
.result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.quiz-actions {
    justify-content: center;
}

#quiz-screen {
    position: relative;
    overflow: hidden;
}

.question-info-area {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
}

.question-timer {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid #d8c7a8;
    background: #f8f0e0;
    color: #6a5d4f;
    font-weight: 700;
    width: fit-content;
}

.question-timer strong {
    color: var(--warning);
    font-size: 1rem;
}

.question-timeout-notice {
    display: grid;
    gap: 12px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid #f6c7b8;
    background: #fff1ec;
    color: #8a2414;
}

.question-timeout-notice p {
    margin: 0;
    font-weight: 700;
}

.start-rules {
    margin-top: 12px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff8eb;
}

.start-rules h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.quiz-locked #quiz-content {
    display: none;
}

.policy-overlay {
    margin-top: 10px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid #f6c7b8;
    background: #fff1ec;
    color: #8a2414;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(31, 38, 51, 0.18);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: opacity 0.2s;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: #fffdf7;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(31, 38, 51, 0.13);
    padding: 32px 28px 24px 28px;
    min-width: 320px;
    max-width: 94vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.modal-card h3 {
    margin: 0 0 6px 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--danger);
}

.modal-card p {
    margin: 0 0 10px 0;
    color: var(--ink-soft);
    text-align: center;
}

.modal-actions {
    display: flex;
    gap: 14px;
    margin-top: 8px;
}

.policy-main-text {
    margin: 0;
    font-weight: 800;
}

.policy-chances-text {
    margin: 8px 0;
    font-weight: 700;
}

.policy-countdown-line {
    margin: 0 0 10px;
}

.result-already-completed {
    margin: 0 0 16px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #c8b8a0;
    background: #f8f0e0;
    color: #6a5d4f;
    font-weight: 700;
}

.result-score {
    font-size: 2rem;
    margin: 6px 0;
    font-weight: 800;
}

.result-percent {
    margin: 0;
    color: var(--accent-strong);
    font-weight: 800;
}

.result-details {
    margin-top: 12px;
    color: var(--ink-soft);
}

.teacher-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
}

.teacher-head h2 {
    margin: 0;
}

.teacher-head p {
    margin: 6px 0 0;
    color: var(--ink-soft);
}

.teacher-head-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.teacher-users-list {
    display: grid;
    gap: 12px;
}

.teacher-create-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: #fff;
    margin-bottom: 12px;
}

.teacher-create-card h3 {
    margin: 0 0 6px;
}

.teacher-create-card p {
    margin: 0 0 10px;
    color: var(--ink-soft);
}

.teacher-create-form {
    display: grid;
    gap: 10px;
}

.teacher-create-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.teacher-create-form input,
.teacher-create-form textarea,
.teacher-create-form select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}

.teacher-create-form textarea {
    resize: vertical;
    min-height: 160px;
}

.builder-questions {
    display: grid;
    gap: 12px;
}

.builder-question-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    padding: 12px;
    display: grid;
    gap: 8px;
}

.builder-question-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.builder-question-head h4 {
    margin: 0;
}

.builder-remove-question {
    background: #fde7e5;
    color: #9f2f25;
    border: 1px solid #f2b8b2;
}

.builder-remove-question:hover {
    background: #fbd8d5;
}

.builder-question-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.builder-field-label {
    display: grid;
    gap: 6px;
    font-size: 0.88rem;
    color: var(--ink-soft);
    font-weight: 700;
}

.builder-checkbox-field {
    align-content: start;
}

.builder-checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font-weight: 600;
}

.builder-checkbox-row input {
    width: auto;
    margin: 0;
}

.review-card p {
    margin: 0;
}

.review-card-correct {
    border-color: #bfd8c8;
    background: #f6fbf8;
}

.review-card-wrong {
    border-color: #efcbc4;
    background: #fff7f5;
}

.review-card-blank {
    border-color: #d8d2c7;
    background: #fbf9f5;
}

.builder-question-timer,
#builder-duration {
    border: 1px solid #cfbe9f;
    background: linear-gradient(180deg, #fffdf8 0%, #f7efe0 100%);
    color: var(--ink);
    font-weight: 700;
}

.builder-question-timer:focus,
#builder-duration:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 122, 106, 0.14);
}

.builder-options {
    display: grid;
    gap: 8px;
}

.builder-option-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
}

.builder-option-row label {
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.builder-add-option {
    justify-self: start;
}

.quiz-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quiz-card-actions .btn-sm {
    padding: 8px 12px;
    font-size: 0.85rem;
    border-radius: 10px;
}

/* Icon button group (edit / remove) */
.icon-group {
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 6px;
    border-radius: 10px;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
    display: block;
    color: inherit;
}

/* Make sure icon buttons are visually compact on small screens */
@media (max-width: 560px) {
    .icon-group {
        justify-content: flex-end;
    }
}

.quiz-review-note {
    margin: 2px 0 0;
    color: #7a6144;
    font-size: 0.85rem;
    font-weight: 700;
}

.result-blocked-note {
    margin: 18px 0 0;
    color: #7a6144;
    font-size: 0.9rem;
    font-weight: 700;
}

.btn-danger-soft {
    background: #fde7e5;
    color: #9f2f25;
    border: 1px solid #f2b8b2;
}

.btn-danger-soft:hover {
    background: #fbd8d5;
}

.teacher-user-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: #fff;
}

.teacher-user-card h3 {
    margin: 0;
}

.teacher-user-card p {
    margin: 4px 0 10px;
    color: var(--ink-soft);
}

.teacher-table-wrap {
    overflow-x: auto;
}

.teacher-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 540px;
}

.teacher-table th,
.teacher-table td {
    border-bottom: 1px solid var(--line);
    padding: 10px 8px;
    text-align: left;
    font-size: 0.92rem;
}

.teacher-table td .btn+.btn {
    margin-left: 6px;
}

.teacher-table th {
    color: var(--ink-soft);
    font-weight: 700;
}

.btn {
    border: 0;
    border-radius: 12px;
    padding: 12px 16px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(160deg, var(--accent), var(--accent-strong));
    color: #fff;
    box-shadow: 0 10px 24px rgba(20, 81, 69, 0.32);
}

.btn-primary:hover {
    transform: translateY(-1px);
}

.btn-ghost {
    background: #f3ead7;
    color: var(--ink);
}

/* disabled gray review button style */
.btn-disabled-gray {
    background: #efefef;
    color: #6b6b6b;
    border: 1px solid #e3e3e3;
    cursor: default;
    opacity: 0.95;
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 700;
}

.btn-google {
    background: #fff;
    color: #2f2f2f;
    border: 1px solid #d7d7d7;
    min-width: 240px;
    margin-top: 14px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn-google img {
    width: 20px;
    height: 20px;
}

.hidden {
    display: none !important;
}

.bg-shape {
    position: fixed;
    border-radius: 999px;
    pointer-events: none;
    opacity: 0.3;
}

.bg-shape-1 {
    width: 260px;
    height: 260px;
    background: #f5c878;
    right: 2%;
    top: 4%;
}

.bg-shape-2 {
    width: 300px;
    height: 300px;
    background: #acd0bf;
    left: -4%;
    bottom: -5%;
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 900px) {
    .quiz-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 560px) {
    body {
        padding: 12px;
    }

    #home-screen .card {
        padding: 18px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .teacher-create-grid {
        grid-template-columns: 1fr;
    }

    .builder-question-meta-grid {
        grid-template-columns: 1fr;
    }

    .builder-option-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .quiz-card-actions .btn {
        width: 100%;
    }

    .quiz-head,
    .quiz-actions,
    .result-actions,
    .teacher-head {
        flex-direction: column;
        align-items: stretch;
    }

    .quiz-card .btn,
    .btn-google {
        width: 100%;
        min-width: 100%;
    }
}

.result-retake-note {
    margin: 14px 0 0;
    color: #1a6347;
    font-size: 0.9rem;
    font-weight: 700;
    background: #e6f4ee;
    border-radius: 8px;
    padding: 10px 14px;
}