/* Base Variables */
:root {
    --primary: #0EA5E9;
    --primary-hover: #0284C7;
    --secondary: #38BDF8;
    --accent: #7DD3FC;
    --bg-color: #0C1929;
    --surface: rgba(15, 30, 48, 0.7);
    --surface-hover: rgba(15, 30, 48, 0.9);
    --border: rgba(56, 189, 248, 0.2);
    --text-active: #E0F2FE;
    --text-muted: #94A3B8;
    --success: #10B981;
    --danger: #EF4444;
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-active);
    min-height: 100vh;
    display: flex;
    background-image: radial-gradient(circle at top right, rgba(14, 165, 233, 0.1), transparent 400px),
        radial-gradient(circle at bottom left, rgba(125, 211, 252, 0.05), transparent 400px);
}

/* Utilities */
.app-container {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.glass {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.grid {
    display: grid;
}

.gap-4 {
    gap: 16px;
}

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

.mt-3 {
    margin-top: 12px;
}

.mt-4 {
    margin-top: 16px;
}

.mt-5 {
    margin-top: 24px;
}

.text-muted {
    color: var(--text-muted);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    overflow-y: auto;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
    background: transparent;
    color: inherit;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-accent {
    background: var(--secondary);
    color: var(--bg-color);
}

.btn-accent:hover {
    background: var(--accent);
}

.btn-outline {
    border: 1px solid var(--border);
    color: var(--text-active);
}

.btn-outline:hover {
    background: rgba(56, 189, 248, 0.1);
    border-color: var(--secondary);
}

.btn-icon {
    padding: 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-danger {
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.btn-block {
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group.row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    color: var(--text-active);
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
}

textarea.form-control {
    resize: vertical;
}

select.form-control {
    appearance: none;
    cursor: pointer;
}

/* Home Screen */
#screen-home {
    padding: 40px 24px;
    max-width: 1000px;
    margin: 0 auto;
}

.hero {
    text-align: center;
    margin-bottom: 48px;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 16px 0 8px;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.icon-wrap {
    width: 64px;
    height: 64px;
    margin: 0 auto;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.3);
}

.dashboard {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 48px;
}

.action-card {
    padding: 32px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, border-color 0.2s;
}

.action-card:hover {
    transform: translateY(-4px);
    background: rgba(56, 189, 248, 0.05);
    border-color: var(--secondary);
}

.action-label {
    cursor: pointer;
    display: block;
    width: 100%;
    height: 100%;
}

.action-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background: rgba(14, 165, 233, 0.1);
    color: var(--secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.action-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.section-title h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.quiz-card {
    padding: 20px;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.quiz-card:hover {
    transform: translateY(-3px);
    border-color: var(--secondary);
}

.quiz-card h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.quiz-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 16px;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.quiz-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: var(--accent);
}

.quiz-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Top Nav */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: rgba(12, 25, 41, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.top-nav h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.nav-actions {
    display: flex;
    gap: 12px;
}

/* Builder */
.builder-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 65px);
}

.builder-sidebar {
    width: 320px;
    border-right: 1px solid var(--border);
    border-radius: 0;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.builder-main {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    border-radius: 0;
    border: none;
    background: transparent;
}

.divider {
    border: 0;
    height: 1px;
    background: var(--border);
    margin: 24px 0;
}

.question-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.question-list-header h3 {
    font-size: 1rem;
    color: var(--secondary);
}

.sidebar-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-item {
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    gap: 12px;
}

.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-item.active {
    background: rgba(14, 165, 233, 0.1);
    border-color: var(--primary);
}

.sidebar-item-num {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary);
}

.sidebar-item-text {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Builder Editor */
.empty-state {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.editor-content {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.2);
    padding: 32px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.options-container {
    background: rgba(255, 255, 255, 0.02);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 24px;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-item {
    display: flex;
    gap: 12px;
    align-items: center;
}

.option-radio {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
}

.btn-remove {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
}

.btn-remove:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.tf-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.radio-card {
    cursor: pointer;
    position: relative;
}

.radio-card input {
    position: absolute;
    opacity: 0;
}

.radio-card span {
    display: block;
    text-align: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 500;
    transition: var(--transition);
}

.radio-card input:checked+span {
    background: rgba(14, 165, 233, 0.15);
    border-color: var(--primary);
    color: var(--secondary);
}

/* Player */
#screen-player {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.player-nav {
    justify-content: flex-start;
    gap: 24px;
    background: transparent;
    border-bottom: none;
}

.timeline {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
}

.progress-bar-wrap {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--secondary);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.9rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.timer {
    font-size: 1.1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
    padding: 4px 12px;
    background: rgba(14, 165, 233, 0.1);
    border-radius: 20px;
}

.player-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.question-card {
    max-width: 800px;
    width: 100%;
    padding: 40px;
}

.q-header {
    margin-bottom: 24px;
}

.q-badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.q-text {
    font-size: 1.8rem;
    line-height: 1.4;
    margin-bottom: 32px;
    font-weight: 600;
}

.player-answers {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.answer-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--border);
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 1.1rem;
    text-align: left;
    transition: var(--transition);
    cursor: pointer;
    color: var(--text-active);
}

.answer-btn:hover:not(:disabled) {
    background: rgba(14, 165, 233, 0.1);
    border-color: var(--secondary);
    transform: translateX(8px);
}

.answer-btn:disabled {
    cursor: default;
}

.answer-btn.selected {
    border-color: var(--primary);
    background: rgba(14, 165, 233, 0.2);
}

.answer-btn.correct {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.answer-btn.wrong {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Fill in blank input */
.fill-in-wrap {
    display: flex;
    gap: 12px;
}

.fill-in-wrap input {
    flex: 1;
    font-size: 1.2rem;
    padding: 16px 24px;
}

.fill-in-wrap button {
    white-space: nowrap;
    font-size: 1.1rem;
    padding: 0 32px;
}

/* Feedback */
.feedback-panel {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
    animation: fadeIn 0.4s ease;
}

.feedback-content h3 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.feedback-content h3.text-success {
    color: var(--success);
}

.feedback-content h3.text-danger {
    color: var(--danger);
}

.feedback-content p {
    color: var(--text-muted);
    line-height: 1.6;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Results */
.results-layout {
    max-width: 900px;
    margin: 40px auto;
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 32px;
    padding: 0 24px;
}

.score-overview {
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-circle {
    width: 160px;
    height: 160px;
    position: relative;
    margin: 32px 0;
}

.circular-chart {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

.circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 3.8;
}

.circle {
    fill: none;
    stroke-width: 2.8;
    stroke-linecap: round;
    transition: stroke-dasharray 1.5s ease-out;
    stroke: var(--secondary);
}

.score-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-text span {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-active);
}

.score-text small {
    color: var(--text-muted);
    font-size: 1rem;
}

.results-msg {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--accent);
}

.results-breakdown {
    padding: 32px;
    max-height: 500px;
    overflow-y: auto;
}

.results-breakdown h3 {
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.breakdown-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.breakdown-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border-left: 4px solid transparent;
}

.breakdown-item.correct {
    border-left-color: var(--success);
}

.breakdown-item.wrong {
    border-left-color: var(--danger);
}

.breakdown-icon {
    padding-top: 4px;
}

.breakdown-content h4 {
    font-size: 1rem;
    margin-bottom: 4px;
    font-weight: 500;
}

.breakdown-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.breakdown-content p strong {
    color: var(--text-active);
}

@media (max-width: 768px) {
    .builder-layout {
        flex-direction: column;
        overflow-y: auto;
    }

    .builder-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .results-layout {
        grid-template-columns: 1fr;
    }
}