/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --red: #BE1033;
  --blue: #1B3565;
  --purple-mid: #6B2560;
  --white: #ffffff;
  --white-80: rgba(255,255,255,0.85);
  --white-20: rgba(255,255,255,0.20);
  --white-10: rgba(255,255,255,0.12);
  --shadow: 0 8px 32px rgba(0,0,0,0.30);
  --radius: 16px;
  --radius-sm: 10px;
}

html, body {
  min-height: 100%;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: var(--white);
  background: linear-gradient(135deg, #BE1033 0%, #6B2560 45%, #1B3565 100%);
  background-attachment: fixed;
}

/* ===== ISB LOGO ===== */
.isb-logo-img {
  height: 64px;
  width: auto;
  display: block;
}

/* ===== LAYOUT ===== */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 40px;
}

.header {
  width: 100%;
  max-width: 520px;
  margin-bottom: 28px;
  padding-top: 8px;
}

.card {
  width: 100%;
  max-width: 520px;
  background: var(--white-10);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--white-20);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--white);
}
.card-subtitle {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.75);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ===== FORM ===== */
.form-group {
  margin-bottom: 18px;
}
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 7px;
  color: rgba(255,255,255,0.9);
}
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 13px 16px;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  color: var(--white);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  -webkit-appearance: none;
}
input::placeholder, textarea::placeholder {
  color: rgba(255,255,255,0.45);
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.22);
}
input[type="number"]::-webkit-inner-spin-button {
  opacity: 0.5;
}
select option {
  background: #1B3565;
  color: white;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.15s;
  letter-spacing: 0.04em;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--white);
  color: var(--red);
  width: 100%;
  margin-top: 8px;
}
.btn-primary:hover { opacity: 0.92; box-shadow: 0 4px 16px rgba(0,0,0,0.25); }
.btn-outline {
  background: transparent;
  color: var(--white);
  border: 2px solid rgba(255,255,255,0.5);
  width: 100%;
  margin-top: 8px;
}
.btn-outline:hover { border-color: white; background: var(--white-10); }
.btn-danger {
  background: rgba(190,16,51,0.8);
  color: white;
  border: 1.5px solid rgba(255,100,100,0.4);
}
.btn-danger:hover { background: var(--red); }
.btn-sm {
  padding: 8px 16px;
  font-size: 0.82rem;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== PROGRESS ===== */
.progress-bar {
  height: 5px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}
.progress-fill {
  height: 100%;
  background: var(--white);
  border-radius: 10px;
  transition: width 0.4s ease;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.7);
  margin-bottom: 8px;
}

/* ===== QUESTION ===== */
.question-number {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.65);
  margin-bottom: 10px;
}
.question-text {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.55;
  margin-bottom: 22px;
  color: var(--white);
}
.unit-hint {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
  margin-top: -14px;
  margin-bottom: 18px;
}

/* ===== SCORE / RESULT ===== */
.score-display {
  text-align: center;
  padding: 20px 0;
}
.score-number {
  font-size: 3rem;
  font-weight: 800;
  color: var(--white);
  line-height: 1;
}
.score-label {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
  margin-top: 6px;
  margin-bottom: 4px;
}
.rank-badge {
  display: inline-block;
  background: var(--white);
  color: var(--red);
  font-weight: 800;
  font-size: 1rem;
  padding: 6px 18px;
  border-radius: 20px;
  margin-top: 12px;
}

/* ===== HIGHSCORE TABLE ===== */
.hs-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}
.hs-table th {
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}
.hs-table td {
  padding: 11px 8px;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.hs-table tr:last-child td { border-bottom: none; }
.hs-rank {
  font-weight: 800;
  font-size: 1rem;
  width: 36px;
}
.rank-1 { color: #FFD700; }
.rank-2 { color: #C0C0C0; }
.rank-3 { color: #CD7F32; }
.hs-name { font-weight: 600; }
.hs-score { font-weight: 600; text-align: right; }
.hs-score-val { font-size: 0.75rem; color: rgba(255,255,255,0.6); }

/* ===== HIGHLIGHT ROW ===== */
.hs-table tr.highlight-row td {
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
}

/* ===== NAV TABS ===== */
.nav-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.nav-tab {
  padding: 9px 18px;
  background: var(--white-10);
  border: 1.5px solid var(--white-20);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.75);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.nav-tab:hover, .nav-tab.active {
  background: var(--white);
  color: var(--red);
  border-color: var(--white);
}

/* ===== ADMIN PANEL ===== */
.admin-section { display: none; }
.admin-section.visible { display: block; }

.question-editor-row {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}
.question-editor-row .q-num {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.55);
  margin-bottom: 8px;
}
.q-row-grid {
  display: grid;
  grid-template-columns: 1fr 130px 120px;
  gap: 10px;
  align-items: start;
}

@media (max-width: 500px) {
  .q-row-grid {
    grid-template-columns: 1fr;
  }
  .card { padding: 24px 18px; }
}

/* ===== ALERT ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-error {
  background: rgba(190,16,51,0.35);
  border-color: rgba(255,100,100,0.4);
  color: #ffcdd2;
}
.alert-success {
  background: rgba(0,150,80,0.3);
  border-color: rgba(100,255,150,0.3);
  color: #c8f7dc;
}

/* ===== LOADING ===== */
.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
  text-align: center;
  padding: 40px 0;
}

/* ===== SCREEN STATES ===== */
.screen { display: none; }
.screen.active { display: block; }

/* ===== MISC ===== */
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mt-8 { margin-top: 8px; }
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.empty-state {
  text-align: center;
  padding: 40px 0;
  color: rgba(255,255,255,0.5);
  font-size: 0.9rem;
}
.badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.05em;
}
.winner-emoji { font-size: 2.5rem; margin-bottom: 12px; }
a.link {
  color: rgba(255,255,255,0.8);
  text-decoration: underline;
  font-size: 0.85rem;
}
a.link:hover { color: white; }
