/* Arcade hardware: lit edges, inset faces and a short, physical key travel. */
:root {
  --control-face: linear-gradient(175deg, #332943, #191322 70%);
  --control-edge: #736181;
  --control-ease: cubic-bezier(.2,.8,.2,1);
}
button, a { touch-action: manipulation; }
:is(button, a):focus-visible {
  outline: 2px solid #e5ffff;
  outline-offset: 4px;
}
.control-icon { flex: none; width: 20px; height: 20px; pointer-events: none; }
.control-label { flex: 1; text-align: left; }
.turbo-entry .control-label { display: inline-flex; align-items: center; gap: 8px; }
.turbo-entry .control-label img { width: 96px; height: auto; }

:is(.cta-primary, .btn-next, #startBtn, #prompt, .chip, .skip) {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid var(--control-edge);
  border-radius: 12px 4px 12px 4px;
  background: var(--control-face);
  box-shadow: inset 0 1px 0 #ffffff30, inset 0 -3px 0 #00000050, 0 4px 0 #08050e, 0 7px 16px #00000040;
  color: #f5eeff;
  text-decoration: none;
  text-shadow: none;
  line-height: 1.3;
  transition: transform .16s var(--control-ease), border-color .16s, box-shadow .16s, filter .16s;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
:is(.cta-primary, .btn-next, #startBtn, #prompt)::before {
  content: '';
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 3px;
  height: auto; margin: 0;
  background: var(--cyan);
  box-shadow: 0 0 10px #3df2ff70;
  pointer-events: none;
}
:is(.readout .cta-primary, .cta-primary, #startBtn) {
  border-color: #c5ffff;
  background: linear-gradient(165deg, #e0ffff 0%, #9aefe9 48%, #8fcbdc 100%);
  color: #151126;
  box-shadow: inset 0 2px 0 #ffffffb0, inset 0 -4px 0 #31566d55, 0 4px 0 #24424e, 0 9px 24px #00000060, 0 0 22px #3df2ff15;
  font-weight: 600;
  letter-spacing: .02em;
}
:is(.cta-primary, #startBtn)::before { background: #b52f77; box-shadow: none; }
:is(.cta-primary, #startBtn) .control-icon {
  width: 32px; height: 32px;
  padding: 6px;
  border: 1px solid #15112630;
  border-radius: 7px 2px 7px 2px;
  background: #1511260c;
}
#startBtn { gap: 20px; min-height: 62px; padding: 10px 18px; font-size: .78rem; letter-spacing: .12em; }
#startBtn span { animation: none; text-shadow: none; }
#startBtn::before { display: block; }
#prompt { min-height: 56px; padding: 12px 22px; border-color: #a79ab6; font-size: .84rem; letter-spacing: .12em; }
#prompt .caret { margin: 0 4px 0 0; color: var(--cyan); font-size: 1.5rem; line-height: 1; }
#prompt .cursor { display: none; }
.hud-bottom { gap: 12px; }
#boot { gap: 12px; }
.boot-meta { margin-bottom: 4px; }

/* Secondary actions still read as controls, with less weight than the main key. */
.skip { min-height: 44px; padding: 10px 14px; border-color: #ffffff24; background: linear-gradient(175deg, #211a30dd, #100d1bdd); color: #c9bfd7; font-size: .7rem; letter-spacing: .07em; }
.skip .control-icon { width: 16px; height: 16px; color: #a9bdca; }
.readout :is(.chip, .btn-next, .close-x) {
  border: 1px solid var(--control-edge);
  background: var(--control-face);
  box-shadow: inset 0 1px 0 #ffffff30, inset 0 -3px 0 #00000050, 0 3px 0 #08050e;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.readout .chip { border-radius: 8px 3px 8px 3px; gap: 10px; min-height: 44px; padding: 10px 14px; }
.readout .chip svg { width: 15px; height: 15px; color: #b7eef2; }
.note .chip { margin-top: 8px; }
.chips { gap: 10px; }
.readout .btn-next { min-height: 54px; padding: 10px 18px; border-color: #8d7b9f; }
.btn-next .control-icon { color: var(--cyan); }
.rf { gap: 12px; padding-bottom: 18px; }
.cal { gap: 12px; }
.readout .cta-primary { min-height: 56px; padding: 10px 18px; }
.close-x, .readout .close-x {
  width: 44px; height: 44px; border-radius: 10px 3px 10px 3px;
  font-size: 1.5rem;
}

/* The top HUD keeps its original bare hearts and icons. */
.rc-steer button {
  border: 1px solid #ffffff30;
  border-radius: 10px 3px 10px 3px;
  background: linear-gradient(165deg, #30263bd9, #110d1be8);
  color: #e2d8ed;
  box-shadow: inset 0 1px 0 #ffffff20, 0 3px 0 #08050e;
  transition: transform .16s, border-color .16s, background .16s;
}
.rc-steer button { width: 58px; height: 58px; color: #befaff; border-color: #3df2ff70; }

/* Result, pause and recovery actions share one predictable position and hierarchy. */
.rc-stage .cta-primary { display: flex; width: min(100%, 340px); min-height: 60px; padding: 10px 18px; font-size: .84rem; letter-spacing: .035em; }
.rc-stage .skip { display: flex; width: min(100%, 340px); margin: 12px auto 0; min-height: 48px; font-size: .65rem; letter-spacing: .035em; text-transform: none; }
.rc-stage .rc-games-link { display: grid; grid-template-columns: auto 16px; gap: 2px 8px; width: fit-content; max-width: 100%; margin-top: 20px; padding: 0 6px 4px; min-height: 44px; text-decoration: none; }
.rc-games-link .external-arrow { width: 16px; height: 16px; color: #c0ecf1; }
.rc-games-link .visit-label { grid-column: 1 / -1; color: #c9bfd7; font: .6rem var(--mono); letter-spacing: .035em; text-decoration: underline; text-decoration-color: #c9bfd755; text-underline-offset: 4px; }
.rc-games-link:is(:hover, :focus-visible) .visit-label { color: #e2ffff; text-decoration-color: #b4f8ff; }
.rc-stage {
  max-height: calc(100% - 100px - var(--safe-t) - var(--safe-b));
  display: flex; flex-direction: column; gap: 10px;
  overflow: visible; padding: 4px 5px 8px;
}
.rc-stage-body {
  flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto;
  overscroll-behavior: contain; padding: 0 3px 8px;
  scrollbar-width: thin; scrollbar-color: #736181 transparent;
}
.rc-stage-actions { flex: none; display: grid; gap: 12px; }
.rc-stage-actions:empty { display: none; }
.rc-stage-actions > :is(.cta-primary, .skip) { margin: 0 auto; min-width: 0; }
.rc-stage-actions .control-label { min-width: 0; overflow-wrap: anywhere; }
.rc-stage .rc-summary { gap: 10px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); container-type: inline-size; }
.rc-summary > div { min-width: 0; }
.rc-summary b { font-size: 1rem; font-size: clamp(.9rem, 5.6cqw, 1.25rem); white-space: nowrap; }
.rc-summary span { overflow-wrap: anywhere; }
.rc-top { left: max(14px, var(--safe-l)); right: max(6px, var(--safe-r)); }
.rc-bottom { left: var(--safe-l); right: var(--safe-r); }
.rc-steer { left: max(14px, var(--safe-l)); right: max(14px, var(--safe-r)); }
.rc-prompt {
  max-width: calc(100% - 160px); justify-content: center; text-align: center;
  font-size: clamp(.68rem, 2.8vw, .9rem); letter-spacing: .12em;
}
#rcPrompt { min-width: 0; }
.rc-boost { max-width: calc(100% - 24px); white-space: normal; overflow-wrap: anywhere; }
.rc-stage::before { inset: 0; }
.rc-stage.rez > * { animation-fill-mode: backwards; }
.rc-stage .rc-cars button { border-radius: 14px 4px 14px 4px; background: linear-gradient(160deg, #34293e, #151020); border: 1px solid color-mix(in srgb, var(--c) 55%, #736181); box-shadow: inset 0 1px 0 #ffffff25, inset 0 -3px 0 #00000050, 0 4px 0 #08050e; }
.rc-boost { border-radius: 12px 4px 12px 4px; border: 1px solid #e2ffff; background: linear-gradient(165deg, #dfffff, #83dedb); box-shadow: inset 0 2px 0 #ffffffa0, inset 0 -4px 0 #31566d55, 0 4px 0 #24424e, 0 0 24px #3df2ff40; letter-spacing: .18em; }

@media (hover: hover) {
  :is(.cta-primary, .btn-next, #startBtn, #prompt, .chip, .skip):not(:disabled):hover {
    transform: translateY(-2px); filter: brightness(1.09); border-color: #dcffff;
  }
  .readout :is(.chip, .btn-next, .close-x):hover { background: linear-gradient(175deg, #493956, #251a33); box-shadow: inset 0 1px 0 #ffffff45, inset 0 -3px 0 #00000050, 0 4px 0 #08050e; }
  #prompt:hover { background: var(--control-face); }
  #startBtn:hover { background: linear-gradient(165deg, #e0ffff, #9aefe9 48%, #8fcbdc); }
}
:is(.cta-primary, .readout .cta-primary, .btn-next, #startBtn, #prompt, .chip, .skip, .rc-steer button):not(:disabled):active {
  transform: translateY(3px); filter: brightness(.96); box-shadow: inset 0 2px 5px #00000030, 0 1px 0 #08050e;
}
.rc-boost.show:active { transform: translateY(3px) scale(.98); animation: none; }
.readout :is(.chip, .btn-next, .close-x):active, #prompt:active { background: var(--control-face); }
:is(button, .chip):disabled { cursor: default; }
:is(#prompt, .cta-primary, .btn-next):disabled { opacity: .45; filter: saturate(.3); }
@media (max-width: 380px) {
  #startBtn { font-size: .68rem; gap: 12px; }
}
@media (max-width: 360px) {
  .rc-score output { font-size: 1.1rem; }
}
/* A completed quest's compact sheet still needs room for its header and actions. */
@media (max-width: 600px) {
  .readout.compact { max-height: min(82dvh, calc(100% - 16px - var(--safe-t) - var(--safe-b))); }
}
@media (max-height: 520px) and (orientation: landscape) {
  #race .rc-stage, #race.paused .rc-stage {
    top: calc(68px + var(--safe-t)); bottom: calc(10px + var(--safe-b));
    right: max(24px, var(--safe-r)); left: auto;
    width: min(310px, calc(100% - max(16px, var(--safe-l)) - max(24px, var(--safe-r))));
    max-height: none; gap: 6px;
  }
  .rc-stage-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .rc-stage-actions > :only-child { grid-column: 1 / -1; }
  .rc-stage-actions > :is(.cta-primary, .skip) { width: 100%; min-height: 48px; padding: 8px 10px; gap: 8px; }
  .rc-stage-actions > .cta-primary { font-size: .76rem; }
  .rc-stage-actions .cta-primary .control-icon { width: 24px; height: 24px; padding: 3px; }
  .rc-stage-body > .rc-games-link {
    grid-template-columns: 80px 12px auto; margin: 8px auto 0;
    width: fit-content; max-width: 100%; min-height: 44px;
    padding: 0 4px; gap: 6px;
  }
  .rc-stage-body .rc-games-link img { width: 80px; height: 24px; }
  .rc-stage-body .rc-games-link .external-arrow { width: 12px; height: 12px; }
  .rc-stage-body .rc-games-link .visit-label { grid-column: auto; font-size: .56rem; }
  .rc-stage .rc-summary { margin: 10px 0; }
  .readout, .readout.compact {
    max-height: calc(100% - 16px - var(--safe-t) - var(--safe-b));
    margin-bottom: calc(8px + var(--safe-b));
  }
  .rh { padding-top: 10px; padding-bottom: 10px; }
  .rh h2 { font-size: 1.3rem; }
  .icon-tile { width: 48px; height: 48px; }
  .rf { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; }
  .rf :is(button, a) { min-width: 0; width: 100%; min-height: 48px; padding: 10px 12px; }
}
/* Browser chrome and a home indicator can leave less than 300px for the race. */
@media (max-height: 360px) and (orientation: landscape) {
  .rc-boost { min-height: 48px; padding: 8px 24px; margin-bottom: 4px; }
  .rc-drive { min-height: 20px; padding: 0 10px 4px; margin: 0 0 2px; }
  .rc-pips button { height: 24px; }
  .rc-prompt { min-height: 28px; font-size: .75rem; }
}
@media (prefers-reduced-motion: reduce) {
  :is(.cta-primary, .btn-next, #startBtn, #prompt, .chip, .skip, .rc-steer button) { transition: none; }
  :is(.cta-primary, .btn-next, #startBtn, #prompt, .chip, .skip):hover { transform: none; }
}
