/* Pug Splash 0.7 - touch layout based on the selected diagonal control render.
   Load after style.css. The game canvas remains fully interactive between controls. */

/* Keep the desktop three-key row intact when the wrappers are present. */
.steer-cluster,
.fart-cluster { display: contents; }
.steer-caption,
.orbit-position,
.fart-hint,
#menuButton,
.pug-avatar,
.pug-you { display: none; }
.drive-controls #steerLeft { order: 1; }
.drive-controls #burpButton { order: 2; }
.drive-controls #steerRight { order: 3; }
.drive-icon {
  display: block;
  width: 29px;
  height: 29px;
  object-fit: contain;
  margin: 1px auto 0;
  pointer-events: none;
}
.fart-icon { display: none; }
.game-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 18px 0;
}
.game-menu-grid button {
  min-height: 48px;
  border: 1px solid #cee2df;
  border-radius: 12px;
  padding: 10px 9px;
  background: #eaf5f1;
  color: #173a55;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
}
.game-menu-grid button:disabled { opacity: .45; }
.game-menu-grid button.active,
.game-menu-grid button.is-off { background: #ffedb2; }
.game-menu-grid button:last-child:nth-child(odd) { grid-column: 1 / -1; }
.menu-help {
  border-top: 1px solid #dce7e1;
  padding-top: 12px;
  margin-top: 15px;
  font-size: 12px;
  line-height: 1.5;
}
.menu-help summary {
  min-height: 38px;
  padding: 8px 2px;
  cursor: pointer;
  font-weight: 800;
}
.menu-help p { font-size: 12px; margin: 7px 0; }
#pauseDialog .text-button { min-height: 48px; margin-top: 12px; }
#menuButton img { width: 26px; height: 26px; pointer-events: none; }

/* Automatic touch/mobile layout. */
@media (pointer: coarse), (max-width: 1024px) {
body.playing {
  --touch-left: max(18px, env(safe-area-inset-left, 0px));
  --touch-right: max(18px, env(safe-area-inset-right, 0px));
  --touch-top: max(12px, env(safe-area-inset-top, 0px));
  --touch-bottom: max(25px, env(safe-area-inset-bottom, 0px));
  --touch-key: clamp(64px, 18.8dvh, 92px);
  --touch-fart: clamp(100px, 29.8dvh, 148px);
  --touch-avatar: clamp(48px, 10.9dvh, 60px);
  --touch-avatar-gap: clamp(8px, 2.2dvh, 14px);
  --touch-ink: #11334f;
  -webkit-user-select: none;
  user-select: none;
}
body.playing .topbar,
body.playing .race-tools,
body.playing .motion-hud,
body.playing .control-hint { display: none; }

body.playing .pug-select {
  z-index: 7;
  top: var(--touch-top);
  left: var(--touch-left);
  right: auto;
  bottom: auto;
  transform: none;
  width: auto;
  justify-content: flex-start;
  align-items: flex-start;
  gap: var(--touch-avatar-gap);
  padding: 0;
  pointer-events: auto;
}
body.playing .pug-chip {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 var(--touch-avatar);
  width: var(--touch-avatar);
  height: var(--touch-avatar);
  min-width: 0;
  margin: 0;
  padding: 2px;
  border: 3px solid #fffdf5;
  border-radius: 50%;
  background: #fff0c7;
  box-shadow: 0 0 0 2px var(--pug), 0 3px 6px #124c5c33;
  transform: none;
  overflow: visible;
  touch-action: manipulation;
}
body.playing .pug-chip.selected,
body.playing .pug-chip.selected:hover {
  border-color: #fffdf5;
  background: #fff7de;
  box-shadow: 0 0 0 3px var(--pug), 0 0 0 5px #ffffffa6, 0 3px 7px #124c5c44;
  transform: none;
}
body.playing .pug-chip.offline { opacity: .58; }
body.playing .pug-chip em,
body.playing .pug-chip > span { display: none; }
body.playing .pug-avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  border-radius: 50%;
}
body.playing .pug-chip .pug-you {
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  display: block;
  transform: translateX(-50%);
  border: 1px solid #ffffffc9;
  border-radius: 9px;
  padding: 2px 9px 3px;
  background: var(--pug);
  color: #fff;
  font-size: clamp(9px, 2.5dvh, 12px);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}

body.playing .race-hud {
  z-index: 5;
  top: var(--touch-top);
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
  display: flex;
  width: min(38vw, 440px);
  min-width: 0;
  height: clamp(38px, 10dvh, 56px);
  padding: 7px 12px;
  gap: 10px;
  border: 1px solid #fffdf5;
  border-radius: 17px;
  background: #fffdf5f5;
  box-shadow: 0 3px 0 #4b8b921f;
  pointer-events: none;
}
body.playing .race-name { flex: 0 1 auto; min-width: 0; }
body.playing .race-name > span {
  display: block;
  max-width: 118px;
  margin: 0;
  color: var(--touch-ink) !important;
  font-size: clamp(8px, 2.35dvh, 12px);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: .15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.playing .race-name > strong,
body.playing .race-progress > div:first-child,
body.playing .race-time > span { display: none; }
body.playing .race-progress { flex: 1 1 70px; min-width: 24px; width: auto; }
body.playing .progress-track { height: 5px; background: #b9d4d5; overflow: visible; }
body.playing .progress-track i {
  display: block;
  height: 5px;
  min-width: 5px;
  background: #11b0e4 !important;
  box-shadow: none;
}
body.playing .race-time {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 49px;
  flex: 0 0 auto;
}
body.playing .race-time > strong {
  color: var(--touch-ink);
  font-size: clamp(21px, 5.8dvh, 31px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.7px;
}
body.playing #menuButton {
  display: grid;
  z-index: 8;
  position: fixed;
  top: var(--touch-top);
  right: var(--touch-right);
  width: clamp(48px, 10.9dvh, 58px);
  height: clamp(48px, 10.9dvh, 58px);
  border-radius: 14px;
  border: 1px solid #fff;
  background: #fffdf5f5;
  box-shadow: 0 3px 0 #719c9c44;
  touch-action: manipulation;
}
body.playing #menuButton img { width: 60%; height: 60%; }
body.playing .network-badge {
  top: calc(var(--touch-top) + var(--touch-avatar) + 25px);
  left: var(--touch-left);
  right: auto;
  max-width: min(240px, 34vw);
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 9px;
  pointer-events: none;
}
body.playing .drive-controls {
  z-index: 6;
  position: fixed;
  inset: 0;
  transform: none;
  display: block;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  pointer-events: none;
  touch-action: none;
}
body.playing .steer-cluster {
  display: block;
  position: absolute;
  left: var(--touch-left);
  bottom: var(--touch-bottom);
  width: calc(var(--touch-key) * 2.25);
  height: calc(var(--touch-key) * 2.12);
  pointer-events: none;
}
body.playing .steer-caption {
  position: absolute;
  display: block;
  left: calc(var(--touch-key) * .28);
  top: calc(var(--touch-key) * -.47);
  padding: 5px 13px;
  border-radius: 13px;
  background: #fffdf5f5;
  color: var(--touch-ink);
  font-size: clamp(10px, 2.8dvh, 14px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: .05px;
  white-space: nowrap;
  pointer-events: none;
}
body.playing .drive-key {
  position: absolute;
  display: grid;
  place-items: center;
  width: var(--touch-key);
  height: var(--touch-key);
  margin: 0;
  padding: 10px;
  border: 3px solid #fffdf2;
  border-radius: 31%;
  background: #fffdf2f5;
  color: var(--touch-ink);
  box-shadow: 0 4px 0 #79a7a3, 0 0 0 3px #aaf5e9, 0 0 0 6px #1cc6d4b3, inset 0 0 8px #ffffffad;
  pointer-events: auto;
  touch-action: none;
  -webkit-touch-callout: none;
  transition: transform .07s ease, background .07s ease, box-shadow .07s ease;
}
body.playing #steerLeft { top: 0; left: 0; }
body.playing #steerRight { right: 0; bottom: 0; }
body.playing .drive-key b { display: none; }
body.playing .drive-icon {
  display: block;
  width: 91%;
  height: 91%;
  margin: 0;
  object-fit: contain;
  pointer-events: none;
}
body.playing .drive-key:hover:not(:disabled) { transform: none; }
body.playing .drive-key.held,
body.playing .drive-key.held:hover:not(:disabled),
body.playing .drive-key:active {
  transform: translateY(3px);
  background: #fff0bb;
  box-shadow: 0 1px 0 #79a7a3, 0 0 0 3px #e7ffff, 0 0 0 6px #35dbed, inset 0 2px 6px #92bdad40;
}
/* The entire marker travels to the right of the upper button and above the
   lower one. The minimum 64px keys retain a gap even including both outlines. */
body.playing .orbit-position {
  position: absolute;
  display: block;
  left: calc(var(--touch-key) * 1.16);
  top: calc(var(--touch-key) * .06);
  width: calc(var(--touch-key) * 1.05);
  height: calc(var(--touch-key) * .90);
  z-index: 0;
  pointer-events: none;
}
body.playing .orbit-track { display: block; width: 100%; height: 100%; object-fit: fill; }
body.playing .orbit-marker {
  position: absolute;
  left: var(--orbit-x, 50%);
  top: var(--orbit-y, 31.25%);
  width: clamp(21px, 5.9dvh, 29px);
  height: clamp(21px, 5.9dvh, 29px);
  padding: 1px;
  border: 2px solid #fffdf5;
  border-radius: 50%;
  background: var(--player-color, #16bce3);
  box-shadow: 0 0 0 1px #23c7ed;
  object-fit: contain;
  transform: translate(-50%, -50%);
  transition: left .06s linear, top .06s linear;
  pointer-events: none;
}
body.playing .fart-cluster {
  display: block;
  position: absolute;
  right: calc(var(--touch-right) + 3px);
  bottom: calc(var(--touch-bottom) + 3px);
  width: var(--touch-fart);
  height: var(--touch-fart);
  pointer-events: none;
}
body.playing .fart-hint {
  display: block;
  position: absolute;
  right: -1px;
  bottom: calc(100% + 14px);
  width: max-content;
  max-width: 30vw;
  padding: 7px 11px;
  border-radius: 15px;
  background: #fffdf5f5;
  color: var(--touch-ink);
  text-align: center;
  font-size: clamp(10px, 2.8dvh, 14px);
  font-weight: 800;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
}
body.playing .burp-key {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1px;
  width: var(--touch-fart);
  height: var(--touch-fart);
  margin: 0;
  padding: 9px;
  border: 3px solid #fff3a2;
  border-radius: 50%;
  background: #ffe13e;
  color: var(--touch-ink);
  box-shadow: 0 6px 0 #cfa12d, 0 0 0 5px #b5f4e5, 0 0 0 8px #45d5e4a6, inset 0 0 14px #fff59c;
  overflow: hidden;
  pointer-events: auto;
  touch-action: none;
  -webkit-touch-callout: none;
  transition: transform .07s ease, background .07s ease, box-shadow .07s ease;
}
body.playing .burp-key small,
body.playing .burp-key #burpCooldown { display: none; }
body.playing .fart-icon {
  display: block;
  width: 55%;
  height: 48%;
  margin: 0;
  object-fit: contain;
  pointer-events: none;
}
body.playing .burp-key strong {
  display: block;
  margin: 0;
  color: var(--touch-ink);
  font-size: clamp(25px, 8.2dvh, 40px);
  font-weight: 1000;
  line-height: 1.05;
  letter-spacing: -.6px;
  pointer-events: none;
}
body.playing .burp-key:hover:not(:disabled) { transform: none; }
body.playing .burp-key.held,
body.playing .burp-key.held:hover:not(:disabled),
body.playing .burp-key:active {
  transform: translateY(3px);
  background: #ffd730;
  box-shadow: 0 3px 0 #cfa12d, 0 0 0 5px #d5ffef, 0 0 0 8px #22cbe3, inset 0 3px 10px #d2a5225e;
}
body.playing .burp-key.sustaining { outline: 2px solid #dffffa; outline-offset: 4px; }
body.playing .toast {
  z-index: 30;
  top: calc(var(--touch-top) + 54px);
  bottom: auto;
  max-width: min(390px, 48vw);
  padding: 7px 13px;
  border-radius: 14px;
  font-size: clamp(10px, 2.7dvh, 12px);
  line-height: 1.35;
  pointer-events: none;
}
body.playing .popped-message {
  top: 44%;
  width: min(380px, 48vw);
  max-width: 48vw;
  white-space: normal;
}
body.playing .popped-message strong { font-size: clamp(32px, 10dvh, 54px); }
body.playing .popped-message span { font-size: 11px; line-height: 1.35; }
body.playing dialog {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - max(16px, env(safe-area-inset-top, 0px)) - max(16px, env(safe-area-inset-bottom, 0px)));
  padding: 22px 24px;
  border-radius: 21px;
  overscroll-behavior: contain;
  -webkit-user-select: text;
  user-select: text;
}
body.playing dialog h2 { margin: 8px 0 12px; font-size: 25px; }
body.playing #pauseNote { margin: 8px 0 15px; }
body.playing .dialog-close { width: 48px; height: 48px; }

}

/* The same layout can be selected explicitly for tablets and visual QA. */
body.playing:where(.touch-ui, .touch-preview) {
  --touch-left: max(18px, env(safe-area-inset-left, 0px));
  --touch-right: max(18px, env(safe-area-inset-right, 0px));
  --touch-top: max(12px, env(safe-area-inset-top, 0px));
  --touch-bottom: max(25px, env(safe-area-inset-bottom, 0px));
  --touch-key: clamp(64px, 18.8dvh, 92px);
  --touch-fart: clamp(100px, 29.8dvh, 148px);
  --touch-avatar: clamp(48px, 10.9dvh, 60px);
  --touch-avatar-gap: clamp(8px, 2.2dvh, 14px);
  --touch-ink: #11334f;
  -webkit-user-select: none;
  user-select: none;
}
body.playing:where(.touch-ui, .touch-preview) .topbar,
body.playing:where(.touch-ui, .touch-preview) .race-tools,
body.playing:where(.touch-ui, .touch-preview) .motion-hud,
body.playing:where(.touch-ui, .touch-preview) .control-hint { display: none; }

body.playing:where(.touch-ui, .touch-preview) .pug-select {
  z-index: 7;
  top: var(--touch-top);
  left: var(--touch-left);
  right: auto;
  bottom: auto;
  transform: none;
  width: auto;
  justify-content: flex-start;
  align-items: flex-start;
  gap: var(--touch-avatar-gap);
  padding: 0;
  pointer-events: auto;
}
body.playing:where(.touch-ui, .touch-preview) .pug-chip {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 var(--touch-avatar);
  width: var(--touch-avatar);
  height: var(--touch-avatar);
  min-width: 0;
  margin: 0;
  padding: 2px;
  border: 3px solid #fffdf5;
  border-radius: 50%;
  background: #fff0c7;
  box-shadow: 0 0 0 2px var(--pug), 0 3px 6px #124c5c33;
  transform: none;
  overflow: visible;
  touch-action: manipulation;
}
body.playing:where(.touch-ui, .touch-preview) .pug-chip.selected,
body.playing:where(.touch-ui, .touch-preview) .pug-chip.selected:hover {
  border-color: #fffdf5;
  background: #fff7de;
  box-shadow: 0 0 0 3px var(--pug), 0 0 0 5px #ffffffa6, 0 3px 7px #124c5c44;
  transform: none;
}
body.playing:where(.touch-ui, .touch-preview) .pug-chip.offline { opacity: .58; }
body.playing:where(.touch-ui, .touch-preview) .pug-chip em,
body.playing:where(.touch-ui, .touch-preview) .pug-chip > span { display: none; }
body.playing:where(.touch-ui, .touch-preview) .pug-avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  border-radius: 50%;
}
body.playing:where(.touch-ui, .touch-preview) .pug-chip .pug-you {
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  display: block;
  transform: translateX(-50%);
  border: 1px solid #ffffffc9;
  border-radius: 9px;
  padding: 2px 9px 3px;
  background: var(--pug);
  color: #fff;
  font-size: clamp(9px, 2.5dvh, 12px);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}

body.playing:where(.touch-ui, .touch-preview) .race-hud {
  z-index: 5;
  top: var(--touch-top);
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
  display: flex;
  width: min(38vw, 440px);
  min-width: 0;
  height: clamp(38px, 10dvh, 56px);
  padding: 7px 12px;
  gap: 10px;
  border: 1px solid #fffdf5;
  border-radius: 17px;
  background: #fffdf5f5;
  box-shadow: 0 3px 0 #4b8b921f;
  pointer-events: none;
}
body.playing:where(.touch-ui, .touch-preview) .race-name { flex: 0 1 auto; min-width: 0; }
body.playing:where(.touch-ui, .touch-preview) .race-name > span {
  display: block;
  max-width: 118px;
  margin: 0;
  color: var(--touch-ink) !important;
  font-size: clamp(8px, 2.35dvh, 12px);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: .15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.playing:where(.touch-ui, .touch-preview) .race-name > strong,
body.playing:where(.touch-ui, .touch-preview) .race-progress > div:first-child,
body.playing:where(.touch-ui, .touch-preview) .race-time > span { display: none; }
body.playing:where(.touch-ui, .touch-preview) .race-progress { flex: 1 1 70px; min-width: 24px; width: auto; }
body.playing:where(.touch-ui, .touch-preview) .progress-track { height: 5px; background: #b9d4d5; overflow: visible; }
body.playing:where(.touch-ui, .touch-preview) .progress-track i {
  display: block;
  height: 5px;
  min-width: 5px;
  background: #11b0e4 !important;
  box-shadow: none;
}
body.playing:where(.touch-ui, .touch-preview) .race-time {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 49px;
  flex: 0 0 auto;
}
body.playing:where(.touch-ui, .touch-preview) .race-time > strong {
  color: var(--touch-ink);
  font-size: clamp(21px, 5.8dvh, 31px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.7px;
}
body.playing:where(.touch-ui, .touch-preview) #menuButton {
  display: grid;
  z-index: 8;
  position: fixed;
  top: var(--touch-top);
  right: var(--touch-right);
  width: clamp(48px, 10.9dvh, 58px);
  height: clamp(48px, 10.9dvh, 58px);
  border-radius: 14px;
  border: 1px solid #fff;
  background: #fffdf5f5;
  box-shadow: 0 3px 0 #719c9c44;
  touch-action: manipulation;
}
body.playing:where(.touch-ui, .touch-preview) #menuButton img { width: 60%; height: 60%; }
body.playing:where(.touch-ui, .touch-preview) .network-badge {
  top: calc(var(--touch-top) + var(--touch-avatar) + 25px);
  left: var(--touch-left);
  right: auto;
  max-width: min(240px, 34vw);
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 9px;
  pointer-events: none;
}
body.playing:where(.touch-ui, .touch-preview) .drive-controls {
  z-index: 6;
  position: fixed;
  inset: 0;
  transform: none;
  display: block;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  pointer-events: none;
  touch-action: none;
}
body.playing:where(.touch-ui, .touch-preview) .steer-cluster {
  display: block;
  position: absolute;
  left: var(--touch-left);
  bottom: var(--touch-bottom);
  width: calc(var(--touch-key) * 2.25);
  height: calc(var(--touch-key) * 2.12);
  pointer-events: none;
}
body.playing:where(.touch-ui, .touch-preview) .steer-caption {
  position: absolute;
  display: block;
  left: calc(var(--touch-key) * .28);
  top: calc(var(--touch-key) * -.47);
  padding: 5px 13px;
  border-radius: 13px;
  background: #fffdf5f5;
  color: var(--touch-ink);
  font-size: clamp(10px, 2.8dvh, 14px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: .05px;
  white-space: nowrap;
  pointer-events: none;
}
body.playing:where(.touch-ui, .touch-preview) .drive-key {
  position: absolute;
  display: grid;
  place-items: center;
  width: var(--touch-key);
  height: var(--touch-key);
  margin: 0;
  padding: 10px;
  border: 3px solid #fffdf2;
  border-radius: 31%;
  background: #fffdf2f5;
  color: var(--touch-ink);
  box-shadow: 0 4px 0 #79a7a3, 0 0 0 3px #aaf5e9, 0 0 0 6px #1cc6d4b3, inset 0 0 8px #ffffffad;
  pointer-events: auto;
  touch-action: none;
  -webkit-touch-callout: none;
  transition: transform .07s ease, background .07s ease, box-shadow .07s ease;
}
body.playing:where(.touch-ui, .touch-preview) #steerLeft { top: 0; left: 0; }
body.playing:where(.touch-ui, .touch-preview) #steerRight { right: 0; bottom: 0; }
body.playing:where(.touch-ui, .touch-preview) .drive-key b { display: none; }
body.playing:where(.touch-ui, .touch-preview) .drive-icon {
  display: block;
  width: 91%;
  height: 91%;
  margin: 0;
  object-fit: contain;
  pointer-events: none;
}
body.playing:where(.touch-ui, .touch-preview) .drive-key:hover:not(:disabled) { transform: none; }
body.playing:where(.touch-ui, .touch-preview) .drive-key.held,
body.playing:where(.touch-ui, .touch-preview) .drive-key.held:hover:not(:disabled),
body.playing:where(.touch-ui, .touch-preview) .drive-key:active {
  transform: translateY(3px);
  background: #fff0bb;
  box-shadow: 0 1px 0 #79a7a3, 0 0 0 3px #e7ffff, 0 0 0 6px #35dbed, inset 0 2px 6px #92bdad40;
}
body.playing:where(.touch-ui, .touch-preview) .orbit-position {
  position: absolute;
  display: block;
  left: calc(var(--touch-key) * 1.16);
  top: calc(var(--touch-key) * .06);
  width: calc(var(--touch-key) * 1.05);
  height: calc(var(--touch-key) * .90);
  z-index: 0;
  pointer-events: none;
}
body.playing:where(.touch-ui, .touch-preview) .orbit-track { display: block; width: 100%; height: 100%; object-fit: fill; }
body.playing:where(.touch-ui, .touch-preview) .orbit-marker {
  position: absolute;
  left: var(--orbit-x, 50%);
  top: var(--orbit-y, 31.25%);
  width: clamp(21px, 5.9dvh, 29px);
  height: clamp(21px, 5.9dvh, 29px);
  padding: 1px;
  border: 2px solid #fffdf5;
  border-radius: 50%;
  background: var(--player-color, #16bce3);
  box-shadow: 0 0 0 1px #23c7ed;
  object-fit: contain;
  transform: translate(-50%, -50%);
  transition: left .06s linear, top .06s linear;
  pointer-events: none;
}
body.playing:where(.touch-ui, .touch-preview) .fart-cluster {
  display: block;
  position: absolute;
  right: calc(var(--touch-right) + 3px);
  bottom: calc(var(--touch-bottom) + 3px);
  width: var(--touch-fart);
  height: var(--touch-fart);
  pointer-events: none;
}
body.playing:where(.touch-ui, .touch-preview) .fart-hint {
  display: block;
  position: absolute;
  right: -1px;
  bottom: calc(100% + 14px);
  width: max-content;
  max-width: 30vw;
  padding: 7px 11px;
  border-radius: 15px;
  background: #fffdf5f5;
  color: var(--touch-ink);
  text-align: center;
  font-size: clamp(10px, 2.8dvh, 14px);
  font-weight: 800;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
}
body.playing:where(.touch-ui, .touch-preview) .burp-key {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1px;
  width: var(--touch-fart);
  height: var(--touch-fart);
  margin: 0;
  padding: 9px;
  border: 3px solid #fff3a2;
  border-radius: 50%;
  background: #ffe13e;
  color: var(--touch-ink);
  box-shadow: 0 6px 0 #cfa12d, 0 0 0 5px #b5f4e5, 0 0 0 8px #45d5e4a6, inset 0 0 14px #fff59c;
  overflow: hidden;
  pointer-events: auto;
  touch-action: none;
  -webkit-touch-callout: none;
  transition: transform .07s ease, background .07s ease, box-shadow .07s ease;
}
body.playing:where(.touch-ui, .touch-preview) .burp-key small,
body.playing:where(.touch-ui, .touch-preview) .burp-key #burpCooldown { display: none; }
body.playing:where(.touch-ui, .touch-preview) .fart-icon {
  display: block;
  width: 55%;
  height: 48%;
  margin: 0;
  object-fit: contain;
  pointer-events: none;
}
body.playing:where(.touch-ui, .touch-preview) .burp-key strong {
  display: block;
  margin: 0;
  color: var(--touch-ink);
  font-size: clamp(25px, 8.2dvh, 40px);
  font-weight: 1000;
  line-height: 1.05;
  letter-spacing: -.6px;
  pointer-events: none;
}
body.playing:where(.touch-ui, .touch-preview) .burp-key:hover:not(:disabled) { transform: none; }
body.playing:where(.touch-ui, .touch-preview) .burp-key.held,
body.playing:where(.touch-ui, .touch-preview) .burp-key.held:hover:not(:disabled),
body.playing:where(.touch-ui, .touch-preview) .burp-key:active {
  transform: translateY(3px);
  background: #ffd730;
  box-shadow: 0 3px 0 #cfa12d, 0 0 0 5px #d5ffef, 0 0 0 8px #22cbe3, inset 0 3px 10px #d2a5225e;
}
body.playing:where(.touch-ui, .touch-preview) .burp-key.sustaining { outline: 2px solid #dffffa; outline-offset: 4px; }
body.playing:where(.touch-ui, .touch-preview) .toast {
  z-index: 30;
  top: calc(var(--touch-top) + 54px);
  bottom: auto;
  max-width: min(390px, 48vw);
  padding: 7px 13px;
  border-radius: 14px;
  font-size: clamp(10px, 2.7dvh, 12px);
  line-height: 1.35;
  pointer-events: none;
}
body.playing:where(.touch-ui, .touch-preview) .popped-message {
  top: 44%;
  width: min(380px, 48vw);
  max-width: 48vw;
  white-space: normal;
}
body.playing:where(.touch-ui, .touch-preview) .popped-message strong { font-size: clamp(32px, 10dvh, 54px); }
body.playing:where(.touch-ui, .touch-preview) .popped-message span { font-size: 11px; line-height: 1.35; }
body.playing:where(.touch-ui, .touch-preview) dialog {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - max(16px, env(safe-area-inset-top, 0px)) - max(16px, env(safe-area-inset-bottom, 0px)));
  padding: 22px 24px;
  border-radius: 21px;
  overscroll-behavior: contain;
  -webkit-user-select: text;
  user-select: text;
}
body.playing:where(.touch-ui, .touch-preview) dialog h2 { margin: 8px 0 12px; font-size: 25px; }
body.playing:where(.touch-ui, .touch-preview) #pauseNote { margin: 8px 0 15px; }
body.playing:where(.touch-ui, .touch-preview) .dialog-close { width: 48px; height: 48px; }


/* Keep the HUD clear of the fourth portrait on compact landscape phones. */
@media (min-width: 701px) and (max-width: 820px) and (orientation: landscape) {
body.playing .race-hud {
  left: calc(var(--touch-left) + var(--touch-avatar) * 4 + var(--touch-avatar-gap) * 3 + 16px);
  transform: none;
}
}

@media (max-width: 700px) and (orientation: landscape) {
body.playing {
  --touch-avatar: 48px;
  --touch-avatar-gap: 7px;
}
body.playing .race-hud {
  left: auto;
  right: calc(var(--touch-right) + 54px);
  width: 38vw;
  max-width: calc(100vw - 260px);
  transform: none;
  gap: 6px;
  padding: 7px 9px;
}
body.playing .race-name > span { max-width: 76px; font-size: 8px; }
body.playing .race-time { min-width: 42px; }
body.playing .race-time > strong { font-size: 21px; }
body.playing .fart-hint { font-size: 10px; }

}

@media (orientation: portrait) {
body.playing {
  --touch-key: clamp(64px, 18vw, 88px);
  --touch-fart: clamp(100px, 29vw, 140px);
  --touch-avatar: clamp(48px, 10.6vw, 56px);
  --touch-avatar-gap: 9px;
  --touch-bottom: max(28px, env(safe-area-inset-bottom, 0px));
}
body.playing .pug-select { gap: var(--touch-avatar-gap); }
body.playing .race-hud {
  top: calc(var(--touch-top) + var(--touch-avatar) + 31px);
  left: var(--touch-left);
  right: var(--touch-right);
  width: auto;
  max-width: none;
  height: 42px;
  transform: none;
  gap: 12px;
  padding: 9px 13px;
}
body.playing .race-name > span { max-width: 148px; font-size: 10px; }
body.playing .race-time > strong { font-size: 24px; }
body.playing .steer-caption { font-size: 10px; padding: 5px 10px; }
body.playing .fart-hint {
  max-width: none;
  font-size: 9px;
  padding: 7px 9px;
  bottom: calc(100% + 13px);
}
body.playing .burp-key strong { font-size: 29px; }
body.playing .orbit-marker { width: 22px; height: 22px; }
body.playing .network-badge {
  top: calc(var(--touch-top) + var(--touch-avatar) + 80px);
  max-width: calc(100vw - 36px);
}
body.playing .toast {
  top: calc(var(--touch-top) + var(--touch-avatar) + 80px);
  max-width: calc(100vw - 36px);
  width: max-content;
  font-size: 11px;
}
body.playing .popped-message { width: calc(100vw - 44px); max-width: none; top: 42%; }
body.playing .popped-message span { margin: 10px auto 0; max-width: 300px; }

}

@media (max-height: 500px) and (orientation: landscape) {
body:not(.playing) .main-menu {
  top: max(69px, calc(env(safe-area-inset-top, 0px) + 58px));
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  left: max(18px, env(safe-area-inset-left, 0px));
  right: auto;
  width: min(440px, 48vw);
  max-width: none;
  max-height: none;
  transform: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 9px 13px 12px;
  border-radius: 18px;
  background: #f2fbf3ee;
}
body:not(.playing) .main-menu h1 { font-size: 28px; line-height: 1.04; margin: 8px 0; letter-spacing: -1px; }
body:not(.playing) .intro { font-size: 11px; line-height: 1.35; margin-bottom: 10px; }
body:not(.playing) .practice-picker { gap: 6px; margin-bottom: 10px; }
body:not(.playing) .practice-picker > span { font-size: 9px; }
body:not(.playing) .primary-button { padding: 11px 12px; font-size: 14px; }
body:not(.playing) .mode-buttons { margin-top: 12px; gap: 8px; }
body:not(.playing) .secondary-button { padding: 11px 6px; }
body:not(.playing) .menu-foot { margin-top: 10px; }
body .menu-controls,
body .scene-caption { display: none; }

body.playing dialog { padding: 18px 22px; }
body.playing .game-menu-grid { margin: 12px 0; gap: 8px; }
body.playing .game-menu-grid button { min-height: 48px; }
}

body.playing .steer-caption,
body.playing .fart-hint {
  opacity: 1;
  visibility: visible;
  transition: opacity .28s ease, visibility 0s;
}
body.playing.control-hints-hidden .steer-caption,
body.playing.control-hints-hidden .fart-hint {
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s ease, visibility 0s linear .28s;
}

@media (prefers-reduced-motion: reduce) {
 .drive-key, .burp-key, .orbit-marker, .steer-caption, .fart-hint { transition: none !important; }
}


@media (max-width: 540px) and (orientation: landscape) {
 body.playing .race-hud { width: calc(100vw - var(--touch-left) - var(--touch-right) - 285px); min-width: 120px; }
 body.playing .race-name > span { max-width: 55px; }
}
