﻿:root {
      --bg: #f3f6f8;
      --surface: #ffffff;
      --surface-soft: #f8fafc;
      --primary: #17456b;
      --primary-dark: #0e2c47;
      --accent: #f5a623;
      --success: #16803c;
      --danger: #c92a2a;
      --text: #17212b;
      --muted: #64748b;
      --border: #d9e2ec;
      --focus: #2563eb;
      --shadow: rgba(15, 23, 42, 0.08);
      --header-shadow: rgba(15, 23, 42, 0.16);
      --option-bg: #ffffff;
      --option-hover: #f8fafc;
      --selected-bg: #eff6ff;
      --correct-bg: #ecfdf3;
      --wrong-bg: #fff1f2;
      --icon-bg: #e2e8f0;
      --secondary-bg: #e2e8f0;
      --secondary-hover: #cbd5e1;
    }

    [data-theme="dark"] {
      --bg: #10151d;
      --surface: #18202b;
      --surface-soft: #111923;
      --primary: #1f5f8f;
      --primary-dark: #8ec5f3;
      --accent: #f5b642;
      --success: #38a169;
      --danger: #f87171;
      --text: #e5edf5;
      --muted: #a8b3c2;
      --border: #303b4a;
      --focus: #60a5fa;
      --shadow: rgba(0, 0, 0, 0.32);
      --header-shadow: rgba(0, 0, 0, 0.34);
      --option-bg: #1d2734;
      --option-hover: #243246;
      --selected-bg: #173354;
      --correct-bg: #123922;
      --wrong-bg: #461b1f;
      --icon-bg: #344154;
      --secondary-bg: #303b4a;
      --secondary-hover: #3d4a5c;
    }

    * {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      min-height: 100vh;
      background: var(--bg);
      color: var(--text);
      font-family: "Segoe UI", Arial, sans-serif;
      line-height: 1.5;
    }

    header {
      background: var(--primary);
      color: #fff;
      padding: 22px clamp(16px, 4vw, 48px);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 18px;
      position: sticky;
      top: 0;
      z-index: 5;
      box-shadow: 0 2px 12px var(--header-shadow);
    }

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

    .badge {
      display: grid;
      place-items: center;
      width: 56px;
      height: 42px;
      border-radius: 8px;
      background: var(--accent);
      color: var(--primary-dark);
      font-weight: 900;
      letter-spacing: 0.04em;
    }

    h1 {
      margin: 0;
      font-size: clamp(1.1rem, 2vw, 1.55rem);
      line-height: 1.15;
    }

    .subtitle {
      margin: 4px 0 0;
      color: rgba(255, 255, 255, 0.78);
      font-size: 0.92rem;
    }

    .header-score {
      min-width: max-content;
      color: rgba(255, 255, 255, 0.88);
      font-weight: 700;
      font-size: 0.95rem;
    }

    .header-actions {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 14px;
    }

    .theme-toggle {
      width: 42px;
      height: 42px;
      border: 1px solid rgba(255, 255, 255, 0.28);
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.12);
      color: #fff;
      cursor: pointer;
      display: grid;
      place-items: center;
      transition: background 0.18s, border-color 0.18s, transform 0.18s;
    }

    .theme-toggle:hover {
      background: rgba(255, 255, 255, 0.22);
      border-color: rgba(255, 255, 255, 0.48);
      transform: translateY(-1px);
    }

    .theme-toggle svg {
      width: 21px;
      height: 21px;
      stroke: currentColor;
    }

    main {
      width: min(920px, calc(100% - 32px));
      margin: 34px auto 56px;
    }

    .panel {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      box-shadow: 0 14px 40px var(--shadow);
      overflow: hidden;
    }

    .screen {
      padding: clamp(22px, 4vw, 42px);
    }

    .intro h2,
    .result h2 {
      margin: 0 0 12px;
      color: var(--primary-dark);
      font-size: clamp(1.55rem, 3vw, 2.2rem);
    }

    .intro p,
    .result p {
      margin: 0 0 22px;
      color: var(--muted);
      max-width: 680px;
    }

    .stats {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 12px;
      margin: 28px 0;
    }

    .stat {
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 16px;
      background: var(--surface-soft);
    }

    .stat strong {
      display: block;
      color: var(--primary);
      font-size: 1.6rem;
      line-height: 1;
      margin-bottom: 6px;
    }

    .stat span {
      color: var(--muted);
      font-size: 0.88rem;
    }

    .test-picker {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 12px;
      margin: 0 0 24px;
    }

    .test-option {
      min-height: 82px;
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 14px 16px;
      background: var(--surface-soft);
      color: var(--text);
      cursor: pointer;
      text-align: left;
      transition: border-color 0.18s, background 0.18s, transform 0.18s;
    }

    .test-option:hover {
      border-color: var(--muted);
      transform: translateY(-1px);
    }

    .test-option:focus-visible {
      outline: 3px solid rgba(37, 99, 235, 0.28);
      outline-offset: 2px;
    }

    .test-option.selected {
      border-color: var(--focus);
      background: var(--selected-bg);
    }

    .test-option strong,
    .test-option span {
      display: block;
    }

    .test-option strong {
      color: var(--primary-dark);
      margin-bottom: 4px;
    }

    .test-option span {
      color: var(--muted);
      font-size: 0.9rem;
    }

    .toolbar {
      border-bottom: 1px solid var(--border);
      background: var(--surface-soft);
      padding: 18px clamp(18px, 4vw, 30px);
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 14px;
      align-items: center;
    }

    .progress-label {
      font-weight: 800;
      color: var(--primary-dark);
      margin-bottom: 8px;
    }

    .progress-track {
      height: 8px;
      background: var(--icon-bg);
      border-radius: 999px;
      overflow: hidden;
    }

    .progress-fill {
      height: 100%;
      width: 0%;
      background: var(--accent);
      transition: width 0.25s ease;
    }

    .question-card {
      padding: clamp(22px, 4vw, 34px);
    }

    .category {
      color: var(--primary);
      font-size: 0.82rem;
      font-weight: 800;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      margin-bottom: 12px;
    }

    .question {
      margin: 0 0 22px;
      font-size: clamp(1.22rem, 2.4vw, 1.55rem);
      color: var(--text);
    }

    .options {
      display: grid;
      gap: 12px;
      margin-bottom: 22px;
    }

    .option {
      width: 100%;
      min-height: 54px;
      padding: 14px 16px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--option-bg);
      color: var(--text);
      text-align: left;
      font: inherit;
      cursor: pointer;
      display: flex;
      align-items: flex-start;
      gap: 12px;
      transition: border-color 0.18s, background 0.18s, transform 0.18s;
    }

    .option:hover {
      border-color: var(--muted);
      background: var(--option-hover);
    }

    .option:focus-visible,
    .primary-btn:focus-visible,
    .secondary-btn:focus-visible {
      outline: 3px solid rgba(37, 99, 235, 0.28);
      outline-offset: 2px;
    }

    .option.selected {
      border-color: var(--focus);
      background: var(--selected-bg);
    }

    .option.correct {
      border-color: var(--success);
      background: var(--correct-bg);
    }

    .option.wrong {
      border-color: var(--danger);
      background: var(--wrong-bg);
    }

    .letter {
      flex: 0 0 auto;
      width: 28px;
      height: 28px;
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: var(--icon-bg);
      color: var(--primary-dark);
      font-weight: 800;
      font-size: 0.86rem;
    }

    .option.correct .letter {
      background: var(--success);
      color: #fff;
    }

    .option.wrong .letter {
      background: var(--danger);
      color: #fff;
    }

    .feedback {
      border-left: 4px solid var(--primary);
      background: var(--surface-soft);
      padding: 14px 16px;
      color: var(--text);
      margin: 4px 0 22px;
      display: none;
    }

    .feedback.show {
      display: block;
    }

    .actions {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    button {
      font: inherit;
    }

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

    .primary-btn,
    .secondary-btn {
      border: 0;
      border-radius: 8px;
      padding: 12px 18px;
      font-weight: 800;
      cursor: pointer;
    }

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

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

    .primary-btn:disabled {
      background: #94a3b8;
      cursor: not-allowed;
    }

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

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

    .muted {
      color: var(--muted);
      font-size: 0.92rem;
    }

    .hidden {
      display: none;
    }

    .confetti {
      position: fixed;
      inset: 0;
      pointer-events: none;
      overflow: hidden;
      z-index: 20;
    }

    .confetti::before {
      content: "";
      position: absolute;
      inset: 0;
      background: rgba(3, 7, 18, 0.72);
      animation: firework-backdrop 3.9s ease-out forwards;
    }

    .confetti-piece {
      position: absolute;
      width: 7px;
      height: 7px;
      border-radius: 50%;
      opacity: 0;
      box-shadow: 0 0 12px currentColor, 0 0 28px currentColor, 0 0 52px currentColor, 0 0 84px currentColor;
      animation: firework-spark var(--burst-duration) ease-out both;
    }

    @keyframes firework-backdrop {
      0% {
        opacity: 0;
      }

      12% {
        opacity: 1;
      }

      82% {
        opacity: 1;
      }

      100% {
        opacity: 0;
      }
    }

    .confetti-piece::after {
      content: "";
      position: absolute;
      top: 50%;
      right: 100%;
      width: 28px;
      height: 3px;
      border-radius: 999px;
      background: currentColor;
      transform: translateY(-50%);
      opacity: 0.9;
    }

    @keyframes firework-spark {
      0% {
        transform: translate3d(0, 0, 0) rotate(var(--angle)) scale(0.2);
        opacity: 0;
      }

      8% {
        opacity: 1;
      }

      55% {
        opacity: 1;
      }

      100% {
        transform: translate3d(var(--spark-x), var(--spark-y), 0) rotate(var(--angle)) scale(0.15);
        opacity: 0;
      }
    }

    .score-big {
      display: inline-flex;
      align-items: baseline;
      gap: 6px;
      margin: 8px 0 18px;
      color: var(--primary);
      font-weight: 900;
      font-size: clamp(2.6rem, 7vw, 4.4rem);
      line-height: 1;
    }

    .score-big span {
      font-size: 1.25rem;
      color: var(--muted);
    }

    .review-list {
      margin: 26px 0 0;
      padding: 0;
      list-style: none;
      display: grid;
      gap: 12px;
    }

    .review-item {
      border: 1px solid var(--border);
      border-left-width: 5px;
      border-radius: 8px;
      padding: 14px 16px;
      background: var(--option-bg);
    }

    .review-item.ok {
      border-left-color: var(--success);
    }

    .review-item.ko {
      border-left-color: var(--danger);
    }

    .review-item strong {
      display: block;
      margin-bottom: 6px;
    }

    @media (max-width: 680px) {
      header,
      .toolbar {
        grid-template-columns: 1fr;
      }

      header {
        align-items: flex-start;
        flex-direction: column;
      }

      .header-actions {
        width: 100%;
        justify-content: space-between;
      }

      .stats {
        grid-template-columns: 1fr;
      }

      .test-picker {
        grid-template-columns: 1fr;
      }

      .actions {
        align-items: stretch;
        flex-direction: column;
      }

      .intro-actions {
        flex-direction: column;
      }

      .primary-btn,
      .secondary-btn {
        width: 100%;
      }
    }

