:root {
    --bg1: #fff3e0; /* warm cam background */
    --bg2: #fff8ef;
    --card: #ffffff;
    --text: #1b1b18;
    --muted: #6b5b4a;
    --line: #f1e6df;
    --brand: #f97316; /* cam (orange) */
    --brand-dark: #d35400;
    --radius: 12px; /* slightly more formal */
    --c1: #ef4444;
    --c2: #fb923c;
    --c3: #f59e0b;
    --c4: #84cc16;
    --c5: #16a34a;
}


* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    min-height: 100%;
}

body {
    font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI",
        sans-serif;
    color: var(--text);
    background: linear-gradient(135deg, var(--bg1), var(--bg2));
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    -webkit-font-smoothing: antialiased;
}

.card {
    width: 100%;
    max-width: 720px;
    background: var(--card);
    border-radius: var(--radius);
    padding: clamp(20px, 4.5vw, 44px);
    box-shadow: 0 12px 40px -12px rgba(249,115,22,0.08),
        0 1px 6px rgba(2,6,23,0.04);
    text-align: center;
}

.step {
    animation: fadeUp 0.45s ease both;
}
.step[hidden] {
    display: none;
}

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

.eyebrow {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--brand);
    background: color-mix(in srgb, var(--brand) 12%, transparent);
    padding: 6px 12px;
    border-radius: 999px;
    margin-bottom: 16px;
}

h1 {
    font-size: clamp(22px, 4.2vw, 32px);
    line-height: 1.25;
    font-weight: 700;
    margin-bottom: 8px;
}

.sub {
    color: var(--muted);
    font-size: clamp(14px, 2vw, 16px);
    line-height: 1.5;
}

/* ===== 5 mức đánh giá ===== */
.rating {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: clamp(6px, 2vw, 16px);
    margin: clamp(24px, 5vw, 36px) 0 12px;
}

.rate-btn {
    --c: var(--c3);
    appearance: none;
    background: transparent;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    padding: clamp(10px, 2.4vw, 18px) 6px clamp(10px, 1.8vw, 14px);
    cursor: pointer;
    color: var(--muted);
    font: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: transform 0.18s ease, border-color 0.18s ease,
        background 0.18s ease, box-shadow 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}

.rate-btn svg {
    width: 100%;
    max-width: 76px;
    height: auto;
    filter: grayscale(1) opacity(0.55);
    transition: filter 0.2s ease,
        transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rate-btn .lbl {
    font-size: clamp(10px, 1.7vw, 14px);
    font-weight: 500;
    line-height: 1.2;
    min-height: 2.4em;
    display: flex;
    align-items: center;
}

.rate-btn:hover svg,
.rate-btn:focus-visible svg {
    filter: none;
    transform: translateY(-3px) scale(1.08);
}

.rate-btn:hover {
    border-color: var(--c);
}

.rate-btn:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--c) 45%, transparent);
    outline-offset: 2px;
}

.rate-btn[aria-checked="true"] {
    border-color: var(--c);
    background: color-mix(in srgb, var(--c) 10%, transparent);
    color: var(--text);
    transform: translateY(-4px);
    box-shadow: 0 10px 24px -10px var(--c);
}

.rate-btn[aria-checked="true"] svg {
    filter: none;
    transform: scale(1.12);
}

.rate-btn[aria-checked="true"] .lbl {
    font-weight: 700;
}

/* ===== Nhãn đã chọn ===== */
.picked {
    min-height: 24px;
    font-size: clamp(15px, 2.2vw, 18px);
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 8px;
    transition: color 0.2s;
}

.picked.has {
    color: var(--text);
}

/* ===== Góp ý ===== */
.extra {
    text-align: left;
    margin-top: 12px;
    animation: fadeUp 0.35s ease both;
}

.extra[hidden] {
    display: none;
}

.extra label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.extra label span {
    color: var(--muted);
    font-weight: 400;
}

textarea {
    width: 100%;
    resize: vertical;
    min-height: 90px;
    padding: 14px 16px;
    font: inherit;
    font-size: 15px;
    color: var(--text);
    background: transparent;
    border: 2px solid var(--line);
    border-radius: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent);
}

.counter {
    text-align: right;
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.error {
    color: #dc2626;
    font-size: 14px;
    margin-top: 12px;
}

.error[hidden] {
    display: none;
}

/* ===== Nút ===== */
.submit,
.ghost {
    font: inherit;
    font-weight: 600;
    border: none;
    cursor: pointer;
    border-radius: 14px;
    transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease,
        box-shadow 0.2s ease;
}

.submit {
    position: relative;
    width: 100%;
    margin-top: 20px;
    padding: 16px 24px;
    font-size: 16px;
    color: #fff;
    background: var(--brand);
    box-shadow: 0 8px 20px -8px rgba(249,115,22,0.12);
}

.submit:hover:not(:disabled) {
    background: var(--brand-dark);
    transform: translateY(-1px);
}
.submit:active:not(:disabled) {
    transform: translateY(0);
}
.submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    animation: spin 0.7s linear infinite;
}

.submit.loading .btn-text {
    visibility: hidden;
}
.submit.loading .spinner {
    display: block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Màn hình cảm ơn ===== */
.done-icon svg {
    width: clamp(96px, 20vw, 130px);
    height: auto;
    margin-bottom: 16px;
    animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Countdown message on done screen */
.sub.small {
    margin-top: 8px;
    font-size: 14px;
    color: var(--muted);
}

@keyframes pop {
    from {
        transform: scale(0.3);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.ghost {
    margin-top: 28px;
    padding: 14px 24px;
    font-size: 15px;
    color: var(--brand);
    background: color-mix(in srgb, var(--brand) 10%, transparent);
}

.ghost:hover {
    background: color-mix(in srgb, var(--brand) 18%, transparent);
}

/* ===== Tablet / Mobile ===== */
@media (max-width: 768px) {
    .card {
        max-width: 560px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 12px;
        align-items: flex-start;
        padding-top: 8vh;
    }
    .card {
        border-radius: 20px;
    }
    .rate-btn {
        border-radius: 14px;
        border-width: 1.5px;
        gap: 4px;
    }
    .submit {
        padding: 15px 20px;
    }
}

@media (max-width: 340px) {
    .rate-btn .lbl {
        font-size: 9px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Force spinner animation even when user prefers reduced motion (opt-in) */
.spinner {
    /* re-enable spin explicitly; uses !important to override the global reduce-motion rule */
    animation: spin 0.7s linear infinite !important;
    -webkit-animation: spin 0.7s linear infinite !important;
}

/* ===== Login page styles (match rating theme) ===== */
.login-card {
    width: 100%;
    max-width: 520px;
    background: var(--card);
    border-radius: calc(var(--radius) + 4px);
    padding: clamp(20px, 4vw, 40px);
    box-shadow: 0 18px 60px -24px rgba(249,115,22,0.08), 0 2px 8px rgba(2,6,23,0.05);
    text-align: center;
}

.login-card .eyebrow{ display:inline-block; margin-bottom:10px; }

.login-card h1 {
    margin: 2px 0 8px;
    font-size: 22px;
    color: var(--text);
}

.login-card .sub { margin-bottom: 18px; }

.field { margin-bottom: 14px; text-align: left; }

label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--line);
    border-radius: 14px;
    font: inherit;
    font-size: 15px;
    color: var(--text);
    background: transparent;
    transition: border-color 0.18s, box-shadow 0.18s, transform 0.08s;
}

input[type="text"]:focus, input[type="password"]:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--brand) 10%, transparent);
    transform: translateY(-2px);
}

.submit {
    font: inherit;
    font-weight: 700;
    border: none;
    cursor: pointer;
    border-radius: 14px;
    padding: 14px 18px;
    background: linear-gradient(90deg, var(--brand), var(--brand-dark));
    color: #fff;
    box-shadow: 0 14px 36px -18px rgba(249,115,22,0.14), 0 6px 18px rgba(2,6,23,0.06);
    width: 100%;
    margin-top: 8px;
}

.submit:disabled { opacity: 0.6; cursor: not-allowed; }

#loginSpinner { margin-left: 8px; }

.error { color: #dc2626; margin-top: 10px; display: none; }
.error.show { display: block; }

.small { font-size: 13px; color: var(--muted); margin-top: 12px; }

/* Center login card on background similar to rating card */
body > main.login-card {
    display: block;
}

@media (max-width: 480px) {
    .login-card { padding: 14px; border-radius: 18px; }
    input[type="text"], input[type="password"] { padding: 12px; }
}

/* Tablet / small laptop: prevent page-level scrolling by making the card fit viewport
   and using internal scrolling when content overflows. This avoids horizontal/vertical
   body scroll on tablet test devices. */
@media (min-width: 600px) and (max-width: 1280px) {
    html, body {
        height: 100dvh; /* fill viewport height */
        overflow: hidden; /* prevent body scroll */
    }
    body {
        align-items: center;
        justify-content: center;
        padding: 0; /* keep card fully visible */
    }
    .card {
        width: calc(100% - 32px);
        max-width: 900px;
        max-height: calc(100dvh - 32px);
        margin: 16px;
        overflow-y: auto; /* internal scroll if content taller than card */
        -webkit-overflow-scrolling: touch;
    }
    /* Slightly reduce gaps to fit more comfortably on tablets */
    .rating { gap: clamp(8px, 2vw, 12px); }
}

