@font-face {
  font-family: 'BonyadKoodak';
  src: url('../assets/fonts/BonyadeKoodakKoochakFaNum-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'BonyadKoodak';
  src: url('../assets/fonts/BonyadeKoodakKoochakFaNum-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'BonyadKoodak';
  src: url('../assets/fonts/BonyadeKoodakKoochakFaNum-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --color-brand-blue: #265CCC;
  --color-brand-blue-dark: #1e4a9e;
  --color-brand-cyan: #34F2FE;
  --color-brand-yellow: #FBDD1A;
  --color-bg: #eef5ff;
  --color-bg-panel: #ffffff;
  --color-primary: var(--color-brand-blue);
  --color-primary-dark: var(--color-brand-blue-dark);
  --color-text: #1a2d52;
  --color-text-muted: #5a6f94;
  --color-border: #c8daf5;
  --color-option: #f8fbff;
  --color-option-selected: #f0f8ff;
  --shadow-soft: 0 4px 16px rgba(38, 92, 204, 0.12);
  --shadow-primary: 0 4px 18px rgba(38, 92, 204, 0.38);
  --radius-lg: 18px;
  --radius-md: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-max-width: 480px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'BonyadKoodak', Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button,
a {
  font-family: inherit;
}

.app-loading,
.app-error {
  text-align: center;
  padding: 2rem 1rem;
  font-weight: 500;
}

.app-error {
  color: #b42318;
}

.app-shell {
  max-width: var(--app-max-width);
  margin: 0 auto;
  min-height: 100dvh;
  padding: 1rem 1rem calc(1rem + var(--safe-bottom));
}

.app-close {
  position: fixed;
  top: calc(var(--safe-top) + 0.65rem);
  right: max(0.75rem, calc((100vw - var(--app-max-width)) / 2 + 0.75rem));
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-bg-panel);
  color: var(--color-text-muted);
  box-shadow: var(--shadow-soft);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s, transform 0.1s;
}

.app-close:hover,
.app-close:focus-visible {
  color: var(--color-brand-blue);
  border-color: var(--color-brand-blue);
  background: #f0f7ff;
  outline: none;
}

.app-close:active {
  transform: scale(0.94);
}

.app-close__icon {
  display: block;
}

.screen {
  display: none;
  flex-direction: column;
  gap: 1rem;
  animation: fadeIn 0.25s ease;
}

.screen.active {
  display: flex;
}

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

@media (prefers-reduced-motion: reduce) {
  .screen.active { animation: none; }
  .skill-bar__fill { transition: none !important; }
}

/* Landing */
.landing-header {
  text-align: center;
  padding: 0.5rem 0 0;
}

.landing-header__icon {
  margin: 0 auto 0.75rem;
}

.landing-header__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-brand-blue);
}

.landing-header__subtitle {
  margin: 0.35rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.landing-description {
  background: var(--color-bg-panel);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  margin: 0;
  font-size: 0.95rem;
  text-align: justify;
}

.age-picker {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.age-card {
  min-height: 52px;
  padding: 0.85rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-panel);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.age-card__label {
  font-size: 1.05rem;
  font-weight: 500;
}

.age-card.selected {
  border-color: var(--color-brand-blue);
  background-color: #f0f7ff;
  box-shadow: var(--shadow-soft), inset 0 -3px 0 var(--color-brand-yellow);
  transform: scale(1.01);
}

.age-card:active {
  transform: scale(0.99);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s, border-color 0.15s;
}

.btn--primary {
  background: linear-gradient(180deg, #2f6ad8 0%, var(--color-brand-blue) 55%, var(--color-brand-blue-dark) 100%);
  color: #fff;
  border: 2px solid var(--color-brand-blue-dark);
  box-shadow: var(--shadow-primary);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.btn--primary:not(:disabled) {
  background: linear-gradient(180deg, #3a74e0 0%, var(--color-brand-blue) 50%, #224fa8 100%);
  box-shadow: var(--shadow-primary), 0 0 0 1px rgba(52, 242, 254, 0.35);
}

.btn--primary:disabled {
  background: #c5d4eb;
  border-color: #b0c3e3;
  color: #8fa3c7;
  box-shadow: none;
  text-shadow: none;
  opacity: 1;
  cursor: not-allowed;
}

.btn--wide {
  width: 100%;
}

.btn--store {
  width: 100%;
  background: var(--color-brand-blue);
  color: #fff;
  margin-bottom: 0;
  min-height: 44px;
  font-size: 0.92rem;
  border: 2px solid var(--color-brand-blue-dark);
}

.btn--store-bazaar {
  background: #6bcb2a;
  color: #1a1a1a;
}

.btn--store-myket {
  background: #5c6bc0;
}

.btn:not(:disabled):active {
  transform: scale(0.98);
}

#start-btn {
  margin-top: 0.25rem;
}

/* Quiz layout */
.screen--quiz {
  min-height: calc(100dvh - 2rem - var(--safe-top) - var(--safe-bottom));
  padding: 0;
  gap: 0;
}

.quiz-topbar {
  position: sticky;
  top: calc(var(--safe-top) + 0.5rem);
  z-index: 10;
  background: var(--color-bg-panel);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.85rem 3rem 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.quiz-topbar__title {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  color: var(--color-brand-blue);
}

.quiz-topbar__progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-direction: row-reverse;
}

.quiz-topbar__progress-bg {
  flex: 1;
  height: 14px;
  border-radius: 999px;
  background: #dce8fa;
  overflow: hidden;
  direction: rtl;
}

.quiz-topbar__progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--color-brand-cyan), var(--color-brand-blue));
  border-radius: 999px;
  transition: width 0.25s ease;
  margin-right: auto;
}

.quiz-topbar__counter {
  font-size: 0.85rem;
  font-weight: 500;
  min-width: 3.2rem;
  text-align: left;
  direction: ltr;
}

.quiz-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.5rem;
}

.question-panel {
  background: var(--color-bg-panel);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-soft);
}

.question-text {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 500;
  text-align: justify;
  white-space: pre-wrap;
}

.question-image-wrap {
  margin-bottom: 1rem;
  text-align: center;
}

.question-image {
  margin: 0 auto;
  max-height: 220px;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.options-grid {
  display: grid;
  gap: 0.65rem;
}

.options-grid--4 {
  grid-template-columns: 1fr 1fr;
  direction: rtl;
}

.options-grid--2 {
  grid-template-columns: 1fr;
}

.option-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 72px;
  padding: 0.65rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-option);
  cursor: pointer;
  text-align: right;
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.option-card--selected {
  border-color: var(--color-brand-blue);
  background-color: var(--color-option-selected);
  box-shadow: var(--shadow-soft), inset 0 0 0 1px rgba(52, 242, 254, 0.45);
}

.option-card__badge {
  align-self: flex-start;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: #dce8fa;
  color: var(--color-brand-blue-dark);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.35rem;
  flex-shrink: 0;
}

.option-card--selected .option-card__badge {
  background: var(--color-brand-blue);
  color: #fff;
  box-shadow: 0 0 0 2px var(--color-brand-yellow);
}

.option-card__body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
}

.option-card__text {
  display: block;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.45;
  width: 100%;
}

.option-card__image {
  margin: 0 auto;
  max-height: 100px;
  object-fit: contain;
}

.option-card__check {
  position: absolute;
  bottom: 0.4rem;
  left: 0.5rem;
  color: var(--color-brand-blue);
  font-weight: 700;
  font-size: 1.1rem;
}

.quiz-bottombar {
  position: sticky;
  bottom: var(--safe-bottom);
  padding-top: 0.75rem;
  background: linear-gradient(to top, var(--color-bg) 70%, transparent);
}

/* Processing */
.screen--processing {
  min-height: calc(100dvh - 2rem - var(--safe-top) - var(--safe-bottom));
  justify-content: center;
  align-items: center;
}

.processing-card {
  width: 100%;
  text-align: center;
  background: var(--color-bg-panel);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow-soft);
}

.processing-card__icon {
  margin: 0 auto 1rem;
  animation: processingPulse 1.4s ease-in-out infinite;
}

.processing-card__title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.processing-card__status {
  margin: 0 0 1.25rem;
  min-height: 1.5rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.processing-card__track {
  height: 12px;
  border-radius: 999px;
  background: #dce8fa;
  overflow: hidden;
  direction: rtl;
}

.processing-card__fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-brand-cyan), var(--color-brand-blue));
  transition: width 0.15s linear;
}

.processing-card__percent {
  margin: 0.65rem 0 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-brand-blue);
}

@keyframes processingPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.85; }
}

@media (prefers-reduced-motion: reduce) {
  .processing-card__icon { animation: none; }
  .processing-card__fill { transition: none; }
}

/* Results */
.screen--result {
  gap: 0.65rem;
  min-height: calc(100dvh - 2rem - var(--safe-top) - var(--safe-bottom));
}

.result-header {
  text-align: center;
}

.result-header__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.result-header__subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.result-panel {
  background: var(--color-bg-panel);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 0.85rem;
}

.skill-bars {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
}

.skill-bar--compact {
  display: grid;
  grid-template-columns: 3.25rem 1fr;
  grid-template-rows: auto auto;
  gap: 0.15rem 0.4rem;
  align-items: center;
}

.skill-bar--compact .skill-bar__label {
  grid-column: 1;
  grid-row: 1 / 3;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
}

.skill-bar--compact .skill-bar__track-wrap {
  grid-column: 2;
  grid-row: 1 / 3;
}

.skill-bar__label {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.skill-bar__track-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-direction: row-reverse;
}

.skill-bar__track {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: #dce8fa;
  overflow: hidden;
  direction: rtl;
}

.skill-bar__fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--color-brand-cyan), var(--color-brand-blue));
  border-radius: 999px;
  transition: width 0.5s ease;
  margin-right: auto;
}

.skill-bar__amount {
  min-width: 2rem;
  font-size: 0.72rem;
  font-weight: 500;
  text-align: left;
  direction: ltr;
}

.score-legend {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--color-border);
  font-size: 0.68rem;
  color: var(--color-text-muted);
  white-space: pre-line;
  line-height: 1.45;
  max-height: 5.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cta-block {
  background: linear-gradient(180deg, #ffffff 0%, #f4f9ff 100%);
  border: 2px solid var(--color-brand-blue);
  border-radius: var(--radius-lg);
  padding: 0.85rem 0.9rem;
  text-align: center;
  margin-top: 0.25rem;
  box-shadow: var(--shadow-soft);
}

.cta-block__title {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-brand-blue);
}

.cta-block__description {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.cta-block__buttons {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

@media (min-width: 400px) {
  .landing-header__title { font-size: 1.65rem; }
  .question-text { font-size: 1.05rem; }
}
