:root{
  --midnight:#0A1222;
  --sand:#F4EDE6;
  --blue:#1C6DF2;
  --teal:#04C2A8;
  --warm:#7A828A;

  --bg: var(--midnight);
  --text: var(--sand);
  --muted: rgba(122,130,138,.95);

  --line: rgba(244,237,230,.12);
  --lineStrong: rgba(244,237,230,.26);

  --shadow: 0 16px 46px rgba(0,0,0,.45);
  --shadowSoft: 0 10px 26px rgba(0,0,0,.26);

  --radius: 20px;
}

*{ box-sizing:border-box; }
html, body{ height:100%; }

body{
  margin:0;
  height: 100svh;
  overflow: hidden;
  display:flex;
  flex-direction:column;

  background: radial-gradient(1200px 900px at 20% -10%, #070D18 0%, #0A1222 55%, #0C1730 100%) fixed;
  color:var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;

  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overscroll-behavior: none;
}

input, select, textarea{ user-select: text; }
img{ -webkit-user-drag: none; }
.hidden{ display:none !important; }

/* ---- Background canvas behind everything ---- */
.bgCanvas{
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
}

/* Main layout above bg */
.app{
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;

  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 14px 16px;
}

/* Each screen fills available height; no page scrollbars */
.screen{
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Two-zone layout: main + docked keyboard (only on some screens) */
.screenFlex{
  height: 100%;
  min-height: 0;
  display:flex;
  flex-direction: column;
}

.screenMain{
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* ---- Cards / UI ---- */
.card{
  background: linear-gradient(180deg, rgba(244,237,230,.07), rgba(244,237,230,.03));
  border: 1px solid rgba(244,237,230,.10);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 12px 0;
}

.card.small{
  padding: 14px;
  box-shadow: none;
  background: rgba(244,237,230,.04);
}

.sep{
  border: 0;
  border-top: 1px solid rgba(244,237,230,.12);
  margin: 16px 0;
}

.muted{
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
  text-align:center;
  margin: 10px 0 0;
}

.screen h1{
  margin: 10px 0 8px;
  font-size: 46px;
  letter-spacing: .2px;
  text-align:center;
}

.screen h2{
  margin: 0 0 10px;
  font-size: 22px;
  letter-spacing: .15px;
  text-align:center;
}

/* ---- Forms ---- */
.field{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin: 12px 0;
  width: 100%;
}

.field > span{
  font-size: 18px;
  color: var(--muted);
  text-align:center;
}

input, select{
  width:100%;
  padding: 16px 16px;
  border-radius: 18px;
  border: 1px solid rgba(244,237,230,.14);
  background: rgba(10,18,34,.52);
  color: var(--text);
  outline: none;
  font-size: 20px;
}

input::placeholder{
  color: rgba(122,130,138,.72);
}

input:focus, select:focus{
  border-color: rgba(4,194,168,.42);
  box-shadow: 0 0 0 6px rgba(4,194,168,.12);
}

.row{
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap:wrap;
  justify-content:center;
  margin-top: 14px;
  width: 100%;
}

button{
  cursor:pointer;
  border-radius: 999px;
  padding: 16px 22px;
  border: 1px solid rgba(244,237,230,.14);
  background: rgba(244,237,230,.06);
  color: var(--text);
  font-weight: 800;
  font-size: 20px;
}

button:hover{ background: rgba(244,237,230,.10); }

button.primary{
  background: rgba(244,237,230,.92);
  color: rgba(10,18,34,.98);
  border-color: rgba(244,237,230,.18);
  box-shadow: 0 14px 34px rgba(0,0,0,.30);
}

button.primary:hover{ filter: brightness(.98); }
button.ghost{ background: rgba(244,237,230,.05); }

button:disabled{
  opacity: .45;
  cursor: not-allowed;
}

/* ---- Participant list ---- */
.list{
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  width: 100%;
}

button.list-item{
  width: 100%;
  text-align: center;
  border-radius: 18px;
  padding: 16px 16px;
  background: rgba(10,18,34,.50);
  border: 1px solid rgba(244,237,230,.10);
  font-weight: 850;
  font-size: 20px;
}

button.list-item:hover{ background: rgba(244,237,230,.08); }

/* ---- Setup / Config layout ---- */
.pptStageWrap{
  position: relative;
  height: 100%;
  min-height: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 0;
}

.setupWrap{ align-items:center; }
.setupStage{
  width: min(1200px, 96vw);
  margin: 0 auto;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
}

.setupStageCentered{ align-items:center; }

.setupTitle{
  text-align: center;
  font-size: clamp(46px, 4.6vw, 68px);
  font-weight: 880;
  letter-spacing: .5px;
  margin: 4px 0 14px;
}

.setupGrid{
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.setupGridOne{
  max-width: 920px;
  margin: 0 auto;
}

.setupCard{
  width: 100%;
  max-width: 920px;
  text-align:center;
  display:flex;
  flex-direction:column;
  align-items:center;
  padding: 22px;
}

/* slightly reduce max widths so a bigger keyboard still fits without overflow */
.setupCard .field{ max-width: 820px; }
.setupActions{ justify-content:center; }

.setupStart{
  width: 100%;
  max-width: 820px;
  padding: 18px 22px;
  font-size: 22px;
}

/* Make Start button bigger (config screen) */
#startBtn{
  width: min(900px, 94vw);
  padding: 24px 30px;
  font-size: clamp(24px, 2.8vw, 34px);
  font-weight: 900;
}

/* Bottom row: edges (Change participant left, Reset right) */
.configBottomRow{
  width: 100%;
  max-width: 820px;
  justify-content: space-between !important;
  margin-top: 12px;
  gap: 10px;
}
.configBottomRow button{
  padding: 14px 18px;
  font-size: 18px;
}

/* Keep buttons away from Start area */
.configBottomRow button:first-child{ margin-right: auto; }
.configBottomRow button:last-child{ margin-left: auto; }

.configTop{
  text-align:center;
  margin: 0 0 10px;
}

/* ---- Stepper (Starting level) ---- */
.stepper{
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 14px;
}

.stepperBtn{
  padding: 14px 18px;
  min-width: 92px;
  font-size: 30px;
  font-weight: 900;
}

.stepperValue{
  text-align:center;
  font-variant-numeric: tabular-nums;
  width: 190px;
  padding: 14px 14px;
  border-radius: 18px;
  background: rgba(10,18,34,.52);
  border: 1px solid rgba(244,237,230,.14);
  color: var(--text);
  font-size: 30px;
}

/* prevent browser spinners */
.stepperValue{ -moz-appearance: textfield; }
.stepperValue::-webkit-outer-spin-button,
.stepperValue::-webkit-inner-spin-button{
  -webkit-appearance: none;
  margin: 0;
}

/* ---- HUD (admin-only; JS toggles body.adminOn) ---- */
.hud{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(244,237,230,.05);
  border: 1px solid rgba(244,237,230,.08);
  margin-bottom: 10px;
}

@media (min-width: 720px){
  .hud{ grid-template-columns: repeat(4, minmax(0,1fr)); }
}
@media (min-width: 1080px){
  .hud{ grid-template-columns: repeat(8, minmax(0,1fr)); }
}

.hud span{ font-weight: 900; }

#screenRun .hud,
#screenRun details.card.small,
#screenRecall details.card.small{
  display: none;
}
body.adminOn #screenRun .hud,
body.adminOn #screenRun details.card.small,
body.adminOn #screenRecall details.card.small{
  display: block;
}

/* ---- PPT stimulus stage ---- */
.stage{
  border-radius: var(--radius);
  background: rgba(244,237,230,.04);
  border: 1px solid rgba(244,237,230,.08);
}

.stage.pptStage{
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
  width: min(1800px, 90vw);
  text-align: center;
}

.stageTitle{
  font-size: 18px;
  color: var(--muted);
  letter-spacing: .2px;
  margin: 0;
  text-align:center;
}

.stageMain{
  font-size: clamp(110px, 11.2vw, 280px);
  font-weight: 900;
  letter-spacing: .5px;
  line-height: 1.02;
  margin: 0;
  word-break: break-word;
  text-align:center;
  font-variant-numeric: tabular-nums;
}

.stageHint{
  color: var(--muted);
  font-size: 18px;
  line-height: 1.4;
  text-align:center;
}

/* Drill: remove subtitles under stimuli */
#screenRun .stageTitle,
#screenRun .stageHint{
  display:none !important;
}

/* Timeout text slightly smaller than processing stimulus */
.timeoutText{
  font-size: clamp(68px, 7.2vw, 190px);
  font-weight: 900;
  letter-spacing: .18px;
}

/* ---- Right ladder ---- */
.pptLadder{
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  pointer-events: none;
  opacity: .62;
}
.pptLadder .rung{
  width: 168px;
  height: 68px;
  border-radius: 18px;
  background: linear-gradient(90deg, rgba(28,109,242,.16), rgba(4,194,168,.10));
  border: 1px solid rgba(244,237,230,.10);
  box-shadow: 0 12px 26px rgba(0,0,0,.26);
  backdrop-filter: blur(3px);
}
.pptLadder .rung:nth-child(1){ opacity:.26; height:58px; }
.pptLadder .rung:nth-child(2){ opacity:.34; height:60px; }
.pptLadder .rung:nth-child(3){ opacity:.42; }
.pptLadder .rung:nth-child(4){ opacity:.50; }
.pptLadder .rung:nth-child(5){ opacity:.58; }
.pptLadder .rung:nth-child(6){ opacity:.66; height:74px; }
.pptLadder .rung:nth-child(7){ opacity:.76; height:80px; }

/* ---- Countdown dots ---- */
.countdownDots{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 28px;
  padding: 10px 0 0;
}

.countdownDot{
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(244,237,230,.92);
  box-shadow: 0 14px 34px rgba(0,0,0,.40);
  transition: opacity 200ms ease, transform 200ms ease;
}

.countdownDot.off{
  opacity: 0;
  transform: scale(.72);
}

#screenCountdown .stageTitle{ display:none !important; }
#screenCountdown #countdownNote{ display:none !important; }
#screenCountdown #countdownFeedback{
  font-size: clamp(26px, 2.6vw, 36px);
  margin-top: 18px;
}

/* ---- Spatial grid (base) ---- */
.grid5{
  display:grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  max-width: min(680px, 80vw);
  margin: 0 auto;
}

.gridCell{
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid var(--lineStrong);
  background: rgba(10,18,34,.44);
  color: var(--text);
  border-radius: 18px;
  aspect-ratio: 1 / 1;
  padding: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  user-select:none;
  font-weight: 900;
  font-size: 26px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18);
}

.gridCell:hover{ background: rgba(244,237,230,.08); }
.gridCell:active{ transform: scale(.99); }

.gridCell.hit{
  background: rgba(4,194,168,.10);
  border-color: rgba(4,194,168,.34);
  box-shadow: 0 0 0 6px rgba(4,194,168,.08), inset 0 0 0 1px rgba(0,0,0,.18);
}

.gridCell.selected{
  background: rgba(28,109,242,.12);
  border-color: rgba(28,109,242,.32);
}

/* MEMORY grid BIGGER (RUN): scale to screen height, not just width */
#screenRun .grid5{
  max-width: min(86vh, 78vw);  /* key change: use height */
  gap: 16px;
}

/* larger tiles help legibility */
#screenRun .gridCell{
  border-width: 2px;
  border-radius: 20px;
}

/* Recall grid SMALLER (RECALL) */
#screenRecall .grid5{
  max-width: min(480px, 62vw);
  gap: 10px;
}

/* Unified F glyph */
.fGlyph{
  display: inline-block;
  font-weight: 950;
  letter-spacing: 1px;
  line-height: 1;
}
.fGlyph.mirrored{ transform: scaleX(-1); }

.fGlyph.small{
  font-size: 64px;    /* bigger F on memory grid */
  letter-spacing: .6px;
}

.fGlyph.big{
  font-size: clamp(120px, 11vw, 280px);
}

/* ---- Recall ---- */
.recallHero{
  font-size: clamp(92px, 9.0vw, 190px);
  font-weight: 900;
  letter-spacing: .6px;
  margin: 0 0 8px;
  text-align:center;
}

.recallPrompt{
  text-align:center;
  margin: 0 auto 14px;
  max-width: min(980px, 92vw);
  font-size: clamp(18px, 2.0vw, 26px);
}

.recallPanel{
  margin: 0 auto;
  width: min(980px, 92vw);
  background: rgba(10,18,34,.55);
  border: 1px solid rgba(244,237,230,.12);
  border-radius: 22px;
  padding: 16px;
}

#recallForm.numRecall{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

#recallForm.numRecall .field{ margin: 0; }
#recallForm.numRecall input{
  font-size: 44px;
  text-align: center;
  padding: 14px 12px;
  border-radius: 18px;
  font-variant-numeric: tabular-nums;
}

/* ---- Level up ---- */
#screenLevelUp .stageMain{
  font-size: clamp(96px, 8.8vw, 220px);
  letter-spacing: .6px;
}
#screenLevelUp .stageTitle{
  display:block;
  margin-top: 12px;
  font-size: clamp(22px, 2.6vw, 34px);
  color: rgba(244,237,230,.86);
}
#screenLevelUp #levelUpHint{ display:none !important; }

#levelUpGoBtn{
  width: min(900px, 92vw);
  padding: 26px 34px;
  font-size: clamp(26px, 3.2vw, 40px);
  font-weight: 900;
  border-radius: 999px;
}

/* ---- Debug ---- */
pre{
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  color: rgba(244,237,230,.92);
  margin: 0;
}

details > summary{
  cursor:pointer;
  color: var(--muted);
  user-select:none;
  text-align:center;
}

/* ---- Floating Pause ---- */
.pauseFloat{
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 60;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid rgba(244,237,230,.14);
  background: rgba(10,18,34,.60);
  color: rgba(243,244,246,.95);
  font-weight: 900;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadowSoft);
}
.pauseFloat:hover{ background: rgba(244,237,230,.08); }

/* =========================================================
   Docked keyboard / keypad (NO frame, only keys)
   ========================================================= */
.softKbd{
  flex: 0 0 auto;
  width: 100%;
  min-height: 0;

  background: transparent;
  border: none;
  box-shadow: none;

  padding: 6px 0 calc(10px + env(safe-area-inset-bottom));
}

.softKbdKeys{
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap: 10px;

  padding: 0 14px;
}

/* Setup keyboard: BIGGER (participant insertion screen) */
.softKbdSetup{
  padding: 8px 0 calc(14px + env(safe-area-inset-bottom));
}
.softKbdSetup .softKbdKeys{
  gap: 12px;
  padding: 0 16px;
}

.kbdRow{
  display:flex;
  gap: 10px;
  justify-content:center;
}

.kbdKey{
  appearance:none;
  border-radius: 20px;

  height: clamp(64px, 7.2vh, 86px);

  min-width: 66px;
  padding: 0 18px;

  border: 2px solid rgba(244,237,230,.14);
  background: rgba(244,237,230,.06);
  color: rgba(243,244,246,.95);
  font-weight: 900;
  font-size: clamp(22px, 2.2vw, 30px);
}

.kbdKey:active{ transform: scale(.99); }

.kbdKey.wide{ min-width: 130px; }
.kbdKey.xwide{ min-width: 420px; }

.kbdKey.primaryLike{
  background: rgba(244,237,230,.92);
  color: rgba(10,18,34,.98);
  border-color: rgba(244,237,230,.18);
}

/* Recall keypad: big */
.softKbdRecall{
  flex: 0 0 clamp(340px, 42vh, 580px);
  padding: 12px 0 calc(16px + env(safe-area-inset-bottom));
}

.softKbdRecall .softKbdKeys{
  padding: 0 18px;
  gap: 14px;
}

.softKbdRecall .kbdRow{
  gap: 14px;
}

.softKbdRecall .kbdKey{
  height: clamp(78px, 9.0vh, 112px);
  font-size: clamp(30px, 3.4vw, 46px);
  min-width: 86px;
  padding: 0 18px;
  border-radius: 24px;
  border-width: 2px;
}

.softKbdRecall .kbdKey.wide{ min-width: 170px; }
.softKbdRecall .kbdKey.xwide{ min-width: 460px; }

/* =========================================================
   Micro feedback motion
   ========================================================= */
.stimulusWrap{
  display:flex;
  align-items:center;
  justify-content:center;
  will-change: transform, filter, opacity;
}

.stimulusWrap.fxGood{ animation: fxGood 420ms ease-out; }
.stimulusWrap.fxBad{ animation: fxBad 420ms ease-out; }

@keyframes fxGood{
  0%{ transform: scale(.985); filter: drop-shadow(0 0 0 rgba(4,194,168,0)); opacity:.92; }
  35%{ transform: scale(1.015); filter: drop-shadow(0 18px 34px rgba(4,194,168,.18)); opacity:1; }
  100%{ transform: scale(1); filter: drop-shadow(0 0 0 rgba(4,194,168,0)); opacity:1; }
}

@keyframes fxBad{
  0%{ transform: scale(.99); filter: drop-shadow(0 0 0 rgba(28,109,242,0)); opacity:.92; }
  35%{ transform: scale(1.01); filter: drop-shadow(0 18px 34px rgba(28,109,242,.14)); opacity:1; }
  100%{ transform: scale(1); filter: drop-shadow(0 0 0 rgba(28,109,242,0)); opacity:1; }
}

/* =========================================================
   Maintenance overlay (5 taps top-left)
   ========================================================= */
.maintOverlay{
  position: fixed;
  inset: 0;
  z-index: 20000;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(10,18,34,.72);
  backdrop-filter: blur(10px);
}

.maintCard{
  width: min(520px, 86vw);
  background: linear-gradient(180deg, rgba(244,237,230,.08), rgba(244,237,230,.04));
  border: 1px solid rgba(244,237,230,.10);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 18px 60px rgba(0,0,0,.55);
  text-align:center;
}

.maintTitle{ font-size: 24px; font-weight: 880; margin-bottom: 8px; }
.maintText{ margin-bottom: 14px; }
.maintHint{ margin-top: 12px; }

/* =========================================================
   REMOVE cycle badge (#1/#2/…) everywhere
   ========================================================= */
#cycleBadge,
.pptBadge{
  display:none !important;
}
