@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700;800&display=swap');

:root {
  --navy: #0B1026;
  --navy-light: #151a3a;
  --gold: #FFD27A;
  --gold-dark: #e6b85c;
  --glass: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.15);
  --text: #ffffff;
  --text-dim: rgba(255,255,255,0.75);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Vazirmatn', system-ui, sans-serif;
  background: var(--navy);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  direction: rtl;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

html { overflow-x: hidden; }

#canvas-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
#canvas-bg canvas { display: block; max-width: 100%; }

.app {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
}

/* Glass card */
.glass {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  padding: 28px 22px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  transition: transform 0.3s ease, box-shadow 0.3s;
}

.glass:hover { transform: translateY(-2px); }

h1, h2, h3 {
  color: var(--gold);
  font-weight: 800;
  text-align: center;
  margin-bottom: 12px;
}

h1 { font-size: 2.1rem; letter-spacing: -0.5px; }
h2 { font-size: 1.6rem; }

.subtitle {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 24px;
  line-height: 1.6;
}

.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 20px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 12px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--navy);
  box-shadow: 0 6px 20px rgba(255, 210, 122, 0.35);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 25px rgba(255, 210, 122, 0.5); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: transparent;
  color: var(--gold);
  border: 1.5px solid var(--gold);
}

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

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #ff9f43);
  border-radius: 10px;
  transition: width 0.5s ease;
}

.option {
  background: rgba(255,255,255,0.05);
  border: 1.5px solid transparent;
  border-radius: 16px;
  padding: 14px 16px;
  margin: 8px 0;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.option:hover { background: rgba(255,210,122,0.1); }
.option.selected {
  border-color: var(--gold);
  background: rgba(255,210,122,0.15);
  font-weight: 600;
}

.score-badge {
  background: var(--gold);
  color: var(--navy);
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
}

.result-card {
  text-align: center;
  padding: 32px 20px;
  background: linear-gradient(145deg, rgba(255,210,122,0.15), rgba(255,159,67,0.1));
  border: 1px solid rgba(255,210,122,0.3);
}

.temperament-title {
  font-size: 2.8rem;
  font-weight: 800;
  margin: 8px 0;
  background: linear-gradient(135deg, #fff, var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.bar-row {
  display: flex;
  align-items: center;
  margin: 10px 0;
  gap: 10px;
}

.bar-label { width: 70px; font-size: 0.9rem; }
.bar-track {
  flex: 1;
  height: 12px;
  background: rgba(255,255,255,0.1);
  border-radius: 20px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 20px;
  transition: width 1.2s ease;
}
.bar-pct { width: 48px; text-align: left; font-size: 0.85rem; }

.footer-note {
  text-align: center;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  margin-top: 24px;
  line-height: 1.5;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--gold);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.screen { animation: fadeIn 0.5s ease; }

.logo {
  text-align: center;
  margin-bottom: 8px;
  font-size: 1.1rem;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 1px;
}

/* ---- Mobile / responsive ---- */
img, video, canvas, svg { max-width: 100%; height: auto; }
#canvas-bg canvas { height: 100%; }
.app { width: 100%; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
h1, h2, h3, p, span, td, th, .option { overflow-wrap: anywhere; word-break: normal; }
.btn { min-height: 48px; touch-action: manipulation; line-height: 1.4; }
a.btn { display: flex; align-items: center; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.option { min-height: 48px; gap: 10px; touch-action: manipulation; }
.score-badge { flex-shrink: 0; }
input, select, textarea { font-size: 16px; max-width: 100%; }
table { max-width: 100%; }

@media (hover: none) {
  .glass:hover, .btn-primary:hover { transform: none; }
}

@media (max-width: 480px) {
  .app { padding-top: 16px; padding-bottom: 32px; }
  .glass { padding: 22px 16px; border-radius: 22px; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  .temperament-title { font-size: 2.1rem; }
  .btn { font-size: 1rem; padding: 14px; border-radius: 16px; }
  .option { padding: 12px 14px; }
  .bar-label { width: 56px; font-size: 0.85rem; }
  .bar-pct { width: 40px; }
}

@media (max-width: 360px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .glass { padding: 18px 12px; }
  h1 { font-size: 1.4rem; }
  .temperament-title { font-size: 1.8rem; }
}
