  /* ========================================
     RESET & BASE
  ======================================== */
  *, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  :root {
    --bg-deep:    #050d1a;
    --bg-surface: #0d1b2e;
    --bg-card:    rgba(255,255,255,0.04);
    --bg-card-hover: rgba(255,255,255,0.08);
    --border:     rgba(255,255,255,0.09);
    --border-glow:rgba(56,189,248,0.4);
    --accent-1:   #38bdf8;
    --accent-2:   #818cf8;
    --accent-grad:linear-gradient(135deg, #38bdf8, #818cf8);
    --green:      #34d399;
    --red:        #f87171;
    --amber:      #fbbf24;
    --text-1:     #f1f5f9;
    --text-2:     #94a3b8;
    --text-3:     #475569;
    --radius-sm:  8px;
    --radius-md:  14px;
    --radius-lg:  20px;
    --radius-xl:  28px;
    --shadow-card:0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow:0 0 40px rgba(56,189,248,0.12);
    --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
    --font-display:'Space Grotesk', 'Segoe UI', sans-serif;
    --font-body:  'Inter', 'Segoe UI', sans-serif;
  }

  html, body {
    min-height: 100%;
    background: var(--bg-deep);
    color: var(--text-1);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
  }

  /* Import Google Fonts */
  @import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

  /* ========================================
     APP SHELL
  ======================================== */
  .app {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
  }

  /* Ambient background blobs */
  .app::before {
    content: '';
    position: fixed;
    top: -200px;
    left: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(56,189,248,0.07) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
  }
  .app::after {
    content: '';
    position: fixed;
    bottom: -200px;
    right: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(129,140,248,0.07) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
  }

  .screen-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 560px;
  }

  /* ========================================
     SCREENS
  ======================================== */
  .screen {
    display: none;
    animation: screenIn 0.4s cubic-bezier(0.4,0,0.2,1) forwards;
  }
  .screen.active { display: block; }

  @keyframes screenIn {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)  scale(1); }
  }

  /* ========================================
     GLASS CARD
  ======================================== */
  .card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 36px;
    box-shadow: var(--shadow-card), var(--shadow-glow);
  }

  /* ========================================
     LOGIN SCREEN
  ======================================== */
  .login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
  }
  .login-logo .logo-icon {
    width: 52px;
    height: 52px;
    background: var(--accent-grad);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    box-shadow: 0 4px 20px rgba(56,189,248,0.35);
    flex-shrink: 0;
  }
  .login-logo h1 {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  .login-tagline {
    text-align: center;
    color: var(--text-2);
    font-size: 14px;
    margin-bottom: 32px;
  }

  /* Stats strip */
  .login-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 28px;
  }
  .stat-chip {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 8px;
    text-align: center;
  }
  .stat-chip .val {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: block;
  }
  .stat-chip .lbl {
    font-size: 11px;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-top: 2px;
  }

  /* Input */
  .field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 8px;
  }
  .input-wrap {
    position: relative;
    margin-bottom: 16px;
  }
  .input-wrap i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    font-size: 16px;
    pointer-events: none;
  }
  input[type="text"] {
    width: 100%;
    padding: 13px 14px 13px 42px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-1);
    font-size: 15px;
    font-family: var(--font-body);
    outline: none;
    transition: var(--transition);
  }
  input[type="text"]:focus {
    border-color: var(--accent-1);
    background: rgba(56,189,248,0.05);
    box-shadow: 0 0 0 3px rgba(56,189,248,0.12);
  }
  input[type="text"]::placeholder { color: var(--text-3); }

  /* Difficulty selector */
  .diff-row {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
  }
  .diff-btn {
    flex: 1;
    padding: 10px 8px;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
  }
  .diff-btn:hover { border-color: var(--accent-1); color: var(--accent-1); }
  .diff-btn.selected {
    background: var(--accent-grad);
    border-color: transparent;
    color: white;
  }
  .diff-btn .diff-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
  }
  .diff-btn:nth-child(1) .diff-dot { background: var(--green); }
  .diff-btn:nth-child(2) .diff-dot { background: var(--amber); }
  .diff-btn:nth-child(3) .diff-dot { background: var(--red); }

  /* ========================================
     BUTTONS (PRIMARY / SECONDARY)
  ======================================== */
  .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
  }
  .btn-primary {
    background: var(--accent-grad);
    color: white;
    box-shadow: 0 4px 20px rgba(56,189,248,0.28);
  }
  .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(56,189,248,0.38);
  }
  .btn-primary:active { transform: scale(0.98); }
  .btn-secondary {
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    color: var(--text-1);
  }
  .btn-secondary:hover {
    border-color: var(--accent-1);
    color: var(--accent-1);
    background: rgba(56,189,248,0.05);
  }
  .btn-sm {
    width: auto;
    padding: 8px 16px;
    font-size: 13px;
    border-radius: var(--radius-sm);
  }
  .btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    flex-shrink: 0;
  }
  .btn-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
  }
  .btn-row .btn { flex: 1; }

  /* ========================================
     CATEGORY SCREEN
  ======================================== */
  .screen-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
  }
  .screen-sub {
    color: var(--text-2);
    font-size: 14px;
    margin-bottom: 24px;
  }
  .category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }
  .cat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 14px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
  }
  .cat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-grad);
    opacity: 0;
    transition: var(--transition);
    border-radius: inherit;
  }
  .cat-card:hover::before { opacity: 0.08; }
  .cat-card:hover {
    border-color: var(--accent-1);
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.4), 0 0 0 1px var(--accent-1);
  }
  .cat-card.locked {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
  }
  .cat-icon-wrap {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin: 0 auto 12px;
    position: relative;
    z-index: 1;
  }
  .cat-card:nth-child(1) .cat-icon-wrap { background: rgba(56,189,248,0.15); color: var(--accent-1); }
  .cat-card:nth-child(2) .cat-icon-wrap { background: rgba(251,191,36,0.15); color: var(--amber); }
  .cat-card:nth-child(3) .cat-icon-wrap { background: rgba(52,211,153,0.15); color: var(--green); }
  .cat-card:nth-child(4) .cat-icon-wrap { background: rgba(168,85,247,0.15); color: #a855f7; }
  .cat-card:nth-child(5) .cat-icon-wrap { background: rgba(249,115,22,0.15); color: #f97316; }
  .cat-card:nth-child(6) .cat-icon-wrap { background: rgba(244,63,94,0.15); color: #f43f5e; }
  .cat-card h3 {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
  }
  .cat-card .q-count {
    font-size: 11px;
    color: var(--text-2);
    position: relative;
    z-index: 1;
  }
  .lock-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 11px;
    color: var(--text-3);
  }

  /* ========================================
     QUIZ SCREEN
  ======================================== */
  .quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 10px;
  }
  .quiz-player {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  .avatar {
    width: 34px;
    height: 34px;
    background: var(--accent-grad);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: white;
    flex-shrink: 0;
    font-family: var(--font-display);
  }
  .quiz-player-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
  }
  .quiz-score-live {
    font-size: 12px;
    color: var(--text-2);
  }

  /* Timer */
  .timer-ring-wrap {
    position: relative;
    width: 54px;
    height: 54px;
    flex-shrink: 0;
  }
  .timer-ring-wrap svg {
    width: 54px; height: 54px;
    transform: rotate(-90deg);
  }
  .timer-ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 3;
  }
  .timer-ring-fill {
    fill: none;
    stroke: var(--accent-1);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear, stroke 0.3s;
  }
  .timer-num {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
  }

  /* Progress */
  .progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-2);
    margin-bottom: 6px;
  }
  .progress-track {
    height: 5px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 20px;
  }
  .progress-fill {
    height: 100%;
    background: var(--accent-grad);
    border-radius: 99px;
    transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
  }

  /* Question */
  .q-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(56,189,248,0.1);
    border: 1px solid rgba(56,189,248,0.2);
    border-radius: 99px;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-1);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 14px;
  }
  .question-text {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 600;
    line-height: 1.45;
    margin-bottom: 22px;
    color: var(--text-1);
  }

  /* Answer buttons */
  .answers { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
  .answer-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-1);
    font-size: 14px;
    font-family: var(--font-body);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    line-height: 1.4;
  }
  .answer-btn:hover:not(:disabled) {
    border-color: var(--accent-1);
    background: rgba(56,189,248,0.06);
    transform: translateX(3px);
  }
  .answer-btn:disabled { cursor: default; }
  .answer-key {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 7px;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-display);
    transition: var(--transition);
  }
  .answer-btn.correct {
    border-color: var(--green);
    background: rgba(52,211,153,0.1);
    animation: correctPop 0.4s cubic-bezier(0.4,0,0.2,1);
  }
  .answer-btn.correct .answer-key {
    background: var(--green);
    color: #0a1f13;
  }
  .answer-btn.wrong {
    border-color: var(--red);
    background: rgba(248,113,113,0.1);
    animation: shake 0.4s ease;
  }
  .answer-btn.wrong .answer-key {
    background: var(--red);
    color: #1f0a0a;
  }
  .answer-btn .result-icon {
    margin-left: auto;
    font-size: 16px;
    display: none;
  }
  .answer-btn.correct .result-icon { display: block; color: var(--green); }
  .answer-btn.wrong   .result-icon { display: block; color: var(--red); }

  @keyframes correctPop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.02); }
    100% { transform: scale(1); }
  }
  @keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%       { transform: translateX(-6px); }
    75%       { transform: translateX(6px); }
  }

  /* Quiz footer controls */
  .quiz-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .quiz-dot-nav {
    display: flex;
    gap: 5px;
    flex: 1;
    justify-content: center;
    flex-wrap: wrap;
  }
  .q-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: var(--transition);
  }
  .q-dot.done-correct { background: var(--green); }
  .q-dot.done-wrong   { background: var(--red); }
  .q-dot.current      { background: var(--accent-1); transform: scale(1.4); }

  /* ========================================
     FEEDBACK TOAST
  ======================================== */
  .feedback-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-80px);
    padding: 10px 20px;
    border-radius: 99px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    pointer-events: none;
    white-space: nowrap;
  }
  .feedback-toast.show { transform: translateX(-50%) translateY(0); }
  .feedback-toast.correct-toast { background: rgba(52,211,153,0.9); }
  .feedback-toast.wrong-toast   { background: rgba(248,113,113,0.9); }
  .feedback-toast.timeout-toast { background: rgba(251,191,36,0.9); }

  /* ========================================
     RESULT SCREEN
  ======================================== */
  .result-header { text-align: center; margin-bottom: 28px; }
  .result-medal {
    font-size: 52px;
    display: block;
    margin-bottom: 10px;
    animation: medalBounce 0.6s cubic-bezier(0.4,0,0.2,1);
  }
  @keyframes medalBounce {
    0%   { transform: scale(0) rotate(-20deg); opacity: 0; }
    70%  { transform: scale(1.15) rotate(5deg); opacity: 1; }
    100% { transform: scale(1) rotate(0); }
  }
  .result-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 6px;
  }
  .result-subtitle { color: var(--text-2); font-size: 14px; }

  /* Score ring */
  .score-ring-wrap {
    position: relative;
    width: 130px;
    height: 130px;
    margin: 0 auto 24px;
  }
  .score-ring-wrap svg { width: 130px; height: 130px; transform: rotate(-90deg); }
  .score-ring-bg { fill: none; stroke: var(--border); stroke-width: 8; }
  .score-ring-fill { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1.2s cubic-bezier(0.4,0,0.2,1); }
  .score-ring-label {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    text-align: center;
  }
  .score-num {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 700;
    display: block;
    line-height: 1;
  }
  .score-den { font-size: 13px; color: var(--text-2); display: block; margin-top: 2px; }

  /* Stats grid */
  .result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 24px;
  }
  .res-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 10px;
    text-align: center;
  }
  .res-stat .rs-val {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
  }
  .res-stat .rs-lbl {
    font-size: 11px;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .rs-correct .rs-val { color: var(--green); }
  .rs-wrong   .rs-val { color: var(--red); }
  .rs-time    .rs-val { color: var(--amber); }

  /* Performance badge */
  .perf-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 20px;
  }
  .perf-excellent { background: rgba(52,211,153,0.15); border: 1px solid rgba(52,211,153,0.3); color: var(--green); }
  .perf-good      { background: rgba(56,189,248,0.15); border: 1px solid rgba(56,189,248,0.3); color: var(--accent-1); }
  .perf-average   { background: rgba(251,191,36,0.15); border: 1px solid rgba(251,191,36,0.3); color: var(--amber); }
  .perf-bad       { background: rgba(248,113,113,0.15); border: 1px solid rgba(248,113,113,0.3); color: var(--red); }

  /* Q-review list */
  .review-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: none;
    border: none;
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-bottom: 12px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-family: var(--font-body);
  }
  .review-toggle i { transition: var(--transition); }
  .review-list { display: none; margin-bottom: 20px; }
  .review-list.open { display: block; }
  .review-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
  }
  .review-item:last-child { border-bottom: none; }
  .review-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
  .review-q { color: var(--text-1); font-weight: 500; margin-bottom: 2px; }
  .review-a { color: var(--text-2); font-size: 12px; }
  .review-a span { font-weight: 600; }

  /* ========================================
     MOBILE RESPONSIVE
  ======================================== */
  @media (max-width: 480px) {
    .card { padding: 22px 18px; border-radius: var(--radius-lg); }
    .login-logo h1 { font-size: 22px; }
    .stat-chip .val { font-size: 17px; }
    .question-text { font-size: 16px; }
    .answer-btn { font-size: 13px; padding: 12px 13px; }
    .answer-key { width: 24px; height: 24px; min-width: 24px; font-size: 11px; }
    .timer-ring-wrap { width: 44px; height: 44px; }
    .timer-ring-wrap svg { width: 44px; height: 44px; }
    .timer-num { font-size: 13px; }
    .result-stats { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .res-stat { padding: 10px 6px; }
    .res-stat .rs-val { font-size: 17px; }
    .score-ring-wrap { width: 110px; height: 110px; }
    .score-ring-wrap svg { width: 110px; height: 110px; }
    .score-num { font-size: 26px; }
    .category-grid { grid-template-columns: repeat(2, 1fr); }
  }
  @media (max-width: 340px) {
    .result-stats { grid-template-columns: repeat(2, 1fr); }
    .rs-time { display: none; }
  }
