:root {
    --primary: #4A90D9;
    --primary-dark: #3572B0;
    --accent: #FF8C42;
    --accent-dark: #E67730;
    --success: #27AE60;
    --error: #E74C3C;
    --warning: #F39C12;
    --bg: #F5F7FA;
    --card: #FFFFFF;
    --text: #2C3E50;
    --text-light: #7F8C8D;
    --border: #E0E6ED;
    --coin: #FFD700;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 16px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 12px 24px;
}

/* Header */
#header {
    position: sticky;
    top: 0;
    background: var(--card);
    padding: 12px 16px;
    margin: 0 -12px 16px;
    box-shadow: var(--shadow);
    z-index: 100;
    border-radius: 0 0 var(--radius) var(--radius);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.logo-btn {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
    background: none;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.logo-btn:hover {
    border-color: var(--primary);
    background: #EBF5FF;
}

.logo-btn:active {
    transform: scale(0.95);
    background: #D6EAFF;
}

.logo-btn span {
    color: var(--accent);
    font-weight: 600;
}

.coins-display {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #FFF8E1, #FFECB3);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 16px;
    color: #F57F17;
    box-shadow: 0 2px 8px rgba(255,215,0,0.3);
}

.coin-icon {
    font-size: 18px;
}

.progress-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.progress-step {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    transition: all 0.3s;
}

.progress-step.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(74,144,217,0.4);
}

.progress-step.done {
    background: var(--success);
    color: white;
}

.progress-step:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.progress-step:active {
    transform: scale(0.95);
}

.progress-line {
    width: 40px;
    height: 3px;
    background: var(--border);
    transition: background 0.3s;
}

.progress-line.done {
    background: var(--success);
}

/* Screens */
.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.module-badge {
    display: inline-block;
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    padding: 4px 14px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
    margin-right: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.module-badge-2 {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
}

.level-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 4px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}

.level-badge-test {
    background: linear-gradient(135deg, #f093fb, #f5576c);
}

.level-badge-independent {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
}

h1 {
    font-size: 28px;
    text-align: center;
    margin-bottom: 8px;
    color: var(--primary);
}

h2 {
    font-size: 20px;
    margin-bottom: 12px;
}

.subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 15px;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Intro */
.intro-card {
    text-align: center;
    padding: 28px 20px;
}

.intro-illustration {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-size: 48px;
    margin: 16px 0;
}

.description {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-light);
    margin-bottom: 20px;
}

/* Toggle */
.anonymity-toggle {
    margin: 16px 0;
    padding: 12px;
    background: #F8FAFC;
    border-radius: 12px;
}

.toggle-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ccc;
    border-radius: 26px;
    transition: 0.3s;
}

.slider:before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .slider {
    background: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.toggle-hint {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 6px;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 3px 12px rgba(74,144,217,0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(74,144,217,0.4);
}

.btn-secondary {
    background: var(--bg);
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-lg {
    width: 100%;
    padding: 14px;
    font-size: 17px;
}

.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.btn-row .btn {
    flex: 1;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Tariff Info */
.tariff-info, .tariff-reminder {
    background: linear-gradient(135deg, #EBF5FF, #E1F0FF);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.7;
    border-left: 4px solid var(--primary);
}

.tariff-info b, .tariff-reminder b {
    color: var(--primary);
}

/* Chart */
.chart-container {
    position: relative;
    margin: 16px -8px;
    padding: 0;
    background: #FAFBFC;
    border-radius: 12px;
    overflow: hidden;
}

.chart-container canvas {
    width: 100% !important;
    height: 280px !important;
}

/* Table */
.table-container {
    overflow-x: auto;
    margin: 12px 0;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 10px;
    overflow: hidden;
    font-size: 14px;
}

.data-table th {
    background: var(--primary);
    color: white;
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 12px;
}

.data-table td {
    padding: 8px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table input {
    width: 60px;
    padding: 6px 4px;
    border: 2px solid var(--border);
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    transition: border-color 0.2s;
}

.data-table input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74,144,217,0.15);
}

.data-table input.correct {
    border-color: var(--success);
    background: #E8F8F0;
}

.data-table input.wrong {
    border-color: var(--error);
    background: #FDEDEC;
}

.data-table .month-btn {
    background: none;
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.data-table .month-btn.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Task Description */
.task-description {
    background: #FFF8E1;
    border-radius: 12px;
    padding: 14px;
    margin: 12px 0;
    font-size: 14px;
    line-height: 1.6;
    border-left: 4px solid var(--warning);
}

/* Calc Block */
.calc-block {
    margin: 16px 0;
}

.calc-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.calc-row label {
    font-size: 14px;
    min-width: 120px;
    color: var(--text);
}

.calc-row input, .calc-row select {
    flex: 1;
    min-width: 80px;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}

.calc-row input:focus, .calc-row select:focus {
    outline: none;
    border-color: var(--primary);
}

.calc-row .unit {
    font-size: 13px;
    color: var(--text-light);
}

/* Feedback */
.feedback {
    margin-top: 12px;
    padding: 0;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    transition: all 0.3s;
    overflow: hidden;
    max-height: 0;
}

.feedback.show {
    padding: 14px;
    max-height: 600px;
}

.feedback.success {
    background: #E8F8F0;
    border-left: 4px solid var(--success);
    color: #1B7A3D;
}

.feedback.error {
    background: #FDEDEC;
    border-left: 4px solid var(--error);
    color: #C0392B;
}

/* Scales */
.scales-container {
    margin: 20px 0;
    padding: 20px;
    background: #FAFBFC;
    border-radius: 16px;
}

.scales {
    position: relative;
    height: 180px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.scales-beam {
    position: absolute;
    top: 30px;
    width: 260px;
    height: 6px;
    background: #5D6D7E;
    border-radius: 3px;
    transform-origin: center center;
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.scales-pivot {
    position: absolute;
    left: 50%;
    top: -12px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-bottom: 16px solid #5D6D7E;
}

.scales-pan {
    position: absolute;
    top: 60px;
    width: 110px;
    text-align: center;
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.scales-pan.left {
    left: calc(50% - 140px);
}

.scales-pan.right {
    right: calc(50% - 140px);
}

.pan-label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-light);
}

.pan-value {
    background: white;
    border: 3px solid var(--border);
    border-radius: 12px;
    padding: 14px 8px;
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    transition: all 0.5s;
    white-space: pre-line;
    line-height: 1.3;
}

.pan-value.economy {
    border-color: var(--success);
    color: var(--success);
}

.pan-value.overpay {
    border-color: var(--error);
    color: var(--error);
}

/* Tariffs Compare */
.tariffs-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.tariff-card {
    border-radius: 12px;
    padding: 14px;
    text-align: center;
}

.tariff-card.current {
    background: #EBF5FF;
    border: 2px solid var(--primary);
}

.tariff-card.new {
    background: #FFF3E0;
    border: 2px solid var(--accent);
}

.tariff-card h4 {
    font-size: 13px;
    margin-bottom: 6px;
}

.tariff-card .price {
    font-size: 22px;
    font-weight: 800;
}

.tariff-card .details {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
    line-height: 1.4;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    top: auto;
    background: rgba(0,0,0,0.3);
    z-index: 1000;
    justify-content: center;
    align-items: flex-end;
    padding: 12px;
}

.modal.show {
    display: flex;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 16px 18px;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    max-height: 55vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 6px;
    color: var(--error);
    font-size: 16px;
}

.modal-content > p {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 10px;
}

.reflection-options {
    margin: 16px 0;
}

.reflection-option {
    display: block;
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 6px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: white;
    cursor: pointer;
    font-size: 12px;
    text-align: left;
    transition: all 0.2s;
}

.reflection-option:hover,
.reflection-option.selected {
    border-color: var(--primary);
    background: #EBF5FF;
}

/* Results */
.results-card {
    text-align: center;
    padding: 28px 20px;
}

.results-icon {
    font-size: 56px;
    margin-bottom: 8px;
}

.results-score {
    font-size: 48px;
    font-weight: 800;
    color: var(--primary);
    margin: 12px 0;
}

.results-breakdown {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.8;
    margin-bottom: 16px;
}

.results-rank {
    background: linear-gradient(135deg, #FFF8E1, #FFECB3);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
    font-size: 15px;
    font-weight: 600;
    color: #F57F17;
}

/* Coin Animation */
@keyframes coinPop {
    0% { transform: scale(0) rotate(0deg); opacity: 0; }
    50% { transform: scale(1.3) rotate(180deg); opacity: 1; }
    100% { transform: scale(1) rotate(360deg); opacity: 1; }
}

.coin-anim {
    display: inline-block;
    animation: coinPop 0.5s ease-out;
}

/* Name Input */
.name-input-block {
    margin: 16px 0 8px;
    text-align: left;
}

.name-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.name-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #FAFBFC;
}

.name-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74,144,217,0.15);
    background: white;
}

/* Quiz Module Styles */
.module-badge-quiz {
    background: linear-gradient(135deg, #f093fb, #a855f7);
}

.level-badge-quiz {
    background: linear-gradient(135deg, #a855f7, #7c3aed);
}

.level-badge-gold {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.quiz-questions {
    margin: 16px 0;
}

.quiz-question {
    background: #F8FAFC;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--primary);
    transition: all 0.3s;
}

.quiz-question.answered-correct {
    border-left-color: var(--success);
    background: #E8F8F0;
}

.quiz-question.answered-wrong {
    border-left-color: var(--error);
    background: #FDEDEC;
}

.quiz-question.locked {
    opacity: 0.5;
    pointer-events: none;
}

.quiz-question-text {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 10px;
    line-height: 1.5;
}

.quiz-answer-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quiz-answer-row input {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    transition: border-color 0.2s;
}

.quiz-answer-row input:focus {
    outline: none;
    border-color: var(--primary);
}

.quiz-answer-row input.correct {
    border-color: var(--success);
    background: #E8F8F0;
}

.quiz-answer-row input.wrong {
    border-color: var(--error);
    background: #FDEDEC;
}

.quiz-check-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.quiz-check-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.quiz-result {
    font-size: 14px;
    font-weight: 600;
    margin-top: 8px;
    min-height: 20px;
}

.quiz-result.success {
    color: var(--success);
}

.quiz-result.error {
    color: var(--error);
}

/* Results Name */
.results-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 360px) {
    .data-table input { width: 50px; font-size: 13px; }
    .data-table th { font-size: 11px; padding: 8px 4px; }
    .calc-row { flex-direction: column; align-items: flex-start; }
    .calc-row input { width: 100%; }
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
