:root {
  --bg-0: #040c16;
  --bg-1: #0d1f33;
  --bg-2: #173658;
  --ink: #ecf6ff;
  --ink-soft: #9cb3c9;
  --card: rgba(7, 20, 36, 0.78);
  --border: rgba(138, 186, 226, 0.28);
  --accent: #00d4ff;
  --accent-2: #ffb347;
  --danger: #ff5e5e;
  --ok: #33d18a;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 15% 20%, rgba(0, 212, 255, 0.15), transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(255, 179, 71, 0.2), transparent 35%),
    linear-gradient(140deg, var(--bg-0), var(--bg-1), var(--bg-2));
  overflow-x: hidden;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.noise-layer {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.03) 0px,
    rgba(255, 255, 255, 0.03) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: soft-light;
  opacity: 0.3;
}

.app-shell {
  position: relative;
  z-index: 2;
  width: min(1150px, calc(100% - 2rem));
  margin: 1rem auto 3rem;
  display: grid;
  gap: 1rem;
}

.card {
  background: linear-gradient(145deg, rgba(15, 33, 54, 0.88), var(--card));
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 1rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1rem;
  min-height: 280px;
}

.hero-kicker {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  color: var(--accent);
}

.hero h1 {
  margin: 0.3rem 0 0.5rem;
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(2.3rem, 5vw, 4rem);
  letter-spacing: 0.04em;
  line-height: 0.95;
}

.hero-subtitle {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.hero-tags {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hero-tags span {
  border: 1px solid rgba(0, 212, 255, 0.25);
  background: rgba(0, 212, 255, 0.08);
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
}

.hero-actions {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.hero-note {
  margin: 0.7rem 0 0;
  color: #b6ccdf;
  font-size: 0.9rem;
}

.hero-side {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.session-banner {
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid rgba(255, 179, 71, 0.35);
  background: rgba(255, 179, 71, 0.08);
  padding: 0.6rem;
  font-size: 0.9rem;
  color: #ffd9a8;
}

.session-banner.pending {
  border-color: rgba(0, 212, 255, 0.45);
  background: rgba(0, 212, 255, 0.12);
  color: #b2efff;
}

.session-banner.success {
  border-color: rgba(51, 209, 138, 0.52);
  background: rgba(51, 209, 138, 0.13);
  color: #b8ffd8;
}

.session-banner.error {
  border-color: rgba(255, 94, 94, 0.58);
  background: rgba(255, 94, 94, 0.14);
  color: #ffc4c4;
}

.hero-meter {
  margin-top: auto;
  border: 1px solid rgba(51, 209, 138, 0.35);
  background: rgba(51, 209, 138, 0.08);
  border-radius: 12px;
  padding: 0.7rem;
}

.hero-meter p {
  margin: 0;
  color: var(--ink-soft);
}

.hero-meter h3 {
  margin: 0.3rem 0;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.06em;
  font-size: 1.7rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.card-head h2 {
  margin: 0;
  font-size: 1.3rem;
}

.card-head p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 0.65rem 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

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

.btn-primary {
  background: linear-gradient(120deg, var(--accent), #6be6ff);
  color: #022132;
  box-shadow: 0 10px 24px rgba(0, 212, 255, 0.26);
}

.btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(156, 179, 201, 0.48);
}

.btn-danger {
  background: linear-gradient(130deg, #ff7a59, var(--danger));
  color: #3a0e0e;
  box-shadow: 0 10px 24px rgba(255, 94, 94, 0.28);
}

.auth-tabs {
  display: inline-flex;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.3rem;
  border-radius: 999px;
}

.tab-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-weight: 700;
}

.tab-btn.active {
  background: rgba(0, 212, 255, 0.2);
  color: var(--ink);
}

.auth-form {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.7rem;
}

.auth-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

input {
  width: 100%;
  border: 1px solid rgba(156, 179, 201, 0.35);
  background: rgba(10, 24, 40, 0.95);
  color: var(--ink);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
}

.auth-user p {
  margin: 0.3rem 0;
}

.auth-title {
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.6rem;
  letter-spacing: 0.08em;
}

.status-text {
  min-height: 1.2rem;
  margin-top: 0.5rem;
  color: var(--accent-2);
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--ink-soft);
}

.progress-content {
  margin-top: 0.7rem;
}

.progress-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 0.6rem;
}

.progress-kpi {
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 12px;
  padding: 0.7rem;
  background: rgba(0, 212, 255, 0.06);
}

.progress-kpi b {
  display: block;
  font-size: 1.2rem;
}

.topic-list,
.history-list,
.feedback-grid,
.mistakes-list {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.topic-item,
.history-item,
.feedback-item,
.mistake-item {
  border: 1px solid rgba(156, 179, 201, 0.22);
  background: rgba(8, 18, 32, 0.65);
  border-radius: 12px;
  padding: 0.7rem;
}

.exam-head {
  align-items: center;
}

.progress-wrap {
  margin: 0.8rem 0;
}

.progress-bar {
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s ease;
}

#progress-label {
  display: inline-block;
  margin-top: 0.4rem;
  color: var(--ink-soft);
}

.question-card {
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 14px;
  padding: 1rem;
  background: rgba(5, 14, 24, 0.75);
}

.question-meta {
  display: flex;
  gap: 0.5rem;
}

.chip {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  border: 1px solid rgba(0, 212, 255, 0.25);
  background: rgba(0, 212, 255, 0.08);
}

.chip-warn {
  border-color: rgba(255, 179, 71, 0.4);
  background: rgba(255, 179, 71, 0.14);
}

.question-card h3 {
  margin: 0.8rem 0;
  line-height: 1.4;
}

.options {
  display: grid;
  gap: 0.6rem;
}

.option-btn {
  text-align: left;
  border-radius: 12px;
  padding: 0.8rem;
  border: 1px solid rgba(156, 179, 201, 0.25);
  color: var(--ink);
  background: rgba(10, 24, 40, 0.8);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease, background 0.2s ease;
}

.option-btn:hover {
  border-color: rgba(0, 212, 255, 0.45);
}

.option-btn.selected {
  border-color: rgba(0, 212, 255, 0.92);
  background: rgba(0, 212, 255, 0.12);
  transform: translateY(-1px);
}

.exam-controls {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.6rem;
}

.question-nav {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 0.35rem;
}

.nav-btn {
  border: 1px solid rgba(156, 179, 201, 0.3);
  background: rgba(5, 14, 24, 0.8);
  color: var(--ink-soft);
  border-radius: 8px;
  height: 32px;
  cursor: pointer;
  font-weight: 700;
}

.nav-btn.current {
  border-color: rgba(255, 179, 71, 0.85);
  color: #ffd08e;
}

.nav-btn.answered {
  border-color: rgba(51, 209, 138, 0.8);
  color: #88f7c6;
}

.result-main {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.score-ring {
  --score-angle: 0deg;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--ok) var(--score-angle), rgba(255, 255, 255, 0.1) 0deg);
  position: relative;
}

.score-ring::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: #081626;
}

#score-value {
  position: relative;
  z-index: 1;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.07em;
  font-size: 2rem;
}

.guest-note {
  color: #ffd9a8;
}

.mistake-item h4 {
  margin: 0 0 0.35rem;
}

.mistake-item p {
  margin: 0.25rem 0;
  color: var(--ink-soft);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.65rem;
  border-bottom: 1px solid rgba(156, 179, 201, 0.18);
  font-size: 0.95rem;
}

th {
  color: var(--ink-soft);
  font-weight: 500;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

@media (max-width: 980px) {
  .hero,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .hero-side {
    order: -1;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: calc(100% - 1rem);
    margin: 0.5rem auto 2rem;
  }

  .card {
    border-radius: 14px;
    padding: 0.8rem;
  }

  .hero h1 {
    font-size: clamp(2rem, 11vw, 3rem);
  }

  .result-main {
    flex-direction: column;
    align-items: flex-start;
  }
}
