body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: linear-gradient(135deg, #eef3ff 0%, #f8fbff 55%, #edf7ff 100%);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  width: min(92vw, 460px);
  margin: 24px;
  background: #ffffff;
  padding: 30px 28px 26px;
  border-radius: 18px;
  border: 1px solid #e7ecf8;
  box-shadow: 0 14px 38px rgba(31, 60, 136, 0.12);
}

.brand-header {
  text-align: center;
  margin-bottom: 22px;
}

.brand-logo {
  width: 88px;
  height: auto;
  display: block;
  margin: 0 auto 14px;
  filter: drop-shadow(0 6px 12px rgba(31, 60, 136, 0.18));
}

h1, h2, h3 {
  color: #1f3c88;
}

h1 {
  margin: 0;
  line-height: 1.15;
}

.title-main,
.title-sub {
  display: block;
}

.title-main {
  font-size: 1.68rem;
  font-weight: 800;
}

.title-sub {
  margin-top: 8px;
  font-size: 1.05rem;
  font-weight: 600;
  color: #3d66bf;
  letter-spacing: 0.01em;
}

.form-label {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

input,
select {
  display: block;
  width: 100%;
  padding: 12px 13px;
  margin-bottom: 13px;
  font-size: 15px;
  box-sizing: border-box;
  border: 1px solid #cfd8ea;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
  border-color: #3d66bf;
  box-shadow: 0 0 0 3px rgba(61, 102, 191, 0.16);
}

select {
  background: #fff;
}

button {
  width: 100%;
  padding: 12px 18px;
  margin-top: 10px;
  border: none;
  background: linear-gradient(135deg, #1f3c88 0%, #2e57b5 100%);
  color: white;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

button:hover {
  filter: brightness(1.05);
  box-shadow: 0 8px 18px rgba(31, 60, 136, 0.28);
}

button:active {
  transform: translateY(1px);
}

.option {
  display: block;
  margin: 10px 0;
}

#timer {
  font-size: 20px;
  font-weight: bold;
  margin: 15px 0;
  color: #c0392b;
}

#message {
  color: red;
  margin-top: 12px;
  min-height: 20px;
  text-align: center;
  font-size: 0.95rem;
}
#navigation {
  margin: 20px 0;
}

#navigation button {
  margin: 5px;
  padding: 8px 12px;
}

#navigation {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.nav-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid #999;
  cursor: pointer;
  font-weight: bold;
}

.nav-btn.answered {
  background-color: green;
  color: white;
}

.nav-btn.unanswered {
  background-color: #dc3545;
  color: white;
}

.nav-btn.active {
  border: 3px solid blue;
}

/* ===== Прелоадер входу ===== */
.auth-loader {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 0%, rgba(79, 70, 229, 0.08) 0%, rgba(79, 70, 229, 0) 55%),
    #f4f6fb;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
.auth-loader.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.auth-loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.auth-loader-spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 4px solid rgba(31, 60, 136, 0.16);
  border-top-color: #2e57b5;
  animation: auth-loader-spin 0.85s linear infinite;
}
@keyframes auth-loader-spin {
  to { transform: rotate(360deg); }
}
.auth-loader-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1b2440;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}
.auth-loader-hint {
  font-size: 0.84rem;
  color: #6b7897;
}
.auth-loader-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 4px;
}
.auth-loader-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6b7897;
  animation: auth-loader-dot 1.2s infinite ease-in-out;
}
.auth-loader-dots span:nth-child(2) { animation-delay: 0.15s; }
.auth-loader-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes auth-loader-dot {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Плавна поява готової форми входу */
#studentView:not(.gate-pending),
#adminView:not(.hidden) {
  animation: auth-form-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes auth-form-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* Кнопка із прелоадером під час відправлення форми */
.admin-submit.is-loading {
  pointer-events: none;
  opacity: 0.88;
}
.admin-submit.is-loading > svg {
  display: none;
}
.admin-submit.is-loading::after {
  content: "";
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: auth-loader-spin 0.7s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .auth-loader, .auth-loader-spinner, .auth-loader-dots span,
  #studentView:not(.gate-pending), #adminView:not(.hidden) {
    animation: none;
    transition: none;
  }
}

/* ===== Тестування закрито: замість форми входу ===== */
.hidden { display: none !important; }

/* поки статус невідомий — нічого не показуємо, щоб форма не блимала */
#studentView.gate-pending > * { visibility: hidden; }

.exam-closed {
  text-align: center;
  padding: 26px 20px 22px;
  border-radius: 16px;
  background: linear-gradient(160deg, #fffaf0 0%, #fff0d9 100%);
  border: 1px solid #f3d3a0;
  box-shadow: 0 8px 22px rgba(232, 150, 46, 0.16);
  animation: exam-closed-in 0.35s ease-out;
}

@keyframes exam-closed-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.exam-closed-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #f0a544 0%, #e08a1c 100%);
  color: #fff;
  box-shadow: 0 0 0 8px rgba(232, 150, 46, 0.14), 0 8px 18px rgba(232, 150, 46, 0.4);
}

.exam-closed-title {
  margin: 0 0 8px;
  font-size: 1.4rem;
  font-weight: 800;
  color: #8a4b08;
}

.exam-closed-text {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.5;
  color: #6a4a1e;
}

.exam-closed-wait {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 16px 0 0;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid #f3d3a0;
  font-size: 0.82rem;
  font-weight: 600;
  color: #8f5d1c;
}

.exam-closed-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e8962e;
  animation: exam-closed-pulse 1.6s ease-out infinite;
}

@keyframes exam-closed-pulse {
  0% { box-shadow: 0 0 0 0 rgba(232, 150, 46, 0.55); }
  100% { box-shadow: 0 0 0 9px rgba(232, 150, 46, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .exam-closed, .exam-closed-dot { animation: none; }
}

/* ===== Окремий вхід для адміністраторів ===== */
.admin-card {
  border-radius: 16px;
  border: 1px solid #dfe6f6;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 26px rgba(31, 60, 136, 0.13);
  animation: exam-closed-in 0.3s ease-out;
}

.admin-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  color: #fff;
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 255, 255, 0.2) 0, rgba(255, 255, 255, 0) 55%),
    linear-gradient(135deg, #172f6e 0%, #2e57b5 100%);
}

.admin-card-icon {
  flex: none;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.admin-card-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.admin-card-sub {
  margin: 3px 0 0;
  font-size: 0.83rem;
  color: rgba(255, 255, 255, 0.82);
}

.admin-card-body {
  padding: 18px 20px 20px;
  background: linear-gradient(180deg, #f7f9ff 0%, #fff 60%);
}

.admin-field {
  display: block;
  margin-bottom: 14px;
}

.admin-field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a6b8f;
}

.admin-field-box {
  position: relative;
  display: block;
}

.admin-field-box svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #8a99bb;
  pointer-events: none;
  transition: color 0.2s ease;
}

.admin-field-box:focus-within svg { color: #2e57b5; }

.admin-field-box input {
  margin: 0;
  padding-left: 42px;
  background: #fff;
}

.admin-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  padding: 13px 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, #172f6e 0%, #2e57b5 100%);
  box-shadow: 0 6px 16px rgba(31, 60, 136, 0.25);
}

.admin-submit svg { transition: transform 0.2s ease; }
.admin-submit:hover svg { transform: translateX(3px); }

@media (prefers-reduced-motion: reduce) {
  .admin-card { animation: none; }
}

/* ===== Форма входу учня ===== */
.student-form { animation: exam-closed-in 0.3s ease-out; }

.student-form-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
}

.student-form-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(205, 216, 234, 0) 0%, #cdd8ea 100%);
}

.student-form-line:last-child { transform: scaleX(-1); }

.student-form-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #3d66bf;
}

.student-form .admin-field-box input {
  padding-top: 13px;
  padding-bottom: 13px;
  border-radius: 12px;
  background: #f9fbff;
}

.student-form .admin-field-box input:focus { background: #fff; }

.student-form-hint {
  margin: 14px 0 0;
  text-align: center;
  font-size: 0.82rem;
  color: #7b8aab;
}

@media (prefers-reduced-motion: reduce) {
  .student-form { animation: none; }
}

.link-btn {
  display: block;
  width: auto;
  margin: 14px auto 0;
  padding: 6px 10px;
  background: none;
  color: #5a6b8f;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
}

.link-btn:hover {
  filter: none;
  box-shadow: none;
  color: #1f3c88;
  background: #eef2fb;
}

#message:empty { display: none; }

/* ===== Номер комп'ютера ===== */
.pc-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 28, 70, 0.55); backdrop-filter: blur(4px);
  padding: 16px;
}
.pc-modal.hidden { display: none; }
.pc-card {
  width: min(92vw, 400px);
  background: #fff; border-radius: 20px; padding: 28px 26px 24px;
  text-align: center; box-shadow: 0 30px 70px rgba(15, 28, 70, 0.4);
  animation: pc-in 0.2s ease-out;
}
@keyframes pc-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.pc-icon { font-size: 2.6rem; line-height: 1; margin-bottom: 8px; }
.pc-card h2 { margin: 0 0 8px; font-size: 1.35rem; }
.pc-text { margin: 0 0 16px; color: #54627f; font-size: 0.95rem; line-height: 1.5; }
.pc-input {
  width: 100%; box-sizing: border-box; text-align: center;
  font-size: 1.8rem; font-weight: 800; letter-spacing: 0.06em;
  padding: 12px 14px; border: 2px solid #cdd8ee; border-radius: 14px; outline: none;
  text-transform: uppercase; color: #1f3c88;
}
.pc-input:focus { border-color: #3d63d6; box-shadow: 0 0 0 4px rgba(61, 99, 214, 0.18); }
.pc-error { min-height: 1.2em; margin: 8px 0 0; color: #c62828; font-size: 0.88rem; font-weight: 600; }
.pc-actions { display: flex; gap: 10px; margin-top: 10px; }
.pc-btn {
  flex: 1; height: 46px; border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(135deg, #3d63d6, #5b7cf0); color: #fff; font: inherit; font-size: 1rem; font-weight: 700;
}
.pc-btn:hover { filter: brightness(1.05); }
.pc-btn-ghost { background: #eef2fb; color: #1f3c88; }
.pc-btn.hidden { display: none; }
.pc-blocked .pc-card { border-top: 6px solid #c62828; }
.pc-badge {
  position: fixed; right: 14px; bottom: 14px; z-index: 50;
  padding: 8px 14px; border-radius: 999px; border: 1px solid #cdd8ee;
  background: #fff; color: #1f3c88; font: inherit; font-size: 0.85rem; font-weight: 700; cursor: default; user-select: none;
  box-shadow: 0 6px 16px rgba(31, 60, 136, 0.15);
}
.pc-badge.hidden { display: none; }
