:root {
    --bg-gradient-start: #2acde6;
    --bg-gradient-end: #0f8fb8;
    --left-panel-bg: rgba(255, 255, 255, 0);
    --right-panel-bg: rgba(18, 55, 99, 0.85);
    
    --card-bg: #4a6a96;
    --card-selected-bg: #ffffff;
    --card-selected-text: #333333;
    --card-text: #ffffff;
    
    --accent-yellow: #d8ea41;
    --accent-yellow-dark: #b5c730;
    
    --text-main: #ffffff;
    --font-ui: 'Nunito', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-ui);
}

body {
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Background grid/scanline for realism */
body::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    z-index: 0;
}

.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 40px;
    position: relative;
    z-index: 10;
}

/* HEADER */
.top-nav {
    display: flex;
    align-items: center;
    padding: 10px 0 20px 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-icon {
    width: 24px;
    height: 24px;
    background: #fff;
    border-radius: 4px;
    position: relative;
}
.logo-icon::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 12px; height: 12px;
    background: var(--bg-gradient-start);
    border-radius: 50%;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 2px;
    color: #fff;
    text-transform: uppercase;
}

/* MAIN LAYOUT */
.main-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.view-section {
    display: flex;
    height: 100%;
    opacity: 1;
    transition: opacity 0.5s ease;
    border-radius: 20px;
    overflow: hidden;
}

.view-section.hidden {
    display: none;
    opacity: 0;
}

.panel {
    position: relative;
}

/* LEFT PANEL */
.left-panel {
    flex: 1.2;
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
}

.bg-scanlines {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.05) 2px,
        rgba(0, 0, 0, 0.05) 4px
    );
    z-index: -1;
}

.hologram-stage {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-height: 50%;
    margin-top: -20px;
    position: relative;
    perspective: 800px;
}

.hologram-platform {
    position: absolute;
    bottom: -15px;
    width: 260px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(120, 240, 255, 0.4) 0%, rgba(120, 240, 255, 0) 70%);
    box-shadow: 0 0 20px rgba(120, 240, 255, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

.platform-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid rgba(180, 255, 255, 0.8);
    box-shadow: 0 0 10px rgba(150, 255, 255, 0.6), inset 0 0 10px rgba(150, 255, 255, 0.6);
}

.platform-ring.outer {
    width: 220px;
    height: 40px;
}

.platform-ring.inner {
    width: 90px;
    height: 16px;
    border-width: 2px;
}

.platform-center {
    width: 10px;
    height: 4px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 15px 5px rgba(255,255,255,0.8);
}

#poly-image-container {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: 25px;
}

#poly-image-container img {
    width: 100%;
    height: 100%;
    max-width: 400px;
    max-height: 400px;
    object-fit: contain;
    filter: drop-shadow(0 0 25px rgba(255, 255, 200, 0.9)) drop-shadow(0 0 10px rgba(255, 255, 255, 1));
    animation: bounce 4s ease-in-out infinite;
}

.poly-info-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: -10px;
    z-index: 2;
}

.pill-id {
    background: #113355;
    color: #fff;
    padding: 6px 20px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    margin-bottom: 5px;
}

.pill-id::before {
    content: '';
    display: block;
    width: 14px;
    height: 14px;
    background: radial-gradient(circle at 30% 30%, #ff5555 0%, #cc0000 100%);
    border-radius: 50%;
    border: 2px solid #fff;
}

.poly-name {
    font-size: 3rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 4px 10px rgba(0,0,0,0.2);
    letter-spacing: 1px;
}

.clean-stats {
    width: 100%;
    max-width: 600px;
    margin-top: 30px;
    padding: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 15px 10px;
    backdrop-filter: blur(10px);
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: rgba(255,255,255,0.8);
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 900;
    color: #fff;
}

/* RIGHT PANEL */
.right-panel {
    flex: 1.5;
    background: var(--right-panel-bg);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    padding: 25px 30px 30px 10px;
    box-shadow: -10px 0 30px rgba(0,0,0,0.2);
}

.right-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-left: 20px;
}

.grid-stats {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 800;
}

.record-icon {
    width: 18px;
    height: 18px;
    background: radial-gradient(circle at 30% 30%, #ff5555 0%, #cc0000 100%);
    border-radius: 50%;
    border: 3px solid #fff;
}

.sort-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    border-radius: 20px;
    transition: background 0.2s;
}

.sort-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon {
    display: inline-block;
    background: #fff;
    color: var(--right-panel-bg);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    font-size: 1rem;
    font-weight: 900;
}

.scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px;
}

.scroll-container::-webkit-scrollbar {
    width: 8px;
}

.scroll-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.scroll-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}

.poly-card {
    background: var(--card-bg);
    border-radius: 12px;
    height: 110px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: visible;
}

.poly-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.poly-card.active {
    background: var(--card-selected-bg);
    box-shadow: 0 0 0 3px var(--accent-yellow);
}

.poly-card.active::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 12px solid var(--accent-yellow);
    z-index: 10;
}

.card-image {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0px;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
    transform: scale(1.5);
    transition: transform 0.2s ease;
}

.poly-card.active .card-image img {
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.3));
    transform: scale(1.65);
}

.card-id-strip {
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 0.85rem;
    font-weight: 800;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.poly-card.active .card-id-strip {
    color: var(--card-selected-text);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.card-id-strip .icon {
    width: 10px;
    height: 10px;
    background: radial-gradient(circle at 30% 30%, #ff5555 0%, #cc0000 100%);
    border-radius: 50%;
    border: 1px solid #fff;
    display: inline-block;
}

.poly-card.active .card-id-strip .icon {
    border-color: #333;
}

/* QUIZ VIEW */
.full-panel {
    background: var(--right-panel-bg);
    width: 100%;
    padding: 40px;
    display: flex;
    flex-direction: column;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(255,255,255,0.1);
    padding-bottom: 20px;
    margin-bottom: 40px;
}

.quiz-header h2 {
    font-size: 2.2rem;
    font-weight: 900;
}

.score-tracker {
    font-size: 1.5rem;
    font-weight: 700;
}

.score-tracker .highlight {
    color: var(--accent-yellow);
    font-size: 2rem;
    margin-left: 10px;
}

.quiz-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

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

.question-box h3 {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.3;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    width: 100%;
    margin-bottom: 40px;
}

.option-btn {
    background: var(--card-bg);
    border: none;
    color: #fff;
    padding: 20px;
    font-size: 1.3rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.option-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
    background: #5c7fae;
}

.option-btn.correct {
    background: #3ec974;
}

.option-btn.wrong {
    background: #e64a4a;
}

.feedback-area {
    text-align: center;
}

.feedback-text {
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 20px;
}

.feedback-text.success { color: #3ec974; }
.feedback-text.error { color: #e64a4a; }

.action-btn {
    background: #fff;
    color: var(--right-panel-bg);
    border: none;
    padding: 12px 30px;
    font-size: 1.2rem;
    font-weight: 800;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s;
}

.action-btn:hover {
    transform: scale(1.05);
}

.question-tracker {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--accent-yellow);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.quiz-results {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.results-title {
    font-size: 3rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 4px 10px rgba(0,0,0,0.3);
    margin-bottom: 30px;
    text-align: center;
}

.results-score {
    background: rgba(255, 255, 255, 0.15);
    padding: 40px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    text-align: center;
    margin-bottom: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    border: 2px solid rgba(255,255,255,0.2);
}

.results-score h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: rgba(255, 255, 255, 0.9);
}

.final-score {
    font-size: 5rem;
    font-weight: 900;
    color: var(--accent-yellow);
    text-shadow: 0 5px 15px rgba(216, 234, 65, 0.4);
}

.results-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.action-btn.primary-action {
    background: var(--accent-yellow);
    color: #333;
    font-size: 1.3rem;
    padding: 15px 40px;
}

.action-btn.primary-action:hover {
    background: #fff;
    transform: scale(1.1);
}

.action-btn.secondary-action {
    background: transparent;
    border: 2px solid #fff;
    color: #fff;
}

.action-btn.secondary-action:hover {
    background: rgba(255,255,255,0.1);
    transform: scale(1.05);
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

@media (max-width: 900px) {
    /* Benarkan body dan wrapper memanjang ke bawah dan ditatal */
    body { 
        height: auto; 
        overflow-y: auto; 
    }
    .app-wrapper { 
        padding: 15px; 
        height: auto; 
        min-height: 100vh; 
    }
    
    /* Ubah susunan panel kepada atas-bawah */
    .view-section { 
        flex-direction: column; 
        height: auto; 
        overflow: visible;
    }
    
    /* Buang had ketinggian supaya panel menyokong kandungan */
    .left-panel { 
        flex: none; 
        padding: 20px 10px; 
        min-height: auto; 
    }
    .right-panel { 
        flex: none; 
        min-height: auto; 
        margin-top: 20px; 
        padding: 20px;
    }

    /* Ubah container kad supaya tidak terperangkap dalam kotak berasingan */
    .scroll-container {
        overflow-y: visible; 
    }
    
    .stats-grid { 
        grid-template-columns: repeat(2, 1fr); 
        gap: 10px; 
    }
    .poly-name { font-size: 2.2rem; }
    .options-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    /* Kemaskini Header */
    .top-nav {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    .action-btn {
        width: 100%;
        text-align: center;
    }

    /* Kecilkan Hologram Stage */
    .hologram-platform {
        width: 200px;
        height: 40px;
    }
    .platform-ring.outer {
        width: 170px;
        height: 30px;
    }
    #poly-image-container img {
        max-width: 200px;
        max-height: 200px;
    }

    /* Ubah saiz Teks dan Stat */
    .poly-name {
        font-size: 1.8rem;
    }
    .stat-value {
        font-size: 1.3rem;
    }

    /* Kemaskini Grid Kad Poligon */
    .cards-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 kad sebaris untuk telefon */
        gap: 10px;
    }
    .poly-card {
        height: 90px; /* Jadikan kad sedikit rendah */
    }
    .card-id-strip {
        font-size: 0.75rem;
    }

    /* Antaramuka Kuiz */
    .full-panel {
        padding: 20px 15px;
    }
    .quiz-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    .quiz-header h2 {
        font-size: 1.5rem;
    }
    .question-box h3 {
        font-size: 1.4rem;
    }
    .results-title {
        font-size: 2rem;
    }
    .final-score {
        font-size: 4rem;
    }
    .results-actions {
        flex-direction: column;
    }
}
