/* IC Power Classic — a committed single-theme look: the gym hall after hours,
   lit by mat blue and vault red. Every colour is painted explicitly so the page
   holds on any host ground. */
:root {
  --ink:        #0C1016;
  --ink-2:      #151B24;
  --ink-3:      #1E2732;
  --line:       #2C3644;
  --chalk:      #EDEAF2;
  --chalk-dim:  #9AA3B2;
  --mat-blue:   #3E7FC1;
  --mat-deep:   #24528C;
  --vault-red:  #C8302B;
  --wood:       #B9803F;
  --gold:       #F2B441;
  --spring:     #59D6A0;
  --shadow:     0 18px 40px -18px rgba(0,0,0,.9);
  --font-px:    "Silkscreen", "Courier New", monospace;
  --font-ui:    "Barlow Semi Condensed", "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

#app, #stage, .tbtn, #hud, #ticker, .overlay, .shape-chip {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body {
  background:
    radial-gradient(120% 80% at 50% 0%, #1B2330 0%, var(--ink) 60%),
    var(--ink);
  color: var(--chalk);
  font-family: var(--font-ui);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 28px;
  justify-content: center;
  min-height: 100%;
  padding-inline: 16px;
  padding-block: 20px;
  max-width: 1100px;
  margin-inline: auto;
}

/* ---------- stage ---------- */

#stage {
  position: relative;
  flex: 0 1 auto;
  --stage-aspect: 0.5625;
  aspect-ratio: var(--stage-aspect);
  width: min(100%, calc((100dvh - 44px) * var(--stage-aspect)));
  height: auto;
  max-width: 100%;
  border: 2px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #0A0D12;
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
}

#screen {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---------- judges' panel ---------- */

#hud {
  position: absolute;
  inset: 0 0 auto 0;
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(180deg, rgba(10,13,18,.88) 0%, rgba(10,13,18,.55) 70%, transparent 100%);
  pointer-events: none;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
}

.readout { display: flex; flex-direction: column; line-height: 1; }
.readout .label {
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--chalk-dim);
  font-weight: 600;
}
.readout .value {
  font-family: var(--font-px);
  font-size: 20px;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(0,0,0,.6);
}
.readout.d-score { align-items: center; }
.readout.d-score .value { color: var(--gold); font-size: 24px; }
.hud-row .readout:last-child { align-items: flex-end; }
.hud-row .readout:last-child .value { font-size: 15px; color: var(--chalk-dim); }

.combo-rail {
  position: relative;
  height: 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(0,0,0,.45);
  overflow: hidden;
  opacity: .35;
  transition: opacity .18s ease;
}
.combo-rail.live { opacity: 1; border-color: var(--mat-blue); }
.combo-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, var(--mat-deep), var(--mat-blue));
  transition: width .09s linear;
}
.combo-rail.hot .combo-fill { background: linear-gradient(90deg, #8A2016, var(--vault-red)); }
.combo-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-px);
  font-size: 9px;
  letter-spacing: .06em;
  text-shadow: 0 1px 0 rgba(0,0,0,.7);
}

/* ---------- shape selector ---------- */

.shape-row {
  display: flex;
  gap: 3px;
  pointer-events: auto;
}
.shape-chip {
  flex: 1;
  min-width: 0;
  padding: 4px 2px 3px;
  font-family: var(--font-px);
  font-size: 9px;
  letter-spacing: .02em;
  color: var(--chalk-dim);
  background: rgba(21,27,36,.82);
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
  transition: background .1s ease, color .1s ease, border-color .1s ease;
}
.shape-chip[aria-pressed="true"] {
  background: var(--mat-blue);
  border-color: var(--mat-blue-light, #62A0DC);
  color: #06101C;
}
.shape-chip:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.shape-row.warn .shape-chip[aria-pressed="true"] {
  background: var(--vault-red);
  border-color: var(--vault-red);
  color: #fff;
}

/* ---------- system buttons ---------- */

.sysbar {
  display: flex;
  gap: 4px;
  margin-top: 5px;
  pointer-events: auto;
  /* above the cards: you should be able to go full screen from the title */
  position: relative;
  z-index: 4;
}
.sysbtn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  color: var(--chalk);
  background: rgba(21,27,36,.8);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.sysbtn:active { background: var(--mat-deep); }
.sysbtn[aria-pressed="true"] { background: var(--mat-blue); color: #06101C; border-color: var(--mat-blue); }
.sysbtn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sysbtn[hidden] { display: none; }
#stage.overlay-open #btn-pause { display: none; }
#stage[data-orient="landscape"] .sysbtn { width: 22px; height: 22px; font-size: 10px; }
#stage[data-orient="landscape"] .sysbar { margin-top: 3px; }

/* ---------- the next element, and the speed that decides it ---------- */

.nextline {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 1px 0;
  pointer-events: none;
}
.nextline .speed {
  position: relative;
  width: 46px;
  height: 6px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(0,0,0,.5);
  overflow: hidden;
}
.nextline .speed i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, var(--mat-deep), var(--mat-blue));
  transition: width .08s linear;
}
.nextline.boosting .speed { border-color: var(--gold); }
.nextline.boosting .speed i { background: linear-gradient(90deg, var(--gold), #FFDE8A); }
.nextline .chip {
  font-family: var(--font-px);
  font-size: 9px;
  line-height: 1;
  padding: 3px 4px 2px;
  border-radius: 2px;
  background: var(--line);
  color: var(--chalk);
}
.nextline .skill {
  font-size: 12px;
  font-weight: 600;
  color: var(--chalk-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nextline[data-value="C"] .chip { background: var(--gold); color: #1A1206; }
.nextline[data-value="D"] .chip,
.nextline[data-value="E"] .chip { background: var(--vault-red); color: #fff; }
.nextline[data-value="C"] .skill,
.nextline[data-value="D"] .skill,
.nextline[data-value="E"] .skill { color: var(--chalk); }
#stage[data-orient="landscape"] .nextline .skill { font-size: 11px; }
#stage[data-orient="landscape"] .nextline .speed { width: 40px; height: 5px; }

/* ---------- element ticker ---------- */

#ticker {
  position: absolute;
  left: 10px;
  top: 138px;                 /* clears the four-row judges' panel */
  max-width: calc(100% - 20px);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 7px 3px 5px;
  border-radius: 4px;
  background: rgba(12,16,22,.72);
  border-left: 3px solid var(--mat-blue);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
#ticker.is-idle { opacity: 0; transform: translateY(-4px); }
#ticker .chip {
  font-family: var(--font-px);
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px 3px;
  border-radius: 3px;
  background: var(--mat-blue);
  color: #06101C;
  font-weight: 700;
}
#ticker .skill {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#ticker .bonus {
  margin-left: 4px;
  font-family: var(--font-px);
  font-size: 11px;
  color: var(--gold);
  white-space: nowrap;
}
#ticker[data-value="C"] { border-left-color: var(--gold); }
#ticker[data-value="C"] .chip { background: var(--gold); }
#ticker[data-value="D"], #ticker[data-value="E"] { border-left-color: var(--vault-red); }
#ticker[data-value="D"] .chip, #ticker[data-value="E"] .chip { background: var(--vault-red); color: #fff; }

/* ---------- guest speech ---------- */

.bubble {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 5px 10px 6px;
  border-radius: 6px;
  background: var(--chalk);
  color: #12161E;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(0,0,0,.45);
  animation: bubble-pop .16s ease-out;
}
.bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top-color: var(--chalk);
  border-bottom: 0;
}
.bubble .who {
  font-family: var(--font-px);
  font-size: 8px;
  letter-spacing: .1em;
  color: var(--mat-deep);
}
.bubble .say {
  font-family: var(--font-px);
  font-size: 13px;
  line-height: 1.1;
}
.bubble .sub { font-size: 13px; font-weight: 600; color: #3A4354; direction: rtl; }
.bubble[data-who="sini"] { background: #A8E4D4; }
.bubble[data-who="sini"]::after { border-top-color: #A8E4D4; }
.bubble[hidden] { display: none !important; }

@keyframes bubble-pop {
  from { transform: translate(-50%, -92%) scale(.82); opacity: 0; }
  to   { transform: translate(-50%, -100%) scale(1); opacity: 1; }
}

/* the master is watching: every element counts double */
.readout.d-score.doubled .value { color: #A8E4D4; }

/* ---------- overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  overflow-y: auto;           /* the card scrolls rather than clipping its CTA */
  overscroll-behavior: contain;
  padding: 24px 18px;
  background: rgba(8,11,16,.72);
  backdrop-filter: blur(2px);
  text-align: center;
  transition: opacity .2s ease;
}
.overlay[hidden] { display: none !important; }
.overlay h2 {
  font-family: var(--font-px);
  font-size: clamp(20px, 6vw, 30px);
  margin: 0 0 6px;
  line-height: 1.25;
  text-wrap: balance;
  text-shadow: 0 3px 0 rgba(0,0,0,.55);
}
.overlay h2 .hl { color: var(--mat-blue); }
.overlay p { margin: 0 0 14px; color: var(--chalk-dim); font-size: 16px; }
.overlay .cta {
  font-family: var(--font-px);
  font-size: 13px;
  padding: 12px 18px;
  border: 0;
  border-radius: 4px;
  background: var(--vault-red);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 #7C1A16;
  transition: transform .08s ease, box-shadow .08s ease;
}
.overlay .cta:active { transform: translateY(3px); box-shadow: 0 1px 0 #7C1A16; }
.overlay .cta:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.course-pick { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.course-pick .cta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  text-align: left;
}
.course-pick .ct { font-size: 13px; }
.course-pick .cb {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  opacity: .85;
  letter-spacing: 0;
}
.course-pick .ch {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .6;
}
.cta.alt { background: var(--mat-deep); box-shadow: 0 4px 0 #16355C; }
.cta.alt:active { box-shadow: 0 1px 0 #16355C; }

.routine {
  width: 100%;
  max-width: 280px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 14px;
  max-height: 32%;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.routine li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 8px;
  background: rgba(30,39,50,.72);
  border-radius: 3px;
}
.routine .rl {
  font-family: var(--font-px);
  font-size: 11px;
  color: var(--gold);
  width: 12px;
}
.routine .rn { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.routine .rv { font-family: var(--font-px); font-size: 11px; color: var(--chalk-dim); }

.final {
  font-family: var(--font-px);
  font-size: 34px;
  color: var(--gold);
  margin: 2px 0 2px;
  font-variant-numeric: tabular-nums;
}
.final-label { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--chalk-dim); }

/* ---------- touch controls ---------- */

.touch {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 2;
  display: none;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 10px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  pointer-events: none;
}

/* The two arrows sit at opposite edges — a thumb should never have to pick
   between them — and whatever you press to act sits in the middle. */
.tbtn[data-action="left"] { grid-column: 1; justify-self: start; }
.tbtn[data-action="right"] { grid-column: 3; justify-self: end; }
.tbtn.jump { grid-column: 2; justify-self: center; }
.tbtn.boost { grid-column: 2; justify-self: center; }
.tbtn {
  pointer-events: auto;
  font-family: var(--font-px);
  font-size: 18px;
  min-width: 64px;
  height: 64px;
  padding: 0;
  color: var(--chalk);
  background: rgba(30,39,50,.66);
  border: 2px solid rgba(237,234,242,.25);
  border-radius: 12px;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .06s ease, transform .06s ease;
}
/* Boost replaces the take-off button wherever he takes off by himself. */
.tbtn.boost {
  display: none;
  font-size: 20px;
  background: rgba(242,180,65,.34);
  border-color: rgba(242,180,65,.55);
  line-height: 1;
}
.tbtn.boost small {
  display: block;
  font-size: 8px;
  letter-spacing: .08em;
  margin-top: 2px;
  opacity: .85;
}
.tbtn.boost.is-down { background: rgba(242,180,65,.9); color: #1A1206; }

#stage[data-assist="autoJump"] .tbtn.jump { display: none; }
#stage[data-assist="autoJump"] .tbtn.boost { display: block; }
/* auto-run: the forward arrow is redundant, so the take-off takes its corner */
#stage[data-assist="autoRun"] .tbtn[data-action="right"] { display: none; }
#stage[data-assist="autoRun"] .tbtn.boost { display: block; }
#stage[data-assist="autoRun"] .tbtn.jump { grid-column: 3; justify-self: end; }
/* manual floor run: the take-off keeps the corner, the arrow steps inward */
#stage[data-course="run"][data-assist="none"] .tbtn[data-action="right"] { grid-column: 2; justify-self: center; }
#stage[data-course="run"][data-assist="none"] .tbtn.jump { grid-column: 3; justify-self: end; }

.tbtn.jump {
  font-size: 13px;
  min-width: 84px;
  height: 84px;
  border-radius: 50%;
  background: rgba(200,48,43,.72);
  border-color: rgba(255,255,255,.32);
}
.tbtn.is-down { background: rgba(62,127,193,.85); transform: scale(.96); }
.tbtn.jump.is-down { background: rgba(242,180,65,.9); color: #1A1206; }
.tbtn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- sidebar ---------- */

#sidebar {
  flex: 1 1 300px;
  max-width: 380px;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wordmark {
  font-family: var(--font-px);
  font-size: 27px;
  line-height: 1.15;
  margin: 0;
  text-shadow: 0 4px 0 rgba(0,0,0,.5);
}
.wordmark span { color: var(--mat-blue); }
.wordmark em {
  display: block;
  font-style: normal;
  font-size: 14px;
  letter-spacing: .3em;
  color: var(--vault-red);
  margin-top: 6px;
}
.tagline { margin: -4px 0 0; color: var(--chalk-dim); font-size: 16px; max-width: 34ch; }

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px 16px;
  background: linear-gradient(180deg, var(--ink-2), rgba(21,27,36,.4));
}
.panel h2 {
  font-family: var(--font-px);
  font-size: 12px;
  letter-spacing: .05em;
  margin: 0 0 12px;
  color: var(--chalk);
}
.note { font-size: 14px; color: var(--chalk-dim); margin: 12px 0 0; max-width: 40ch; }
.note strong { color: var(--chalk); font-weight: 600; }

.decides { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; color: var(--chalk-dim); }
.decides li::marker { color: var(--mat-blue); font-family: var(--font-px); font-size: 11px; }
.decides strong { color: var(--chalk); font-weight: 600; }
.decides em { font-style: normal; color: var(--gold); }

.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 15px; }
.keys dt { font-family: var(--font-px); font-size: 11px; color: var(--mat-blue); align-self: center; }
.keys dd { margin: 0; color: var(--chalk-dim); align-self: center; }

.catalogue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.catalogue li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 6px;
  border-radius: 3px;
  font-size: 15px;
}
.catalogue li.group {
  background: none;
  padding: 10px 0 2px;
  font-family: var(--font-px);
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--mat-blue);
}
.catalogue li.group:first-child { padding-top: 0; }
.catalogue li.row:nth-of-type(odd) { background: rgba(44,54,68,.35); }
.catalogue .cl {
  font-family: var(--font-px);
  font-size: 11px;
  width: 16px;
  text-align: center;
  color: var(--gold);
}
.catalogue .cn { flex: 1; }
.catalogue .cd { color: var(--chalk-dim); font-size: 13px; text-align: right; }

/* ---------- responsive ---------- */

@media (pointer: coarse) {
  .touch { display: grid; }
}

/* No controls while a card is up — they would cover its buttons. */
#stage.overlay-open .touch { display: none; }

@media (max-width: 860px) {
  #app {
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-block: 12px;
  }
  #stage {
    width: min(100%, calc((100dvh - 28px) * var(--stage-aspect)));
    max-width: 460px;
  }
  #sidebar { max-width: 460px; width: 100%; align-self: stretch; }
}

/* The floor run is a landscape frame: the judges' panel gets out of the way. */
#stage[data-orient="landscape"] #hud { padding: 5px 8px 6px; gap: 6px; }
#stage[data-orient="landscape"] .readout .value { font-size: 15px; }
#stage[data-orient="landscape"] .readout.d-score .value { font-size: 16px; }
#stage[data-orient="landscape"] .readout .label { font-size: 8px; }
#stage[data-orient="landscape"] .combo-rail { height: 10px; }
#stage[data-orient="landscape"] .combo-text { font-size: 8px; }
#stage[data-orient="landscape"] .shape-chip { font-size: 8px; padding: 2px 2px 1px; }
#stage[data-orient="landscape"] .overlay { padding: 10px 14px; align-items: start; }
#stage[data-orient="landscape"] .overlay h2 { font-size: 19px; margin-bottom: 2px; }
#stage[data-orient="landscape"] .overlay p { font-size: 13px; margin-bottom: 6px; }
#stage[data-orient="landscape"] .final { font-size: 25px; margin: 0; }
#stage[data-orient="landscape"] .final-label { font-size: 9px; }
#stage[data-orient="landscape"] .routine { max-height: 86px; font-size: 12px; margin-bottom: 10px; }
#stage[data-orient="landscape"] .routine li { padding: 2px 7px; }
#stage[data-orient="landscape"] .overlay .cta { padding: 9px 14px; font-size: 11px; }
#stage[data-orient="landscape"] .course-pick { gap: 7px; }
#stage[data-orient="landscape"] .course-pick .cta { padding: 8px 14px; }
#stage[data-orient="landscape"] .course-pick .cb { font-size: 12px; }
#stage[data-orient="landscape"] .course-pick .ch { font-size: 10px; }

#stage[data-orient="landscape"] #ticker {
  top: auto;
  bottom: 62px;               /* above the control row, not under it */
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 6px 2px 4px;
}
#stage[data-orient="landscape"] #ticker.is-idle { transform: translateX(-50%) translateY(4px); }
#stage[data-orient="landscape"] .touch { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
#stage[data-orient="landscape"] .tbtn { min-width: 46px; height: 46px; font-size: 14px; }
#stage[data-orient="landscape"] /* Boost replaces the take-off button wherever he takes off by himself. */
.tbtn.boost {
  display: none;
  font-size: 20px;
  background: rgba(242,180,65,.34);
  border-color: rgba(242,180,65,.55);
  line-height: 1;
}
.tbtn.boost small {
  display: block;
  font-size: 8px;
  letter-spacing: .08em;
  margin-top: 2px;
  opacity: .85;
}
.tbtn.boost.is-down { background: rgba(242,180,65,.9); color: #1A1206; }

#stage[data-assist="autoJump"] .tbtn.jump { display: none; }
#stage[data-assist="autoJump"] .tbtn.boost { display: block; }
/* auto-run: the forward arrow is redundant, so the take-off takes its corner */
#stage[data-assist="autoRun"] .tbtn[data-action="right"] { display: none; }
#stage[data-assist="autoRun"] .tbtn.boost { display: block; }
#stage[data-assist="autoRun"] .tbtn.jump { grid-column: 3; justify-self: end; }
/* manual floor run: the take-off keeps the corner, the arrow steps inward */
#stage[data-course="run"][data-assist="none"] .tbtn[data-action="right"] { grid-column: 2; justify-self: center; }
#stage[data-course="run"][data-assist="none"] .tbtn.jump { grid-column: 3; justify-self: end; }

.tbtn.jump { min-width: 62px; height: 62px; font-size: 11px; }
#stage[data-orient="landscape"] .touch .pad { gap: 7px; }
#stage[data-orient="landscape"] #ticker .skill { font-size: 11px; }
#stage[data-orient="landscape"] #ticker .chip { font-size: 9px; }

/* Phone turned sideways: the hall takes the whole screen and the reading
   material steps out of the way. */
@media (orientation: landscape) and (max-height: 620px) {
  html, body { overflow: hidden; }
  #app {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 6px 8px;
    padding-block: 6px;
    min-height: 100dvh;
  }
  #sidebar { display: none; }
  #stage {
    width: min(100%, calc((100dvh - 12px) * var(--stage-aspect)));
    max-width: 100%;
    max-height: calc(100dvh - 12px);
    border-radius: 10px;
  }
}

/* Immersive mode.
   The Fullscreen API is asked for on #app, never on the stage: the UA
   stylesheet forces width/height:100% !important on whatever element goes
   fullscreen, which would stretch the stage off its aspect ratio. #app is
   happy to fill the screen; the stage centres inside it at its own shape.
   Where the API is unavailable (iPhone Safari) the same class alone gives a
   full-viewport layout. */
body.immersive { overflow: hidden; }
body.immersive #sidebar { display: none; }
body.immersive #app {
  padding: 0;
  gap: 0;
  max-width: none;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  background: var(--ink);
}
body.immersive #stage {
  width: min(100vw, calc(100dvh * var(--stage-aspect)));
  max-width: 100vw;
  /* clears the gutter the landscape layout keeps — in immersive there is none */
  max-height: 100dvh;
  border-radius: 0;
  border-width: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}
