:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1d2330;
  --text: #f5f7fb;
  --muted: #9aa4b2;
  --line: #2a3242;
  --accent: #d6b36a;
  --success: #52c17a;
  --danger: #ff6b6b;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
}

#jspsych-target {
  min-height: 100vh;
}

.tr-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 18px;
  box-sizing: border-box;
}

.tr-card {
  width: 100%;
  max-width: 920px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-sizing: border-box;
  box-shadow: 0 20px 60px rgba(0,0,0,0.28);
}

.tr-center {
  text-align: center;
}

.tr-brand {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tr-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.tr-title {
  margin: 0 0 10px 0;
  font-weight: 800;
  line-height: 1.1;
}

.tr-subtitle {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 20px;
}

.tr-list {
  margin: 16px 0 0 0;
  padding-left: 20px;
  color: var(--text);
  line-height: 1.6;
}

.tr-grid,
.tr-score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.tr-metric,
.tr-score-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.tr-metric-label,
.tr-score-title {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.tr-metric-value,
.tr-score-value {
  font-size: 26px;
  font-weight: 800;
}

.tr-score-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.tr-progress-wrap {
  margin-bottom: 18px;
}

.tr-progress-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.tr-progress-bar {
  width: 100%;
  height: 10px;
  background: #0e131c;
  border-radius: 999px;
  overflow: hidden;
}

.tr-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #cda75b, #e6c987);
  border-radius: 999px;
}

.tr-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.tr-btn:hover {
  transform: translateY(-1px);
}

.tr-btn-primary {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.tr-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.tr-inline-key,
.tr-key-hint {
  color: var(--muted);
  font-size: 14px;
}

.tr-inline-key {
  display: inline-block;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 4px;
}

.tr-stimulus-word {
  font-size: 58px;
  font-weight: 900;
  letter-spacing: 1px;
}

.tr-fixation {
  font-size: 52px;
  font-weight: 900;
  text-align: center;
}

.tr-countdown {
  width: 100%;
  height: 8px;
  background: #0e131c;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 18px;
}

.tr-countdown-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #d6b36a, #ff6b6b);
  transform-origin: left center;
  animation-name: trShrink;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes trShrink {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.tr-micro-feedback {
  margin-top: 14px;
  font-size: 16px;
  font-weight: 700;
  min-height: 22px;
}

.tr-micro-correct {
  color: var(--success);
}

.tr-micro-wrong {
  color: var(--danger);
}

.tr-pair-list {
  display: grid;
  gap: 12px;
  margin: 20px 0;
}

.tr-pair-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}

.tr-emoji,
.tr-recall-cue {
  font-size: 42px;
}

.tr-arrow {
  font-size: 24px;
  color: var(--muted);
}

.tr-icon-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(90px, 1fr));
  gap: 14px;
  max-width: 420px;
  margin: 0 auto;
}

.tr-icon-choice {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 18px;
  padding: 18px;
  font-size: 34px;
  cursor: pointer;
}

.tr-feedback-icon {
  font-size: 54px;
  font-weight: 900;
  margin-bottom: 10px;
}

.tr-memory-emoji {
  font-size: 72px;
}

.tr-memory-cue {
  font-size: 84px;
  line-height: 1;
  margin: 10px 0 18px;
}

.tr-memory-grid {
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  max-width: 520px;
  gap: 18px;
}

.tr-memory-grid .tr-icon-choice {
  font-size: 54px;
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tr-feedback-icon {
  font-size: 72px;
  font-weight: 900;
  margin-bottom: 10px;
}


/* =========================
   Login / activation inputs
========================= */

#tr-login-panel input,
#tr-activation-panel input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: white;
  font-size: 16px;
  outline: none;
  box-sizing: border-box;
}

#tr-login-panel input::placeholder,
#tr-activation-panel input::placeholder {
  color: rgba(255,255,255,0.42);
}

#tr-login-panel input:focus,
#tr-activation-panel input:focus {
  border-color: rgba(214,179,106,0.65);
  box-shadow: 0 0 0 3px rgba(214,179,106,0.12);
}

#tr-act-toggle-password,
#tr-act-toggle-password-2 {
  height: 34px;
  min-width: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  color: white;
  cursor: pointer;
}
/* =========================
   Domain brain map
========================= */

.tr-domain-brain-section {
  margin-top: 18px;
  padding: 24px 22px 26px;
  border-radius: 22px;
  background: var(--panel-2);
  overflow: hidden;
}

.tr-domain-brain-map {
  position: relative;
  width: 100%;
  max-width: 980px;
  height: 620px;
  margin: 16px auto 0;
  isolation: isolate;
}

.tr-brain-connectors {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}

.tr-brain-connector-line {
  fill: none;
  stroke: rgba(214, 179, 106, 0.72);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: url(#connectorGlow);
}

.tr-brain-connector-dot {
  fill: #d6b36a;
  opacity: 0.9;
  filter: url(#connectorGlow);
}

.tr-brain-centerpiece {
  position: absolute;
  left: 50%;
  top: 278px;
  transform: translate(-50%, -50%);
  width: 315px;
  z-index: 1;
  pointer-events: none;
  opacity: 0.96;
}

.tr-brain-svg {
  width: 100%;
  height: auto;
  display: block;
}

.tr-brain-hotspot {
  fill: #d6b36a;
  stroke: rgba(255, 255, 255, 0.40);
  stroke-width: 1.1;
  filter: drop-shadow(0 0 7px rgba(214, 179, 106, 0.35));
}

.tr-brain-domain-card {
  position: absolute;
  width: 290px;
  min-height: 174px;
  padding: 18px 18px 16px;
  border-radius: 22px;
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.050) 0%,
    rgba(255,255,255,0.034) 100%
  );
  border: 1px solid rgba(255,255,255,0.095);
  box-shadow:
    0 16px 42px rgba(0,0,0,0.16),
    inset 0 1px 0 rgba(255,255,255,0.035);
  z-index: 3;
  box-sizing: border-box;
  backdrop-filter: blur(4px);
}

.tr-brain-domain-card:hover {
  border-color: rgba(214,179,106,0.22);
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.060) 0%,
    rgba(255,255,255,0.040) 100%
  );
}

.tr-brain-card-left-top {
  left: 16px;
  top: 44px;
}

.tr-brain-card-left-bottom {
  left: 16px;
  top: 258px;
}

.tr-brain-card-right-top {
  right: 16px;
  top: 44px;
}

.tr-brain-card-right-bottom {
  right: 16px;
  top: 258px;
}

.tr-brain-card-bottom {
  left: 50%;
  top: 474px;
  transform: translateX(-50%);
  width: 400px;
  min-height: 144px;
}

.tr-brain-card-bottom .tr-brain-domain-title {
  max-width: 245px;
  white-space: nowrap;
}

.tr-brain-domain-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.tr-brain-domain-title {
  font-size: 16px;
  line-height: 1.12;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  max-width: 165px;
}

.tr-brain-domain-score {
  font-size: 34px;
  line-height: 0.95;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.04em;
  flex-shrink: 0;
}

.tr-brain-domain-age {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.35;
  color: rgba(194,216,235,0.74);
  text-align: center;
}

.tr-brain-domain-associated {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.48;
  color: rgba(194,216,235,0.90);
  text-align: center;
}

/* Responsive fallback */
@media (max-width: 980px) {
  .tr-domain-brain-map {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    height: auto;
    min-height: auto;
  }

  .tr-brain-connectors {
    display: none;
  }

  .tr-brain-centerpiece {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    width: min(320px, 80vw);
    margin: 0 auto 10px;
    order: 1;
  }

  .tr-brain-domain-card {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    transform: none;
    width: 100%;
    min-height: auto;
  }

  .tr-brain-card-left-top,
  .tr-brain-card-left-bottom,
  .tr-brain-card-right-top,
  .tr-brain-card-right-bottom,
  .tr-brain-card-bottom {
    left: auto;
    right: auto;
    top: auto;
    transform: none;
  }
}

.tr-scientific-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.tr-scientific-summary::-webkit-details-marker {
  display: none;
}

.tr-scientific-toggle {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.tr-scientific-less {
  display: none;
}

.tr-scientific-details[open] .tr-scientific-more {
  display: none;
}

.tr-scientific-details[open] .tr-scientific-less {
  display: inline;
}

/* =========================
   Task breakdown premium blocks
========================= */

.tr-task-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
  margin-top: 8px;
}

/* 
  IMPORTANT:
  results.js currently also sets grid-template-columns inline.
  These !important rules are needed for responsive behavior to override that inline style.
*/
@media (max-width: 900px) {
  .tr-task-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 640px) {
  .tr-task-metric-grid {
    grid-template-columns: 1fr !important;
  }
}

/* =========================
   Task interpretation blocks
========================= */

.tr-task-insight-block {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.tr-task-copy-section {
  text-align: left;
  max-width: 820px;
  margin-left: 0;
  margin-right: 0;
}

.tr-task-section-title {
  font-size: 12px;
  font-weight: 800;
  color: rgba(214,179,106,0.95);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 8px;
}

.tr-task-section-text {
  font-size: 15px;
  line-height: 1.55;
  color: rgba(194,216,235,0.88);
  max-width: 720px;
  margin-left: 0;
  margin-right: 0;
}

.tr-practice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.tr-practice-card {
  padding: 13px 15px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.032);
  border: 1px solid rgba(255,255,255,0.07);
  text-align: left;
}

.tr-practice-title {
  font-size: 13px;
  font-weight: 800;
  color: rgba(255,255,255,0.94);
  margin-bottom: 5px;
}

.tr-practice-text {
  font-size: 13px;
  line-height: 1.45;
  color: rgba(194,216,235,0.80);
}

@media (max-width: 760px) {
  .tr-practice-grid {
    grid-template-columns: 1fr;
  }

  .tr-task-copy-section {
    text-align: left;
  }

  .tr-task-section-text {
    margin-left: 0;
    margin-right: 0;
  }
}

/* =========================
   Scientific studies dropdown
========================= */

.tr-scientific-details {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.075);
}

.tr-scientific-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.tr-scientific-summary::-webkit-details-marker {
  display: none;
}

.tr-scientific-toggle {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.tr-scientific-less {
  display: none;
}

.tr-scientific-details[open] .tr-scientific-more {
  display: none;
}

.tr-scientific-details[open] .tr-scientific-less {
  display: inline;
}

.tr-scientific-content {
  margin-top: 12px;
}

.tr-study-row {
  padding: 12px 0;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.tr-study-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.tr-study-meta {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.tr-study-link {
  display: inline-block;
  margin-top: 7px;
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  font-weight: 700;
}

.tr-study-empty {
  padding: 12px 0 2px;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
/* =========================
   Task metric cards polish
========================= */

.tr-task-metric-card {
  min-height: 210px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  text-align: center;
  padding: 16px 16px 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.075);
  box-sizing: border-box;
}

.tr-task-metric-card-label {
  width: 100%;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

.tr-task-metric-value-wrap {
  width: 100%;
  min-height: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 0;
  margin-bottom: 12px;
  text-align: center;
}

.tr-task-metric-value {
  width: 100%;
  text-align: center;
  font-size: 34px;
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--text);
}

.tr-task-metric-delta {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

.tr-task-metric-delta > * {
  justify-content: center;
}

.tr-task-metric-chart {
  width: 100%;
  margin-top: 0;
}

.tr-task-metric-note {
  width: 100%;
  margin: 0 0 4px 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.2;
  color: rgba(194,216,235,0.78);
}

.tr-task-metric-chart svg {
  display: block;
  width: 100%;
}

/* =========================
   Task visual preview thumbnails
========================= */

.tr-task-card-header {
  position: relative;
  display: grid;
  grid-template-columns: 150px 1fr 150px;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.tr-task-title-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}

.tr-task-preview-slot {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

.tr-task-header-spacer {
  width: 150px;
  height: 1px;
}

.tr-task-preview {
  width: 142px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 20%, rgba(214,179,106,0.10), transparent 38%),
    rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    0 12px 30px rgba(0,0,0,0.18),
    inset 0 1px 0 rgba(255,255,255,0.035);
  box-sizing: border-box;
  overflow: hidden;
}

.tr-stroop-preview {
  padding: 10px;
}

.tr-stroop-preview-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.tr-stroop-preview-kicker {
  font-size: 8px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: rgba(214,179,106,0.92);
}

.tr-stroop-preview-level {
  font-size: 8px;
  line-height: 1;
  font-weight: 700;
  color: rgba(194,216,235,0.58);
}

.tr-stroop-preview-instruction {
  font-size: 8px;
  line-height: 1.2;
  color: rgba(194,216,235,0.58);
  text-align: center;
  margin-bottom: 6px;
}

.tr-stroop-preview-word {
  font-size: 25px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #ff5f5f;
  text-align: center;
  margin-bottom: 10px;
  text-shadow: 0 0 16px rgba(255,95,95,0.16);
}

.tr-stroop-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.tr-stroop-preview-choice {
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.075);
  background: rgba(255,255,255,0.045);
  color: rgba(245,247,251,0.78);
  font-size: 7.5px;
  line-height: 1;
  font-weight: 800;
  text-align: center;
  padding: 6px 3px;
}

.tr-stroop-preview-choice-active {
  border-color: rgba(214,179,106,0.32);
  background: rgba(214,179,106,0.13);
  color: rgba(255,255,255,0.94);
  box-shadow: 0 0 16px rgba(214,179,106,0.10);
}

.tr-stroop-preview-timer {
  width: 100%;
  height: 5px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
  overflow: hidden;
}

.tr-stroop-preview-timer-fill {
  width: 62%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d6b36a, rgba(255,107,107,0.85));
}

/* Responsive */
@media (max-width: 760px) {
  .tr-task-card-header {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .tr-task-preview-slot {
    justify-content: center;
  }

  .tr-task-header-spacer {
    display: none;
  }
}

.tr-user-menu-item {
  width: 100%;
  display: block;
  padding: 11px 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.tr-user-menu-item:hover {
  background: rgba(255,255,255,0.07);
}

@media print {
  body {
    background: #ffffff !important;
  }

  body.tr-print-report-mode {
    background: #ffffff !important;
  }

  body.tr-print-report-mode .tr-actions,
  body.tr-print-report-mode button,
  body.tr-print-report-mode .tr-btn {
    display: none !important;
  }

  body.tr-print-report-mode .tr-shell {
    padding: 0 !important;
    background: #ffffff !important;
  }

  body.tr-print-report-mode .tr-card {
    box-shadow: none !important;
    border: none !important;
    background: #ffffff !important;
    color: #111827 !important;
    max-width: none !important;
    width: 100% !important;
  }

  body.tr-print-report-mode * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

@keyframes tr-loading-bar {
  0% {
    transform: translateX(-38%);
    opacity: 0.72;
  }

  100% {
    transform: translateX(76%);
    opacity: 1;
  }
}

/* =========================
   TOAST NOTIFICATIONS
========================= */

.tr-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}

.tr-toast {
  min-width: 260px;
  max-width: 380px;
  padding: 14px 18px;
  border-radius: 14px;
  background: #1d2330;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  animation: trToastIn 0.25s ease-out;
}

.tr-toast.tr-toast-error {
  border-color: rgba(255, 107, 107, 0.35);
  background: linear-gradient(180deg, rgba(255, 107, 107, 0.10), #1d2330);
}

.tr-toast.tr-toast-warning {
  border-color: rgba(214, 179, 106, 0.30);
  background: linear-gradient(180deg, rgba(214, 179, 106, 0.08), #1d2330);
}

.tr-toast-title {
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 13px;
}

.tr-toast-body {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
}

@keyframes trToastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .tr-toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .tr-toast {
    min-width: unset;
    max-width: unset;
  }
}