/* Brain Games — shared hub + game shell */
body {
  min-height: 100vh;
  margin: 0;

  background:
    radial-gradient(
      700px circle at 15% -10%,
      rgba(56, 189, 248, 0.36),
      transparent 60%
    ),
    radial-gradient(
      650px circle at 85% 0%,
      rgba(147, 197, 253, 0.44),
      transparent 58%
    ),
    linear-gradient(
      180deg,
      #d9effb 0%,
      #edf8ff 45%,
      #f8fcff 100%
    );

  background-attachment: fixed;
}

#instructionsBox {
    max-width:1100px;
    margin:auto;
    }
.brain-games-page,
.memory-games-page {

}

.memory-hub-top {
    max-width: 520px;
    margin: 0 auto 16px auto;
    padding: 0 12px;
}

.memory-hub-pick-label {
    display: block;
    margin-bottom: 6px;
    color: #0b2b3a;
}

.memory-hub-select {
    width: 100%;
    max-width: 100%;
    font-size: 1rem;
    padding: 8px 10px;
    border-radius: 6px;
    background: #fff;
}

.memory-hub-select optgroup {
    font-weight: 700;
    color: #155726;
}

.memory-class-join {
    text-align: center;
    padding-bottom: 8px;
}

/* Intro screen (Human Benchmark style) */
.memory-intro-screen {
    max-width: 520px;
    margin: 24px auto 20px auto;
    padding: 32px 20px 28px;
    text-align: center;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.memory-intro-screen[hidden],
.memory-end-screen[hidden],
.memory-play-shell[hidden] {
    display: none !important;
}

.memory-intro-title {
    font-size: 2rem;
    font-weight: 800;
    margin: 0 0 16px 0;
    color: #0b2b3a;
    line-height: 1.2;
}

.memory-intro-blurb {
    font-size: 1.05rem;
    line-height: 1.5;
    color: #334;
    margin: 0 0 28px 0;
}

.memory-intro-start-btn {
    font-size: 1.1rem;
    font-weight: 700;
    padding: 12px 36px;
    border: none;
    border-radius: 8px;
    background: #155726;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.memory-intro-start-btn:hover {
    background: #1a6b2f;
}

.memory-intro-start-btn:active {
    transform: scale(0.98);
}

.memory-end-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.memory-end-back-btn {
    font-size: 1.05rem;
    font-weight: 700;
    padding: 12px 22px;
    border: 2px solid rgba(0, 0, 0, 0.18);
    border-radius: 8px;
    background: #fff;
    color: #0b2b3a;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.memory-end-back-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.memory-end-back-btn:active {
    transform: scale(0.98);
}

.memory-play-shell {
    max-width: 560px;
    margin: 0 auto;
}

.memory-question-bar {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    height: auto;
    min-height: 44px;
    margin-bottom: 4px;
    display: block;
}

.memory-canvas-area {
    flex-direction: column;
}

/* Hub HUD */
.memory-hud-hub .memory-hud-row {
    align-items: center;
}

.memory-hud-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.memory-hud-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.memory-hud-strikes {
    display: none;
}

.memory-sound-btn {
    position: relative;
}

.memory-timer-bar {
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.memory-timer-fill {
    height: 100%;
    width: 100%;
    background: #2aa7ff;
    border-radius: 2px;
    transition: width 0.1s linear;
}

.memory-timer-bar.is-warning .memory-timer-fill {
    background: #f5a623;
}

.memory-timer-bar.is-urgent .memory-timer-fill {
    background: #ff4b4b;
}

.memory-instructions-box h2 {
    margin-top: 1.2em;
}

.memory-instructions-box .memory-about-list {
    margin: 0;
    padding-left: 1.25rem;
}

.memory-instructions-box .memory-about-list li {
    margin-bottom: 0.5em;
}

#memoryAboutDefault[hidden],
#memoryAboutGame[hidden] {
    display: none !important;
}

/* Classic Concentration card grid */
.concentration-grid {
    --conc-cols: 4;
    --gap: 10px;
    max-width: 520px;
    width: min(480px, 96vw);
    margin: 14px auto 20px auto;
    display: grid;
    grid-template-columns: repeat(var(--conc-cols), 1fr);
    gap: var(--gap);
    user-select: none;
    touch-action: manipulation;
}

.concentration-card {
    width: 110px;
    height: 110px;
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 10px;
    perspective: 600px;
}

.concentration-card:disabled,
.concentration-card.is-hidden {
    cursor: default;
    pointer-events: none;
}

.concentration-card.is-hidden {
    visibility: hidden;
    opacity: 0;
}

.concentration-card-inner {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.35s ease, opacity 0.25s ease;
    border-radius: 10px;
}

.concentration-card.is-flipped .concentration-card-inner {
    transform: rotateY(180deg);
}

.concentration-card-back,
.concentration-card-front {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.concentration-card-back {
    background: #35C978;
    border: 2px solid rgba(255, 255, 255, 0.35);
}

.concentration-card-back::after {
    content: "?";
    font-size: 1.6rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.85);
}

.concentration-card-front {
    transform: rotateY(180deg);
    background: #fff;
    border: 2px solid rgba(0, 0, 0, 0.1);
    font-size: 5rem; /* ~80px for larger card images */
    line-height: 1;
}

.concentration-card.is-hidden .concentration-card-inner {
    opacity: 0;
}

/* Fade out when cards match */
.concentration-card.is-fading-out {
  opacity: 0 !important;
  transition: opacity 0.8s ease-out;
  pointer-events: none;
}

.concentration-card.is-fading-out .concentration-card-front {
  background: #d1fae5 !important;
  border-color: #34d399 !important;
  transition: background 0.2s ease, border-color 0.2s ease;
}

/* Make cards smaller on mobile portrait mode */
@media (orientation: portrait) and (max-width: 480px) {
  .concentration-card {
    width: 80px;
    height: 80px;
  }

  .concentration-card-front {
    font-size: 2.8rem;
  }

  .concentration-card-back::after {
    font-size: 1.2rem;
  }
}

.brain-hub-top { max-width: 520px; margin: 0 auto; padding: 10px 12px 0; }
.brain-game-stage {
    min-height: 400px;
    max-width: 560px;
    margin: 25px auto 8px auto;
    padding: 0 12px;
    box-sizing: border-box;
}
.brain-hub-pick-label { display: block; margin-bottom: 6px; color: #0b2b3a; }

.brain-class-join { text-align: center; padding-bottom: 8px; }
.brain-intro-screen { max-width: 520px; margin: 0 auto; padding: 32px 20px 28px; text-align: center; background: #fff; border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08); }
.brain-intro-screen[hidden], .brain-end-screen[hidden], .brain-play-shell[hidden] { display: none !important; }
.brain-intro-title {
  margin: 0 0 1.5rem;

  font-size: clamp(3.25rem, 9vw, 4.75rem);
  line-height: 1.08;
  letter-spacing: -0.055em;
  font-weight: 800;

  padding-bottom: 0.08em;

  background: linear-gradient(
    135deg,
    #082f49 0%,
    #075985 45%,
    #0f766e 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;

  text-wrap: balance;
}
.h1title {padding-bottom:25px; padding-top:10px;}
.scorefont {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;

  padding: 0.75rem 1.1rem;
  border-radius: 999px;

  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(14, 116, 144, 0.14);
  box-shadow: 0 5px 14px rgba(8, 47, 73, 0.06);

  color: #0b3551;
  font-size: clamp(1.25rem, 4vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;

  backdrop-filter: blur(12px);
}

.scorefont strong {
  color: #164e63;
  font-weight: 700;
}

.scorefont #brainEndScore {
  color: #075985;
  font-size: 1.15em;
  font-weight: 900;
}
.brain-intro-blurb { font-size: 1.05rem; line-height: 1.5; color: #334; margin: 0 0 28px 0; }
.brain-intro-start-btn { 
    background-color: #339966;
    background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08) 6px, transparent 6px, transparent 12px);
    color: white;
    border: 0;
    border-radius: 5px;
    height: 40px;
    width: 140px;
    font-size: 24px;
    /* margin: 10px auto; */
    cursor: pointer;
 }
.brain-intro-start-btn:hover { background-color: #127041; }
.brain-end-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; padding-top:15px;}
.brain-end-back-btn { 
    background-color: #ffffff;
    background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08) 6px, transparent 6px, transparent 12px);
    color: black;
    border: 0;
    border-radius: 5px;
    height: 40px;
    width: 140px;
    font-size: 24px;
    /* margin: 10px auto; */
    cursor: pointer;
    border: 1px solid #000000;
}
.brain-end-back-btn:hover { background-color: #127041; color: white; }
.brain-play-shell { max-width: 560px; margin: 0 auto; }
.brain-question-bar { position: relative; height: auto; min-height: 0; margin-bottom: 0; display: block; }
.brain-canvas-area { flex-direction: column; }
.brain-instructions-box h2 { margin-top: 1.2em; }
.brain-about-list { margin: 0; padding-left: 1.25rem; }
.brain-about-list li { margin-bottom: 0.5em; }
.brain-game-blurb { margin-bottom: 1.5em; padding: 0 12px; max-width: 720px; margin-left: auto; margin-right: auto; }
.brain-coming-soon { color: #64748b; font-weight: 500; font-size: 0.85em; }

/* Memory Matrix grid (shared game mount) */
.memory-hud { max-width: 520px; margin: 0 auto; padding: 0 4px 6px; }
.memory-hud-row {
    position: relative;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}
.memory-hud-item { font-family: "Open Sans", Roboto, Arial, sans-serif; font-size: 16px; color: #0b2b3a; }
.memory-hud-label { font-weight: 700; opacity: 0.85; margin-right: 4px; }
.memory-hud-value {
    font-family: "Open Sans", Roboto, Arial, sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.memory-hud-hub { width: 100%; max-width: 520px; }
.memory-hud-lives {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}
.memory-hud-lives[hidden] { display: none !important; }
.memory-life {
    display: inline-flex;
    line-height: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.memory-life svg {
    width: 26px;
    height: 26px;
    fill: #2aa7ff;
}
.memory-life.is-lost svg {
    fill: none;
    stroke: #2aa7ff;
    stroke-width: 1.6px;
    opacity: 0.35;
}
.memory-life.is-lost {
    transform: scale(0.92);
}
.memory-sound-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 0;
    color: #0b2b3a;
    opacity: 0.85;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.memory-sound-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.06);
}
.memory-sound-btn .memory-sound-off[hidden] { display: none; }
.memory-sound-btn.is-muted .memory-sound-on { display: none; }
.memory-sound-btn.is-muted .memory-sound-off { display: block; }
.memory-game-mount { min-height: 0; }
.brain-canvas-area,
.brain-play-shell #canvasArea {
    height: auto;
    min-height: 0;
    padding: 0;
}
.memory-grid { --grid-size: 3; --gap: 12px; max-width: 520px; width: min(400px, 92vw); aspect-ratio: 1 / 1; margin: 8px auto 0 auto; display: grid; grid-template-columns: repeat(var(--grid-size), 1fr); gap: var(--gap); user-select: none; touch-action: manipulation; }
.memory-tile {
    border-radius: 10px;
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
    perspective: 700px;
}
.memory-tile:active { transform: scale(0.98); }

.memory-tile-inner {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.35s ease;
    border-radius: 10px;
}

.memory-tile-face {
    position: absolute;
    inset: 0;
    border-radius: 10px;
    backface-visibility: hidden;
    border: 2px solid rgba(0,0,0,0.12);
    background: #ffffff;
    box-shadow: 0 6px 14px rgba(0,0,0,0.08);
}

.memory-tile-front {
    transform: rotateX(180deg);
    background: #2aa7ff;
    border-color: rgba(0,0,0,0.18);
    box-shadow: 0 10px 22px rgba(42,167,255,0.35);
}

/* Wrong = no flip; highlight + shake */
.memory-tile.is-wrong .memory-tile-back {
    background: #ff4b4b;
    border-color: rgba(0,0,0,0.18);
    box-shadow: 0 10px 22px rgba(255,75,75,0.30);
}

/* Flip vertically like Card Matching (Memory Matrix) */
.memory-tile.is-active .memory-tile-inner,
.memory-tile.is-correct .memory-tile-inner {
    transform: rotateX(180deg);
}

/* Sequence Memory — flash (color pulse) instead of flip */
.memory-grid--flash .memory-tile {
    perspective: none;
}
.memory-grid--flash .memory-tile-inner {
    transform-style: flat;
    transition: none;
}
.memory-grid--flash .memory-tile-front {
    display: none;
}
.memory-grid--flash .memory-tile-back {
    transition: background 0.08s ease, border-color 0.08s ease, box-shadow 0.08s ease, transform 0.08s ease;
}
.memory-grid--flash .memory-tile.is-active .memory-tile-inner,
.memory-grid--flash .memory-tile.is-correct .memory-tile-inner {
    transform: none;
}
.memory-grid--flash .memory-tile.is-active .memory-tile-back,
.memory-grid--flash .memory-tile.is-correct .memory-tile-back {
    background: #2aa7ff;
    border-color: rgba(0, 0, 0, 0.18);
    box-shadow: 0 10px 22px rgba(42, 167, 255, 0.45);
    transform: scale(1.04);
}

@keyframes memoryShake {
    0% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
    100% { transform: translateX(0); }
}

/* Number Memory */
.number-memory-panel {
    max-width: 520px;
    margin: 12px auto 0;
    padding: 8px 12px 24px;
    text-align: center;
}
.number-memory-display {
    min-height: 4.6rem;
    padding: 18px 8px 10px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none;
    pointer-events: none;
}
.number-memory-canvas {
    display: block;
    width: 100%;
    max-width: 520px;
    height: 96px;
    margin: 0 auto;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
}
.number-memory-answer-wrap {
    margin-top: 8px;
}
.number-memory-answer-wrap[hidden] {
    display: none !important;
}
.number-memory-answer-label {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    color: #334;
    margin: 0 0 14px;
}
.number-memory-input {
    max-width: 360px;
    margin: 0 auto 18px;
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 12px 14px !important;
}
.number-memory-submit {
    margin-top: 4px;
}
.brain-end-detail {
    margin: 0 0 18px;
}
.brain-end-detail[hidden] {
    display: none !important;
}
.number-memory-end-detail {
    display: grid;
    gap: 8px;
    justify-items: center;
    font-size: 1.05rem;
    color: #334;
}
.number-memory-end-label {
    font-weight: 700;
    opacity: 0.75;
    margin-right: 6px;
}
.number-memory-end-value {
    font-weight: 800;
    letter-spacing: 0.06em;
    word-break: break-all;
}

.memory-tile.is-wrong-anim .memory-tile-inner {
    animation: memoryShake 260ms ease-in-out;
}
#txtQuestion .questionMeasurement { font-size: 30px; font-weight: bold; color: #000; }
#txtQuestion .gameOver { font-size: 35px; font-weight: bold; color: #f44336; }

.brain-hub-pick {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex-direction: column;
  margin: 0 0 1.5rem;
}

.brain-hub-pick-label {
  color: #164e63;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brain-hub-select {
  width: auto;
  min-width: min(100%, 280px);

  appearance: none;
  -webkit-appearance: none;

  padding: 0.8rem 2.75rem 0.8rem 1rem;
  border-radius: 14px;

  border: 1px solid rgba(14, 116, 144, 0.18);
  background-color: rgba(255, 255, 255, 0.78);

  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%23075985' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 14px;

  color: #0b3551;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;

  box-shadow: 0 6px 18px rgba(8, 47, 73, 0.06);
  cursor: pointer;

  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.brain-hub-select:hover {
  background-color: rgba(255, 255, 255, 0.92);
  border-color: rgba(14, 116, 144, 0.3);
}

.brain-hub-select:focus {
  outline: none;
  border-color: rgba(2, 132, 199, 0.55);
  box-shadow:
    0 0 0 4px rgba(56, 189, 248, 0.16),
    0 8px 22px rgba(8, 47, 73, 0.08);
}

.brain-hub-select:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

@media (max-width: 600px) {
  .brain-hub-pick {
    align-items: stretch;
  }

  .brain-hub-pick-label {
    width: 100%;
    text-align: center;
  }

  .brain-hub-select {
    width: 100%;
    min-width: 0;
  }
}






/* Brain game dropdown */
#brainGameNav.brain-hub-pick {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;

  margin: 0 0 1.5rem;
}

#brainGameNav .brain-hub-pick-label {
  color: #164e63;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#brainGameNavSelect.brain-hub-select {
  width: auto;
  min-width: min(100%, 300px);

  appearance: none;
  -webkit-appearance: none;

  padding: 0.85rem 2.8rem 0.85rem 1rem;
  border-radius: 14px;

  border: 1px solid rgba(14, 116, 144, 0.18);
  background-color: rgba(255, 255, 255, 0.82);

  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%23075985' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 14px;

  color: #0b3551;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;

  box-shadow: 0 6px 18px rgba(8, 47, 73, 0.055);
  cursor: pointer;

  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease,
    transform 160ms ease;
}

#brainGameNavSelect.brain-hub-select:hover {
  background-color: rgba(255, 255, 255, 0.95);
  border-color: rgba(14, 116, 144, 0.3);
  box-shadow: 0 8px 22px rgba(8, 47, 73, 0.07);
}

#brainGameNavSelect.brain-hub-select:focus {
  outline: none;
  border-color: rgba(2, 132, 199, 0.55);
  box-shadow:
    0 0 0 4px rgba(56, 189, 248, 0.16),
    0 8px 22px rgba(8, 47, 73, 0.08);
}

/* Open dropdown menu styling — browser support varies */
#brainGameNavSelect.brain-hub-select optgroup {
  color: #64748b;
  background: #f8fcff;
  font-weight: 800;
}

#brainGameNavSelect.brain-hub-select option {
  color: #0b3551;
  background: #ffffff;
  font-weight: 600;
}

#brainGameNavSelect.brain-hub-select option:checked {
  color: #082f49;
  background: #e0f2fe;
  font-weight: 800;
}

#brainGameNavSelect.brain-hub-select option:disabled {
  color: #94a3b8;
  background: #f8fafc;
}

@media (max-width: 600px) {
  #brainGameNav.brain-hub-pick {
    align-items: stretch;
  }

  #brainGameNav .brain-hub-pick-label {
    width: 100%;
    text-align: center;
  }

  #brainGameNavSelect.brain-hub-select {
    width: 100%;
    min-width: 0;
  }
}

/* Reaction Time */
.memory-hud-reaction .memory-hud-row {
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.reaction-hud-stats {
  display: flex;
  flex: 1 1 auto;
  justify-content: center;
  gap: 10px 18px;
  flex-wrap: wrap;
  min-width: 0;
}

.reaction-hud-sound {
  flex: 0 0 auto;
  margin-left: auto;
}

.memory-hud-reaction .reaction-stat {
  min-width: 72px;
}

.memory-hud-reaction .reaction-stat-value {
  font-size: 22px;
}

.memory-hud-reaction .reaction-stat-unit {
  font-size: 14px;
  font-weight: 600;
  color: rgba(11, 43, 58, 0.45);
}

.memory-hud-reaction .reaction-stat-label {
  font-size: 10px;
  white-space: nowrap;
}

.reaction-mount {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  margin-top: 16px;
}

.reaction-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
}

.reaction-stat {
  text-align: center;
  min-width: 88px;
}

.reaction-stat-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(11, 43, 58, 0.62);
  margin-bottom: 4px;
}

.reaction-stat-value {
  font-family: Consolas, "Andale Mono", "Lucida Console", Monaco, "Courier New", monospace;
  font-size: 28px;
  font-weight: 800;
  color: #0b2b3a;
  line-height: 1.1;
}

.reaction-pad {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 280px;
  padding: 28px 20px;
  border: 3px solid rgba(8, 47, 73, 0.18);
  border-radius: 16px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
  box-shadow: 0 10px 28px rgba(8, 47, 73, 0.12);
}

.reaction-pad:focus-visible {
  outline: 3px solid rgba(21, 87, 38, 0.45);
  outline-offset: 3px;
}

.reaction-pad:active {
  transform: scale(0.992);
}

.reaction-pad.is-idle {
  background: linear-gradient(180deg, #f8fcff 0%, #e8f4fa 100%);
  color: #0b2b3a;
}

.reaction-pad.is-waiting {
  background: #e74c3c;
  border-color: #922b21;
  color: #fff;
}

.reaction-pad.is-go {
  background: #2ecc71;
  border-color: #0b6a3f;
  color: #fff;
}

.reaction-pad.is-result {
  background: #3498db;
  border-color: #1a5276;
  color: #fff;
}

.reaction-pad.is-false-start {
  background: #f39c12;
  border-color: #b9770e;
  color: #fff;
}

.reaction-pad-label {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
}

.reaction-pad-hint {
  font-size: 0.92rem;
  font-weight: 400;
  line-height: 1.35;
  text-align: center;
  max-width: 320px;
  opacity: 0.88;
}

.reaction-pad.is-waiting .reaction-pad-hint,
.reaction-pad.is-go .reaction-pad-hint,
.reaction-pad.is-false-start .reaction-pad-hint {
  display: none;
}

.reaction-pad.is-result .reaction-pad-hint {
  display: none;
}

.reaction-pad.is-result .reaction-pad-label {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.2em;
}

.reaction-time-value {
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 800;
  line-height: 1;
}

.reaction-time-unit {
  font-size: clamp(0.95rem, 3vw, 1.25rem);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.62);
  line-height: 1;
}

.reaction-pad-rating {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  opacity: 0.95;
}

.reaction-pad-try-again {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  animation: reaction-try-again-glow 2.8s ease-in-out infinite;
}

@keyframes reaction-try-again-glow {
  0%, 100% {
    opacity: 0.55;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.15);
  }
  50% {
    opacity: 1;
    text-shadow: 0 0 14px rgba(255, 255, 255, 0.45);
  }
}

.reaction-reset-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}

.reaction-reset-btn {
  background: none;
  border: 0;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(11, 43, 58, 0.55);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.reaction-reset-btn:hover {
  color: rgba(11, 43, 58, 0.85);
}

.brain-play-shell:has(.reaction-mount) {
  max-width: 560px;
}

/* Aim Trainer */
.memory-hud-aim .memory-hud-row {
  position: relative;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
}
.aim-hud-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 0 1 auto;
  min-width: 0;
  z-index: 1;
}
.aim-hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  margin-left: auto;
  z-index: 1;
}
.aim-stat {
  text-align: left;
  min-width: 64px;
}
.aim-stat-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(11, 43, 58, 0.55);
}
.aim-stat-value {
  display: block;
  font-family: "Open Sans", Roboto, Arial, sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  color: #0b2b3a;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.memory-hud-aim .memory-hud-lives {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 0;
  pointer-events: none;
}
.aim-mount {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: 100%;
  max-width: 720px;
  margin: 12px auto 0;
}
.aim-arena {
  position: relative;
  width: 100%;
  height: min(420px, 58vh);
  min-height: 280px;
  border-radius: 14px;
  overflow: hidden;
  cursor: crosshair;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.55), transparent 55%),
    linear-gradient(160deg, #e8f4fb 0%, #d7ebf7 45%, #c9e2f2 100%);
  border: 1px solid rgba(14, 116, 144, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 10px 28px rgba(8, 47, 73, 0.08);
  touch-action: manipulation;
  user-select: none;
}
.aim-ready {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  background: rgba(232, 244, 251, 0.72);
  backdrop-filter: blur(2px);
}
.aim-ready[hidden] {
  display: none !important;
}
.aim-ready-title {
  font-family: "Open Sans", Roboto, Arial, sans-serif;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #0b2b3a;
}
.aim-ready-hint {
  max-width: 28rem;
  font-size: 1.05rem;
  line-height: 1.45;
  color: rgba(11, 43, 58, 0.72);
}
.aim-target {
  position: absolute;
  z-index: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background:
    radial-gradient(circle at 35% 30%, #7dd3fc 0%, #0ea5e9 42%, #0369a1 78%, #0c4a6e 100%);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.85),
    0 0 0 6px rgba(14, 165, 233, 0.35),
    0 8px 18px rgba(3, 105, 161, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.aim-target::after {
  content: "";
  position: absolute;
  inset: 28%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 2px rgba(3, 105, 161, 0.25);
}
.aim-target:hover,
.aim-target:focus-visible {
  transform: scale(1.08);
  filter: brightness(1.06);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.95),
    0 0 0 8px rgba(14, 165, 233, 0.45),
    0 10px 22px rgba(3, 105, 161, 0.4);
  outline: none;
}
.aim-target.is-pop {
  animation: aim-target-pop 0.18s ease-out;
}
@keyframes aim-target-pop {
  from {
    transform: scale(0.55);
    opacity: 0.35;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.aim-target[hidden] {
  display: none !important;
}
.aim-reset-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}
.brain-play-shell:has(.aim-mount) {
  max-width: 760px;
}

/* Language picker (Verbal Memory intro / end) */
.brain-intro-extra,
.brain-end-extra {
  margin: 0 0 22px;
}
.brain-intro-extra[hidden],
.brain-end-extra[hidden] {
  display: none !important;
}
.brain-lang-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.brain-lang-option {
  appearance: none;
  border: 2px solid transparent;
  background: transparent;
  color: #0b2b3a;
  font-family: "Open Sans", Roboto, Arial, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.brain-lang-option:hover {
  background: rgba(14, 116, 144, 0.08);
}
.brain-lang-option.is-selected {
  border-color: #0e7490;
  background: rgba(14, 116, 144, 0.1);
  color: #082f49;
  font-weight: 800;
}

/* Verbal Memory play UI */
.verbal-memory-panel {
  max-width: 520px;
  margin: 28px auto 0;
  padding: 12px 16px 24px;
  text-align: center;
}
.verbal-memory-word {
  min-height: 2.4em;
  margin: 24px 0 36px;
  font-family: "Open Sans", Roboto, Arial, sans-serif;
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: #0b2b3a;
  word-break: break-word;
}
.verbal-memory-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.verbal-memory-btn {
  min-width: 132px;
  height: 48px;
  padding: 0 22px;
  border: none;
  border-radius: 8px;
  font-family: "Open Sans", Roboto, Arial, sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  color: #fff;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.verbal-memory-btn:hover {
  filter: brightness(1.05);
}
.verbal-memory-btn:active {
  transform: scale(0.98);
}
.verbal-memory-btn:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}
.verbal-memory-btn-seen {
  background: #0e7490;
}
.verbal-memory-btn-new {
  background: #339966;
}