:root {
  --bg: #0b1220;
  --card: #111a2e;
  --text: #e5ecf7;
  --muted: #a5b4cf;
  --green: #58cc02;
  --green-dark: #43a002;
  --blue: #56c7ff;
  --border: #253049;
  --danger: #ff6b6b;
  --ok: #22c55e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #060b16 0%, var(--bg) 35%);
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.top-bar {
  margin-bottom: 1rem;
}

.home-btn {
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 2rem;
  font-weight: 800;
  padding: 0;
  cursor: pointer;
}

.home-btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
  border-radius: 6px;
}

.subtitle {
  margin-top: 0.25rem;
  color: var(--muted);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.stat {
  background: #18243f;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem;
}

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

.progress-wrap {
  height: 12px;
  margin-top: 0.95rem;
  background: #1b2743;
  border-radius: 999px;
  overflow: hidden;
}

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

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.home-model-card {
  margin-top: 1rem;
}

.home-model-image {
  width: 100%;
  height: auto;
  display: block;
}

.pill {
  display: inline-block;
  background: #0d2d42;
  color: #b7e8ff;
  border: 1px solid #1e4e6c;
  font-size: 0.82rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
}

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

.diagram-area {
  display: none;
  margin: 0.75rem 0;
}

.diagram-object {
  width: calc(100% - 1rem);
  aspect-ratio: 210 / 297;
  height: auto;
  display: block;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0f172a;
}

.input-grid {
  display: grid;
  gap: 0.65rem;
  margin: 1rem 0;
}

.option-btn {
  width: 100%;
  border: 1px solid var(--border);
  background: #15213a;
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-size: 1rem;
  cursor: pointer;
}

.option-btn:hover,
.option-btn.selected {
  border-color: var(--blue);
  background: #11314a;
}

.option-btn.correct-selected {
  border: 2px solid var(--ok);
  background: rgba(34, 197, 94, 0.18);
}

.option-btn.incorrect-selected {
  border: 2px solid var(--danger);
  background: rgba(255, 107, 107, 0.18);
}

.option-btn.correct-outline {
  border: 2px solid var(--ok);
}

.option-btn.correct-selected:hover,
.option-btn.incorrect-selected:hover,
.option-btn.correct-outline:hover {
  background: #15213a;
}

.option-btn.correct-selected:hover {
  background: rgba(34, 197, 94, 0.18);
}

.option-btn.incorrect-selected:hover {
  background: rgba(255, 107, 107, 0.18);
}

.option-result-tag {
  font-weight: 700;
  white-space: nowrap;
  margin-left: auto;
}

.option-result-tag.ok {
  color: var(--ok);
}

.option-result-tag.bad {
  color: var(--danger);
}

.text-input {
  width: 100%;
  border: 1px solid #33425f;
  background: #0f172a;
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem;
  font-size: 1rem;
  margin: 0.85rem 0;
}

.actions {
  display: flex;
  gap: 0.65rem;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-weight: 700;
  cursor: pointer;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 1;
  background: #27344f;
  color: #9caaca;
}

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

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

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

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

.feedback {
  font-weight: 600;
  min-height: 1.5rem;
}

.note {
  display: none;
  margin: 0.3rem 0 0.75rem;
  color: #c9dcff;
  font-size: 0.94rem;
  line-height: 1.45;
}

.feedback.ok {
  color: var(--ok);
}

.feedback.bad {
  color: var(--danger);
}

.recap ul {
  margin-top: 0.4rem;
}

.agn-flash-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at center, rgba(86, 199, 255, 0.18) 0%, rgba(11, 18, 32, 0.85) 70%);
  z-index: 999;
}

.agn-flash-overlay.active {
  animation: agn-flash-fade 5000ms ease-out forwards;
}

.agn-flash-object {
  width: min(92vw, 560px);
  height: min(92vh, 700px);
  filter: drop-shadow(0 0 24px rgba(86, 199, 255, 0.4));
  transform: rotate(-45deg) scale(1.05);
  display: grid;
  place-items: center;
}

.agn-flash-object svg {
  width: 100%;
  height: 100%;
}

.agn-flash-overlay.active .agn-flash-object {
  animation: agn-flash-pop 5000ms ease-out forwards;
}

.agn-streak-text {
  position: absolute;
  bottom: 8vh;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2.8rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #d8f4ff;
  text-shadow: 0 0 18px rgba(86, 199, 255, 0.8), 0 0 32px rgba(86, 199, 255, 0.35);
  opacity: 0;
}

.agn-flash-overlay.active .agn-streak-text {
  animation: agn-streak-float 5000ms ease-out forwards;
}

@keyframes agn-flash-fade {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes agn-flash-pop {
  0% { transform: rotate(-45deg) scale(0.95); }
  22% { transform: rotate(-45deg) scale(1.16); }
  100% { transform: rotate(-45deg) scale(1.24); }
}

@keyframes agn-streak-float {
  0% { opacity: 0; transform: translateX(-50%) translateY(16px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; transform: translateX(-50%) translateY(-10px); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

@media (max-width: 620px) {
  .stats-row {
    grid-template-columns: 1fr;
  }

  .agn-flash-object {
    width: min(96vw, 420px);
    height: min(90vh, 520px);
  }
}
