/* ==========================================================================
   EMASI VẠN PHÚC - MINIGAME TRUNG THU & LUCKY DRAW
   Premium Responsive Design System
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400;1,600&family=Outfit:wght@600;700;800;900&display=swap');

:root {
    /* Màu sắc chuẩn nhận diện EMASI (https://www.emasi.edu.vn/) */
    --primary-navy: #00364D;      /* Xanh đậm chủ đạo EMASI */
    --primary-blue: #005D83;      /* Xanh dương thương hiệu EMASI */
    --primary-dark: #002433;
    --accent-cyan: #84CFF7;       /* Xanh nhạt thương hiệu */
    --accent-lime: #BFD730;       /* Xanh cốm đặc trưng EMASI */
    --accent-gold: #FBB03B;       /* Vàng lễ hội Trung Thu */
    --accent-gold-hover: #E59C28;
    --accent-red: #E74C3C;
    --bg-overlay: rgba(0, 38, 54, 0.76);
    --glass-bg: rgba(255, 255, 255, 0.94);
    --glass-border: rgba(255, 255, 255, 0.7);
    --card-shadow: 0 20px 45px rgba(0, 36, 51, 0.3), 0 8px 16px rgba(0, 0, 0, 0.15);
    --card-hover-shadow: 0 25px 50px rgba(0, 36, 51, 0.4);
    --font-heading: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 10px;
    --transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset cơ bản */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-body);
    color: #222222;
    background-color: #002433;
    background-image: linear-gradient(var(--bg-overlay), var(--bg-overlay)), url('../Artboard 1.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px 15px;
    overflow-x: hidden;
}

/* Top Header Bar */
.app-header {
    width: 100%;
    max-width: 900px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 24px;
    background: rgba(0, 54, 77, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    box-shadow: 0 8px 24px rgba(0, 36, 51, 0.35);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.emasi-brand-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
    display: block;
}

.brand-campus-divider {
    width: 1.5px;
    height: 24px;
    background: rgba(255, 255, 255, 0.35);
}

.brand-campus-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 14px;
    color: #FFFFFF;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.btn-admin-trigger {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-body);
}

.btn-admin-trigger:hover {
    background: var(--accent-lime);
    color: #00364D;
    border-color: var(--accent-lime);
    transform: translateY(-1px);
}

/* Container chính của ứng dụng */
.main-container {
    width: 100%;
    max-width: 860px;
    position: relative;
}

/* Các màn hình chính */
.screen-panel {
    display: none;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    padding: 36px 32px;
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.screen-panel.active-screen {
    display: block;
}

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

/* Decorative Header inside Panel */
.panel-header {
    text-align: center;
    margin-bottom: 28px;
}

.festival-tag {
    display: inline-block;
    background: linear-gradient(135deg, #17355D, #005D83);
    color: #fbb03b;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 6px 16px;
    border-radius: 20px;
    margin-bottom: 12px;
    box-shadow: 0 4px 10px rgba(0, 93, 131, 0.25);
}

.panel-title {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 800;
    color: var(--primary-navy);
    line-height: 1.25;
    margin-bottom: 8px;
}

.panel-subtitle {
    font-size: 15px;
    color: #5A6A85;
    line-height: 1.5;
}

/* ==========================================================================
   MÀN HÌNH 1: FORM ĐĂNG KÝ
   ========================================================================== */
.form-card {
    max-width: 580px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 22px;
    text-align: left;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-navy);
    margin-bottom: 8px;
}

.form-label .required {
    color: var(--accent-red);
}

.form-control {
    width: 100%;
    padding: 14px 18px;
    font-size: 15px;
    font-family: var(--font-body);
    background: #F8FAFC;
    border: 2px solid #E2E8F0;
    border-radius: var(--radius-sm);
    color: #1E293B;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    background: #FFFFFF;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 4px rgba(41, 171, 226, 0.15);
}

select.form-control {
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2317355D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 18px;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 44px;
}

.form-error {
    background: #FEE2E2;
    color: #B91C1C;
    border: 1px solid #FCA5A5;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 20px;
    display: none;
}

/* Nút bấm chung */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 32px;
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.btn-primary {
    background: linear-gradient(135deg, #17355D, #005D83);
    color: #FFFFFF;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1c4172, #0072a0);
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(23, 53, 93, 0.35);
}

.btn-gold {
    background: linear-gradient(135deg, #fbb03b, #ff9f1c);
    color: #17355D;
}

.btn-gold:hover {
    background: linear-gradient(135deg, #ffb84a, #ffa72b);
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(251, 176, 59, 0.45);
}

.btn-success {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: #FFFFFF;
}

.btn-success:hover {
    background: linear-gradient(135deg, #219653, #27ae60);
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(46, 204, 113, 0.35);
}

.btn-secondary {
    background: #E2E8F0;
    color: #475569;
}

.btn-secondary:hover {
    background: #CBD5E1;
}

.btn-block {
    width: 100%;
}

/* ==========================================================================
   MÀN HÌNH 2: BÀI TRẮC NGHIỆM
   ========================================================================== */
.quiz-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.grade-pill {
    background: #EBF8FF;
    color: #005D83;
    border: 1px solid #BEE3F8;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
}

.progress-info {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-navy);
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #E2E8F0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 28px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #29abe2, #fbb03b);
    width: 33.33%;
    border-radius: 10px;
    transition: width 0.4s ease;
}

.question-box {
    margin-bottom: 24px;
    text-align: center;
}

.question-title {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-navy);
    line-height: 1.4;
    margin-bottom: 20px;
}

.question-image-box {
    max-width: 480px;
    margin: 0 auto 24px auto;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    padding: 8px;
}

.question-image-box img {
    width: 100%;
    max-height: 280px;
    object-fit: contain;
    border-radius: 12px;
    display: block;
}

/* Lưới đáp án */
.quiz-options {
    display: grid;
    gap: 16px;
    margin-bottom: 30px;
}

.text-options-grid {
    grid-template-columns: 1fr;
}

@media (min-width: 600px) {
    .text-options-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.image-options-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.quiz-option-card {
    background: #FFFFFF;
    border: 2px solid #E2E8F0;
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}

.quiz-option-card:hover {
    border-color: var(--accent-cyan);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(41, 171, 226, 0.12);
}

.quiz-option-card.selected {
    border-color: var(--primary-blue);
    background: #F0F9FF;
    box-shadow: 0 0 0 3px rgba(0, 93, 131, 0.25);
}

.opt-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #EDF2F7;
    color: var(--primary-navy);
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    transition: var(--transition);
}

.quiz-option-card.selected .opt-badge {
    background: var(--primary-blue);
    color: #FFFFFF;
}

.opt-img-wrap {
    width: 100%;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.opt-img-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.opt-text {
    font-size: 16px;
    font-weight: 600;
    color: #2D3748;
    text-align: center;
}

.quiz-nav-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

/* ==========================================================================
   MÀN HÌNH 3: KẾT QUẢ & CHẤM ĐIỂM
   ========================================================================== */
.result-card {
    text-align: center;
    max-width: 520px;
    margin: 0 auto;
    padding: 20px 10px;
}

.icon-badge {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin-bottom: 20px;
}

.icon-badge.pass {
    background: linear-gradient(135deg, #fbb03b, #ff7e47);
    color: #FFFFFF;
    box-shadow: 0 12px 28px rgba(251, 176, 59, 0.4);
}

.icon-badge.fail {
    background: #EDF2F7;
    color: #718096;
}

.score-display-box {
    display: inline-block;
    background: #F7FAFC;
    border: 2px dashed #CBD5E0;
    padding: 12px 30px;
    border-radius: var(--radius-sm);
    margin: 16px 0 20px 0;
}

.score-label {
    font-size: 13px;
    font-weight: 700;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-number {
    font-family: var(--font-heading);
    font-size: 38px;
    font-weight: 900;
    color: var(--primary-navy);
}

.result-title {
    font-family: var(--font-heading);
    font-size: 30px;
    font-weight: 800;
    margin-bottom: 12px;
}

.result-title.pass {
    color: #10B981;
}

.result-title.fail {
    color: #EF4444;
}

.result-desc {
    font-size: 16px;
    color: #4B5563;
    line-height: 1.6;
    margin-bottom: 32px;
}

/* ==========================================================================
   MÀN HÌNH 4: VÒNG QUAY MAY MẮN (LUCKY DRAW)
   ========================================================================== */
.wheel-screen-content {
    text-align: center;
}

.player-greeting-bar {
    display: inline-block;
    background: linear-gradient(135deg, #17355D, #005D83);
    color: #FFFFFF;
    font-size: 16px;
    font-weight: 700;
    padding: 8px 24px;
    border-radius: 30px;
    margin-bottom: 20px;
    box-shadow: 0 4px 14px rgba(23, 53, 93, 0.25);
}

.wheel-outer-wrapper {
    position: relative;
    width: 480px;
    height: 480px;
    max-width: 90vw;
    max-height: 90vw;
    margin: 15px auto 30px auto;
}

#wheelCanvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
    background: #ffffff;
    display: block;
}

/* Kim chỉ cố định ở góc 3h (bên phải, hướng sang tâm vòng quay) */
.wheel-pointer-pin {
    position: absolute;
    top: 50%;
    right: -24px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 22px solid transparent;
    border-bottom: 22px solid transparent;
    border-right: 44px solid #EF4444;
    filter: drop-shadow(-3px 2px 5px rgba(0, 0, 0, 0.35));
    z-index: 10;
    pointer-events: none;
}

.spin-action-area {
    margin-top: 10px;
}

.btn-big-spin {
    padding: 16px 48px;
    font-size: 22px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.btn-big-spin:disabled {
    background: #CBD5E1 !important;
    color: #94A3B8 !important;
    box-shadow: none !important;
    cursor: not-allowed;
    transform: none !important;
}

/* ==========================================================================
   MODAL CHIẾN THẮNG & NHẬN QUÀ
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(12, 28, 51, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 999;
}

.modal-overlay.active {
    display: flex;
    animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

.modal-dialog {
    background: #FFFFFF;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    max-width: 500px;
    width: 100%;
    padding: 40px 32px;
    text-align: center;
    position: relative;
    border: 3px solid var(--accent-gold);
}

.win-icon {
    font-size: 64px;
    margin-bottom: 12px;
}

.win-title {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 800;
    color: var(--primary-navy);
    margin-bottom: 8px;
}

.win-player {
    font-size: 18px;
    color: #4B5563;
    margin-bottom: 20px;
}

.prize-highlight-box {
    background: linear-gradient(135deg, #FFFBEB, #FEF3C7);
    border: 2px dashed #F59E0B;
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 28px;
}

.prize-highlight-box .lbl {
    font-size: 13px;
    font-weight: 700;
    color: #92400E;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.prize-highlight-box .prize-name {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 900;
    color: #B45309;
    margin-top: 4px;
}

/* ==========================================================================
   MODAL ADMIN QUẢN TRỊ
   ========================================================================== */
.admin-modal-dialog {
    max-width: 820px;
    padding: 30px;
    text-align: left;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #E2E8F0;
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.admin-title {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 800;
    color: var(--primary-navy);
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 24px;
    color: #718096;
    cursor: pointer;
    line-height: 1;
}

.admin-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #E2E8F0;
}

.admin-tab-btn {
    background: none;
    border: none;
    padding: 10px 18px;
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    color: #64748B;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}

.admin-tab-btn.active {
    color: var(--primary-navy);
    border-bottom-color: var(--accent-gold);
}

.admin-tab-content {
    display: none;
    overflow-y: auto;
    flex: 1;
}

.admin-tab-content.active {
    display: block;
}

/* Bảng dữ liệu Admin */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 14px;
}

.admin-table th {
    background: #F1F5F9;
    color: #334155;
    font-weight: 700;
    padding: 12px 14px;
    border: 1px solid #E2E8F0;
    text-align: left;
}

.admin-table td {
    padding: 12px 14px;
    border: 1px solid #E2E8F0;
    color: #1E293B;
}

.color-preview {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid #CBD5E1;
    vertical-align: middle;
}

.prize-qty-input {
    width: 80px;
    padding: 6px 10px;
    text-align: center;
    font-weight: 700;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}

.badge-success { background: #DCFCE7; color: #166534; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-primary { background: #DBEAFE; color: #1E40AF; }

.admin-action-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

/* Canvas Confetti cố định toàn màn hình */
#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1000;
    display: none;
}

/* Responsive adjustments */
@media (max-width: 650px) {
    .screen-panel {
        padding: 24px 18px;
        border-radius: var(--radius-md);
    }

    .panel-title {
        font-size: 24px;
    }

    .question-title {
        font-size: 19px;
    }

    .wheel-outer-wrapper {
        width: 320px;
        height: 320px;
    }

    .btn {
        padding: 12px 24px;
        font-size: 15px;
    }

    .btn-big-spin {
        font-size: 18px;
        padding: 14px 32px;
    }
}
