/* ── RESET & ROOT VARIABLES ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue-900: #0d1b3e;
  --blue-700: #1a3a8f;
  --blue-500: #2563eb;
  --blue-400: #3b82f6;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;
  --green-500: #16a34a;
  --green-100: #dcfce7;
  --red-500:  #dc2626;
  --red-100:  #fee2e2;
  --gold-500: #d97706;
  --gold-100: #fef3c7;
  --gray-900: #111827;
  --gray-700: #374151;
  --gray-500: #6b7280;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --white: #ffffff;
  --glass: rgba(255,255,255,0.72);
  --shadow-card: 0 8px 32px rgba(13,27,62,0.13);
  --shadow-btn:  0 4px 16px rgba(37,99,235,0.35);
  --radius-card: 20px;
  --radius-input: 12px;
}

/* ── BODY ── */
body {
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg, #0d1b3e 0%, #1a3a8f 40%, #2563eb 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px 64px;
  color: var(--gray-900);
}

/* ── HEADER ── */
header {
  text-align: center;
  margin-bottom: 36px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}

.badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.badge-java   { background: #f89820; color: #fff; }
.badge-awt    { background: var(--blue-500); color: #fff; }
.badge-mini   { background: var(--green-500); color: #fff; }

header h1 {
  font-size: clamp(22px, 5vw, 38px);
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

header h1 span { color: #93c5fd; }

header p {
  margin-top: 10px;
  color: #bfdbfe;
  font-size: 15px;
  font-weight: 400;
  max-width: 520px;
}

/* ── CARD ── */
.card {
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 620px;
  padding: 36px 36px 28px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--blue-700);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--blue-200, #bfdbfe), transparent);
}

/* ── FORM ── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  letter-spacing: .3px;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-input);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--gray-900);
  background: #fff;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

input:focus {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

input.error-field { border-color: var(--red-500); }

/* ── DYNAMIC SUBJECT ROWS ── */
#subjectRows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 0;
}

.subject-row {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 10px;
  align-items: center;
  animation: slideIn .22s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.subject-index {
  font-size: 11px;
  font-weight: 700;
  color: var(--blue-500);
  white-space: nowrap;
}

/* ── BUTTONS ── */
.btn-row { display: flex; gap: 12px; margin-top: 24px; }

.btn {
  flex: 1;
  padding: 13px 20px;
  border: none;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover  { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(37,99,235,.45); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
}

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

/* ── RESULT CARD ── */
#resultCard {
  display: none;
  width: 100%;
  max-width: 620px;
  animation: popIn .3s cubic-bezier(.34,1.56,.64,1);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: scale(1); }
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}

.result-header h2 { font-size: 20px; font-weight: 800; color: var(--blue-900); }

.status-pill {
  padding: 6px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .5px;
}

.pass { background: var(--green-100); color: var(--green-500); }
.fail { background: var(--red-100);   color: var(--red-500); }

/* ── STATS GRID ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.stat-box {
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: 14px;
  padding: 16px 18px;
}

.stat-box.highlight { background: var(--blue-700); border-color: transparent; }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--blue-500);
  letter-spacing: .5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-box.highlight .stat-label { color: #93c5fd; }

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--blue-900);
  font-family: 'JetBrains Mono', monospace;
}

.stat-box.highlight .stat-value { color: #fff; }

.grade-badge {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: 0 4px 16px rgba(37,99,235,.35);
  float: right;
  margin-top: -6px;
}

/* ── BREAKDOWN TABLE ── */
.breakdown-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--blue-700);
  margin-bottom: 12px;
}

.breakdown-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
}

.breakdown-table th {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .5px;
  text-align: left;
  padding: 0 14px 4px;
}

.breakdown-table td {
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-900);
  background: #fff;
}

.breakdown-table td:first-child { border-radius: 10px 0 0 10px; }
.breakdown-table td:last-child  { border-radius: 0 10px 10px 0; text-align: right; }
.breakdown-table tr { box-shadow: 0 1px 4px rgba(0,0,0,.06); }

.mark-bar-wrap { display: flex; align-items: center; gap: 10px; }

.mark-bar-bg {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: var(--gray-200);
  overflow: hidden;
}

.mark-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  transition: width .6s ease;
}

.mark-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  white-space: nowrap;
}

/* ── ERROR BANNER ── */
#errorBanner {
  display: none;
  background: var(--red-100);
  border: 1px solid #fca5a5;
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--red-500);
  animation: slideIn .2s ease;
}

/* ── FOOTER ── */
footer {
  margin-top: 40px;
  text-align: center;
  color: #93c5fd;
  font-size: 13px;
}

footer a { color: #bfdbfe; text-decoration: none; font-weight: 600; }
footer a:hover { text-decoration: underline; }

/* ── RESPONSIVE ── */
@media (max-width: 520px) {
  .card { padding: 24px 18px 20px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .subject-row { grid-template-columns: 1fr 110px; }
}
