/* Loop Rush only. The 2D learning games retain their existing presentation. */
.loop-course-panel { display: none; }
body[data-view="game"][data-mode="loop"] {
  --loop-accent: #1b887d;
  --text: #244a4d;
  --muted: #496668;
  --gold: #315c5b;
  background: #daf0e5;
  color: #244a4d;
}
body[data-view="game"][data-mode="loop"] .runner-card { min-height: 100dvh; }
body[data-view="game"][data-mode="loop"] .hud {
  top: max(14px, env(safe-area-inset-top));
  left: 20px;
  right: 20px;
  border: 1px solid #ffffffc9;
  border-radius: 22px;
  padding: 12px 18px;
  background: #fffdf3ed;
  box-shadow: 0 7px 24px #2a666a18;
  backdrop-filter: blur(16px);
  grid-template-columns: 1fr minmax(310px, 430px);
}
body[data-mode="loop"] .hud .eyebrow { color: var(--loop-accent); font-size: 11px; letter-spacing: .14em; }
body[data-mode="loop"] #modeTitle { color: #244a4d; font-size: clamp(21px, 2.2vw, 30px); line-height: 1.1; }
body[data-mode="loop"] #instructionText { color: #627578; font-size: 13px; }
body[data-view="game"][data-mode="loop"] .stats { gap: 6px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
body[data-view="game"][data-mode="loop"] .stats div {
  background: #e7f0e7;
  border: 0;
  border-radius: 14px;
  box-shadow: none;
  min-height: 56px;
  padding: 9px 6px;
  align-content: center;
}
body[data-view="game"][data-mode="loop"] .stats div:first-child { background: #fce9ae; }
body[data-view="game"][data-mode="loop"] .stats span { color: #536866; font-size: 10px; letter-spacing: .1em; }
body[data-view="game"][data-mode="loop"] .stats strong,
body[data-view="game"][data-mode="loop"] #targetText { color: #315557; font-size: 21px; text-shadow: none; }
body[data-view="game"][data-mode="loop"] .loop-course-panel {
  display: grid;
  gap: 7px;
  position: absolute;
  z-index: 6;
  left: 22px;
  top: max(115px, calc(env(safe-area-inset-top) + 101px));
  width: min(780px, calc(100% - 44px));
}
.loop-course-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.loop-course-picker button {
  min-height: 55px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid #ffffffbd;
  border-radius: 15px;
  padding: 7px 9px;
  background: #fffdf2e8;
  color: #355756;
  box-shadow: 0 3px 9px #366c6310;
  text-align: left;
  min-width: 0;
}
.loop-course-picker button.is-current { border-color: var(--loop-accent); background: #fffef7; }
.loop-course-number { display: grid; place-items: center; width: 27px; height: 29px; flex: 0 0 27px; background: #e5eee6; border-radius: 9px; font-size: 11px; }
.is-current .loop-course-number { color: white; background: var(--loop-accent); }
.loop-course-picker strong { display: block; font-size: 12px; line-height: 1.2; }
.loop-course-picker small { display: block; font-size: 9px; line-height: 1.3; margin-top: 3px; font-weight: 500; color: #607879; }
.loop-journey { display: grid; grid-template-columns: 1fr auto; gap: 5px 14px; color: #305052; padding: 6px 12px 9px; border-radius: 11px; background: #ffffffd9; font-size: 11px; font-weight: 800; }
#loopGoal { color: #596e6d; font-weight: 500; }
.loop-lap-track { grid-column: 1 / -1; height: 4px; overflow: hidden; background: #d7e4de; border-radius: 4px; }
#loopLapFill { display: block; height: 100%; width: 0; background: var(--loop-accent); border-radius: 4px; transition: width .15s linear; }
body[data-view="game"][data-mode="loop"] .stage-overlay {
  inset: auto;
  top: 54%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(410px, calc(100% - 36px));
  border: 1px solid #ffffffde;
  border-radius: 26px;
  background: #fffdf2ed;
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 50px #26454525;
  padding: 27px;
}
body[data-mode="loop"] .stage-overlay strong { color: #315658; font-size: 28px; filter: none; }
body[data-mode="loop"] .stage-overlay span { color: #5c6e6b; font-size: 15px; line-height: 1.6; font-weight: 500; }
body[data-mode="loop"] .stage-start-button { background: var(--loop-accent); color: white; border: 0; min-height: 56px; min-width: 0; width: 100%; border-radius: 15px; box-shadow: 0 5px 0 #204c4525; font-size: 18px; }
body[data-mode="loop"] .stage-start-button:disabled { opacity: .6; cursor: wait; }
body[data-view="game"][data-mode="loop"] .control-row {
  left: 20px;
  right: 20px;
  bottom: max(14px, env(safe-area-inset-bottom));
  padding: 10px;
  gap: 8px;
  border-radius: 20px;
  background: #fffdf2ec;
  border: 1px solid #ffffffce;
  box-shadow: 0 5px 24px #365b5620;
  backdrop-filter: blur(12px);
}
body[data-mode="loop"] .control-row button { min-height: 48px; border: 0; border-radius: 12px; padding: 8px 16px; color: #2c5554; background: #e6eee4; font-size: 13px; }
body[data-mode="loop"] #startButton { background: var(--loop-accent); color: white; }
body[data-mode="loop"] #resetButton { background: #e6eee4; color: #2c5554; }
body[data-mode="loop"] #speakButton { display: none; }
body[data-mode="loop"] .phone-controls { gap: 6px; }
body[data-mode="loop"] [data-phone-dir="left"] { order: 0; }
body[data-mode="loop"] [data-phone-dir="right"] { order: 1; }
body[data-mode="loop"] [data-phone-dir="up"] { order: 2; }
body[data-mode="loop"] [data-phone-dir="down"] { order: 3; }
body[data-mode="loop"] .phone-controls [data-phone-dir="up"] { background: #f5dda1; }
body[data-mode="loop"] #statusText { font-size: 11px; font-weight: 500; color: #55716d; flex: 1 1 200px; }
body[data-mode="loop"] .grownup-panel { display: none; }
body[data-mode="loop"] button:focus-visible { outline: 3px solid #254f67; outline-offset: 3px; }
@media (max-width: 900px) {
  body[data-view="game"][data-mode="loop"] .hud { left: 12px; right: 12px; padding: 12px; grid-template-columns: 1fr 290px; }
  body[data-view="game"][data-mode="loop"] .control-row { left: 12px; right: 12px; }
  body[data-mode="loop"] #statusText { flex-basis: 100%; text-align: center; }
  body[data-mode="loop"] .control-row button { padding: 8px 12px; }
}
@media (max-width: 600px) {
  body[data-view="game"][data-mode="loop"] .hud { top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px; border-radius: 18px; padding: 10px 12px; gap: 8px; grid-template-columns: 1fr; }
  body[data-mode="loop"] .hud .mission { gap: 3px; }
  body[data-mode="loop"] .hud .eyebrow { font-size: 9px; }
  body[data-mode="loop"] #modeTitle { font-size: 23px; }
  body[data-mode="loop"] #instructionText { display: none; }
  body[data-view="game"][data-mode="loop"] .stats div { min-height: 39px; padding: 5px; border-radius: 9px; }
  body[data-view="game"][data-mode="loop"] .stats strong,
  body[data-view="game"][data-mode="loop"] #targetText { font-size: 17px; }
  body[data-view="game"][data-mode="loop"] .stats span { font-size: 8px; }
  body[data-view="game"][data-mode="loop"] .loop-course-panel { top: max(125px, calc(env(safe-area-inset-top) + 117px)); left: 8px; width: calc(100% - 16px); gap: 5px; }
  .loop-course-picker { gap: 5px; }
  .loop-course-picker button { gap: 3px; padding: 6px; min-height: 49px; flex-direction: column; justify-content: center; border-radius: 11px; text-align: center; }
  .loop-course-number { display: none; }
  .loop-course-picker strong { font-size: 12px; line-height: 1.3; }
  .loop-course-picker small { display: none; }
  .loop-journey { font-size: 10px; padding: 5px 9px 7px; gap: 4px; }
  body[data-view="game"][data-mode="loop"] .stage-overlay { top: 52%; padding: 23px; }
  body[data-mode="loop"] .stage-overlay strong { font-size: 25px; }
  body[data-view="game"][data-mode="loop"] .control-row { display: flex; left: 8px; right: 8px; padding: 8px; gap: 6px; border-radius: 17px; }
  body[data-mode="loop"] .control-row > button { flex: 1 1 25%; padding: 8px; min-height: 44px; font-size: 12px; }
  body[data-mode="loop"] .phone-controls { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; order: -1; gap: 6px; }
  body[data-mode="loop"] .phone-controls button { min-height: 49px; padding: 7px; }
  body[data-mode="loop"] #statusText { display: none; }
}
@media (max-height: 570px) and (min-width: 601px) {
  body[data-view="game"][data-mode="loop"] .hud { top: 7px; padding: 8px 12px; }
  body[data-mode="loop"] #instructionText { display: none; }
  body[data-mode="loop"] .hud .eyebrow { font-size: 9px; }
  body[data-mode="loop"] #modeTitle { font-size: 22px; }
  body[data-view="game"][data-mode="loop"] .loop-course-panel { top: 82px; width: min(640px, calc(100% - 44px)); }
  .loop-course-picker button { min-height: 44px; }
  .loop-course-picker small, .loop-journey, body[data-mode="loop"] #statusText { display: none; }
  body[data-view="game"][data-mode="loop"] .stage-overlay { top: 56%; padding: 14px; }
  body[data-mode="loop"] .stage-overlay strong { font-size: 22px; }
  body[data-mode="loop"] .stage-overlay span { font-size: 12px; line-height: 1.35; margin-bottom: 9px; }
  body[data-mode="loop"] .stage-start-button { min-height: 44px; }
}
