:root {
  color-scheme: light dark;
  --bg: radial-gradient(circle at top, #0f172a 0%, #111827 60%, #020617 100%);
  --fg: #e2e8f0;
  --accent: #60a5fa;
  --stim-bg: rgba(15, 23, 42, 0.8);
  --cue-color: #3b82f6;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  user-select: none;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px);
}

#app {
  width: min(960px, 100%);
}

.splash {
  background: rgba(15, 23, 42, 0.78);
  border-radius: clamp(20px, 4vw, 32px);
  box-shadow: 0 20px 60px rgba(2, 6, 23, 0.5);
  padding: clamp(24px, 5vw, 48px);
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 4vw, 24px);
  align-items: flex-start;
}

.splash h1 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.6rem);
}

.splash p {
  margin: 0;
  line-height: 1.6;
  color: rgba(226, 232, 240, 0.85);
}

.splash button {
  appearance: none;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  color: #f8fafc;
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.4);
}

#jspsych-root {
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 3vw, 28px);
  align-items: center;
}

.task-container {
  width: min(720px, 90vw);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 3vw, 24px);
  padding: clamp(16px, 4vw, 24px);
  border-radius: clamp(18px, 4vw, 28px);
  background: var(--stim-bg);
  box-shadow: 0 18px 50px rgba(2, 6, 23, 0.45);
}

.stimulus-area {
  position: relative;
  width: min(520px, 80vw);
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.letter-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  width: 100%;
  height: 100%;
  gap: clamp(6px, 1.5vw, 14px);
}

.letter-cell {
  position: relative;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family, monospace);
  font-size: clamp(32px, 4vw, 44px);
  color: #f8fafc;
}

.letter-mask {
  font-size: clamp(32px, 4vw, 44px);
  opacity: 0.7;
}

.fixation {
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 600;
}

.cue-square {
  position: absolute;
  inset: clamp(6px, 1.5vw, 14px);
  border: clamp(2px, 0.4vw, 4px) solid var(--cue-color);
  border-radius: 10px;
  pointer-events: none;
}

.response-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.response-area p {
  margin: 0;
  line-height: 1.5;
}

.response-display {
  font-size: clamp(20px, 3.2vw, 28px);
  font-weight: 600;
  letter-spacing: 0.1em;
}

.response-error {
  color: #f87171;
  min-height: 1.2em;
}

.feedback {
  font-size: 1.1rem;
  line-height: 1.6;
}

.download-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 16px;
}

.download-buttons button {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 12px;
  padding: 10px 16px;
  background: rgba(37, 99, 235, 0.2);
  color: var(--fg);
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 600px) {
  body {
    padding: 16px;
  }

  .task-container {
    width: 100%;
    padding: 16px;
  }
}
