/* Test & Game hub refresh */
#view-test.view-section {
  min-height: calc(100vh - 72px);
  background: radial-gradient(
      circle at top right,
      rgba(14, 165, 233, 0.12),
      transparent 34%
    ),
    linear-gradient(
      180deg,
      rgba(248, 250, 252, 0.98),
      rgba(241, 245, 249, 0.98)
    );
}

.test-hub {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 18px 72px;
}

.test-hub-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 22px;
  padding: 28px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 28px;
  background: linear-gradient(135deg, #ffffff, #eff6ff);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.08);
}

.test-hub-kicker,
.test-setup-kicker,
.tg-eyebrow,
.test-type-title {
  color: #1570ef;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.test-hub-copy h2 {
  margin: 8px 0 10px;
  color: #07112f;
  font-size: 36px;
  line-height: 1.05;
  font-weight: 950;
  letter-spacing: 0;
}

.test-hub-copy p {
  max-width: 620px;
  margin: 0;
  color: #667085;
  font-size: 15px;
  line-height: 1.65;
  font-weight: 700;
}

.test-hub-meter {
  border-radius: 24px;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 16px 28px rgba(37, 99, 235, 0.25);
}

.test-hub-meter span {
  font-size: 38px;
  line-height: 1;
  font-weight: 950;
}

.test-hub-meter small {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 850;
  opacity: 0.92;
}

.test-hub-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.test-gateway-card {
  min-width: 0;
  min-height: 260px;
  position: relative;
  align-items: flex-start;
  text-align: left;
  gap: 16px;
  padding: 24px !important;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.07);
  cursor: pointer;
  overflow: hidden;
}

.test-gateway-card::after {
  content: "";
  position: absolute;
  right: -44px;
  top: -44px;
  width: 150px;
  height: 150px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  pointer-events: none;
}

.test-gateway-card-secondary::after {
  background: rgba(20, 184, 166, 0.09);
}

.test-gateway-card:hover {
  transform: translateY(-4px);
  border-color: rgba(37, 99, 235, 0.32);
  box-shadow: 0 20px 36px rgba(15, 23, 42, 0.1);
}

.test-gateway-card .tg-icon {
  width: 58px;
  height: 58px;
  margin: 0;
  border-radius: 18px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 0;
}

.test-gateway-card-secondary .tg-icon {
  background: #ecfeff;
  color: #0f766e;
}

.test-gateway-card .tg-icon svg {
  width: 30px;
  height: 30px;
  display: block;
}

.tg-card-content {
  min-width: 0;
  flex: 1;
}

.tg-title {
  margin: 6px 0 8px;
  color: #07112f;
  font-size: 23px;
  line-height: 1.15;
}

.tg-desc {
  margin: 0;
  color: #667085;
  font-size: 14px;
  line-height: 1.6;
  font-weight: 700;
}

.tg-btn {
  min-height: 48px;
  margin-top: auto;
  border-radius: 16px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.24);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-transform: none;
}

.tg-btn svg {
  width: 18px;
  height: 18px;
}

.tg-btn-muted {
  background: #e2e8f0 !important;
  color: #475467 !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
}

/* Test setup modal refresh */
#test-setup-modal {
  background: rgba(15, 23, 42, 0.36);
  backdrop-filter: blur(10px);
}

#test-setup-modal .test-setup-card {
  width: min(94vw, 560px) !important;
  max-width: 560px !important;
  max-height: min(760px, 92vh) !important;
  padding: 0 !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 28px !important;
  background: #f8fafc !important;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.18);
}

.test-setup-head {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: space-between !important;
  gap: 16px;
  padding: 26px 28px 20px !important;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18) !important;
  background: #fff !important;
}

.test-setup-title {
  margin-top: 6px;
  color: #07112f;
  font-size: 25px;
  line-height: 1.1;
  font-weight: 950;
}

.test-setup-subtitle {
  margin: 8px 0 0;
  color: #667085;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

#btnCloseTestSetup.test-setup-close {
  position: static !important;
  width: 42px !important;
  height: 42px !important;
  min-width: 42px;
  border: none;
  border-radius: 14px;
  background: #f1f5f9;
  color: #64748b;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  font-size: 22px !important;
  font-weight: 900;
  cursor: pointer;
}

.test-setup-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 28px 24px !important;
  background: #f8fafc !important;
}

.test-setup-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.test-setup-summary > div {
  padding: 14px;
  border: 1px solid rgba(37, 99, 235, 0.14);
  border-radius: 18px;
  background: #fff;
}

.test-setup-summary span {
  display: block;
  color: #2563eb;
  font-size: 25px;
  line-height: 1;
  font-weight: 950;
}

.test-setup-summary small {
  display: block;
  margin-top: 6px;
  color: #667085;
  font-size: 12px;
  font-weight: 850;
}

#test-setup-modal .ts-row {
  min-width: 0;
  margin: 0;
  padding: 14px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

#test-setup-modal .ts-row-source {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

#test-setup-modal .ts-label {
  color: #334155;
  font-size: 14px;
  font-weight: 900;
}

#test-setup-modal .ts-label small {
  display: block;
  margin-top: 3px;
  color: #667085;
  font-size: 12px;
  font-weight: 750;
}

#btnOpenTestWordSelector {
  min-height: 44px;
  border: 1.5px dashed rgba(37, 99, 235, 0.38);
  border-radius: 14px;
  background: #fff;
  color: #2563eb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 900;
  cursor: pointer;
}

#btnOpenTestWordSelector svg {
  width: 18px;
  height: 18px;
}

.test-setup-grid {
  display: grid;
  grid-template-columns: 0.76fr 1.24fr;
  gap: 14px;
}

.test-setup-grid .ts-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

#test-setup-modal .ts-select,
#test-setup-modal .ts-input {
  width: 100% !important;
  min-height: 46px;
  border-radius: 14px !important;
  border: 1.5px solid rgba(148, 163, 184, 0.35);
  background: #fff;
  color: #07112f;
  box-shadow: none;
}

#test-setup-modal .ts-select:focus,
#test-setup-modal .ts-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.test-type-panel {
  margin-top: 16px;
  padding: 16px 18px 4px;
  border-radius: 22px;
  background: #fff;
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.test-type-title {
  margin-bottom: 4px;
}

.test-type-panel .ts-row:last-child {
  border-bottom: 0;
}

.test-setup-footer {
  padding: 20px 28px 26px !important;
  border-top: 1px solid rgba(148, 163, 184, 0.18) !important;
  background: #fff !important;
}

#btnGenerateExam.test-start-btn {
  width: 100%;
  min-height: 58px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.26);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 950;
  text-transform: none;
  cursor: pointer;
}

#btnGenerateExam.test-start-btn svg {
  width: 20px;
  height: 20px;
}

body.dark-theme #view-test.view-section {
  background: radial-gradient(
      circle at top right,
      rgba(14, 165, 233, 0.12),
      transparent 34%
    ),
    linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(2, 6, 23, 0.98));
}

body.dark-theme .test-hub-hero,
body.dark-theme .test-gateway-card,
body.dark-theme #test-setup-modal .test-setup-card,
body.dark-theme .test-setup-head,
body.dark-theme .test-setup-footer,
body.dark-theme .test-setup-summary > div,
body.dark-theme .test-type-panel,
body.dark-theme #btnOpenTestWordSelector,
body.dark-theme #test-setup-modal .ts-select,
body.dark-theme #test-setup-modal .ts-input {
  background: #0f172a !important;
  border-color: rgba(148, 163, 184, 0.22);
}

body.dark-theme .test-hub-copy h2,
body.dark-theme .tg-title,
body.dark-theme .test-setup-title,
body.dark-theme #test-setup-modal .ts-label,
body.dark-theme #test-setup-modal .ts-select,
body.dark-theme #test-setup-modal .ts-input {
  color: #f8fafc !important;
}

body.dark-theme .test-hub-copy p,
body.dark-theme .tg-desc,
body.dark-theme .test-setup-subtitle,
body.dark-theme #test-setup-modal .ts-label small,
body.dark-theme .test-setup-summary small {
  color: #cbd5e1 !important;
}

body.dark-theme .test-setup-body {
  background: #020617 !important;
}

body.dark-theme #btnCloseTestSetup.test-setup-close {
  background: #1e293b !important;
  color: #cbd5e1 !important;
}

@media (max-width: 768px) {
  #view-test.view-section {
    padding: 12px 10px 96px !important;
  }

  .test-hub {
    padding: 8px 0 56px;
  }

  .test-hub-hero {
    grid-template-columns: 1fr;
    padding: 20px;
    border-radius: 24px;
  }

  .test-hub-copy h2 {
    font-size: 30px;
  }

  .test-hub-meter {
    min-height: 88px;
    align-items: flex-start;
    padding: 18px;
  }

  .test-hub-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .test-gateway-card {
    width: 100% !important;
    min-height: 230px;
    padding: 20px !important;
    border-radius: 24px;
  }

  .tg-title {
    font-size: 21px;
  }

  #test-setup-modal {
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 0 !important;
    background: rgba(15, 23, 42, 0.6) !important;
  }

  #test-setup-modal .test-setup-card {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  #test-setup-modal .test-setup-head {
    flex-shrink: 0 !important;
    padding: 22px 18px 18px !important;
    background: #fff !important;
  }

  .test-setup-title {
    font-size: 28px !important;
  }

  #test-setup-modal .test-setup-body {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 18px 16px 120px !important;
    background: #f8fafc !important;
  }

  .test-setup-summary,
  .test-setup-grid {
    grid-template-columns: 1fr;
  }

  #test-setup-modal .ts-row-source {
    grid-template-columns: 1fr;
  }

  #btnOpenTestWordSelector {
    width: 100% !important;
  }

  #test-setup-modal .test-setup-footer {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 20 !important;
    flex-shrink: 0 !important;
    padding: 14px 16px 18px !important;
    background: #fff !important;
    box-shadow: 0 -18px 30px rgba(15, 23, 42, 0.08);
  }

  body.dark-theme #test-setup-modal .test-setup-head,
  body.dark-theme #test-setup-modal .test-setup-footer {
    background: #0f172a !important;
  }

  body.dark-theme #test-setup-modal .test-setup-body {
    background: #020617 !important;
  }
}

/* ======================================================
   TASK ARENA-1: TEST BUILDER MODAL POLISH
   ====================================================== */

#btnCloseTestSetup,
#btnCloseTestWordSelector {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 44px !important;
  height: 44px !important;
  border-radius: 50% !important;
  background: var(--bg-body) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-main) !important;
  cursor: pointer !important;
  font-size: 18px !important;
  transition: background 0.18s ease, transform 0.15s ease, color 0.18s ease !important;
  position: static !important;
  box-sizing: border-box !important;
  line-height: 1 !important;
  flex-shrink: 0 !important;
}

#btnCloseTestSetup:hover,
#btnCloseTestWordSelector:hover {
  background: var(--border-color) !important;
  transform: scale(1.05) !important;
  color: #ef4444 !important;
}

body.dark-theme #btnCloseTestSetup,
body.dark-theme #btnCloseTestWordSelector {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

body.dark-theme #btnCloseTestSetup:hover,
body.dark-theme #btnCloseTestWordSelector:hover {
  background: #334155 !important;
  color: #f87171 !important;
}

@media (max-width: 768px) {
  #btnCloseTestSetup,
  #btnCloseTestWordSelector {
    width: 40px !important;
    height: 40px !important;
    font-size: 16px !important;
  }
}

#btnConfirmTestWords {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  font-size: 16px !important;
  border: none !important;
  border-radius: 12px !important;
  padding: 12px 24px !important;
  min-height: 44px !important;
  cursor: pointer !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25) !important;
  transition: opacity 0.2s ease, transform 0.15s ease !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#btnConfirmTestWords:hover {
  opacity: 0.9 !important;
  transform: translateY(-1px) !important;
}

#btnConfirmTestWords:active {
  transform: translateY(1px) !important;
}

@media (max-width: 768px) {
  #btnConfirmTestWords {
    width: 100% !important;
  }
}

.ws-footer {
  background: var(--bg-surface) !important;
  border-top: 1px solid var(--border-color) !important;
  padding: 16px 24px !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 16px !important;
}

@media (max-width: 768px) {
  .ws-footer {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 16px !important;
    gap: 12px !important;
    text-align: center !important;
  }
}
