/* Give the content the available height and keep actions grouped with its title. */
.rally-ui #app :is(#ov-garage,#ov-fitting,#ov-mods,#ov-shop,#ov-quests,#ov-road,#ov-rooms,#ov-online,#ov-leaderboard,#ov-training)>.panel {
  box-sizing: border-box;
  gap: 5px;
  padding: 6px 9px;
}
.rally-ui #app :is(#ov-fitting,#ov-mods,#ov-rooms,#ov-leaderboard,#ov-road,#ov-quests)>.panel {
  width: min(780px, calc(100% - 20px));
  height: min(510px, calc(100% - 16px));
  min-height: 0;
}
.rally-ui #app .compact-toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  flex: 0 0 auto;
}
.rally-ui #app .compact-toolbar .panel-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  font-size: clamp(16px, calc(19px * var(--ui-text-scale, 1)), 27px);
  line-height: 1.15;
  text-align: left;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
}
.rally-ui #app .compact-toolbar .x-close {
  position: relative;
  inset: auto;
  order: 10;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
}
.rally-ui #app .compact-toolbar :is(.btn, #mods-group) {
  height: auto;
  min-height: 44px;
  min-width: 44px;
  max-width: 48%;
  flex: 0 1 auto;
  padding: 4px 10px;
  font-size: clamp(13px, calc(14px * var(--ui-text-scale, 1)), 21px);
  line-height: 1.12;
  white-space: normal;
}
.rally-ui #app .compact-toolbar .cn {
  display: inline-flex;
  white-space: nowrap;
  vertical-align: middle;
}
.rally-ui #app .compact-toolbar .compact-remove:disabled { display: none; }
.compact-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.rally-ui #app #ov-fitting .panel { width: min(745px, calc(100% - 20px)); }
.rally-ui #app #fitting-car {
  flex: 1 1 0;
  width: 100%;
  min-height: 0;
  height: 0;
  box-sizing: border-box;
  object-fit: contain;
}

.rally-ui #app #ov-mods .panel { width: min(820px, calc(100% - 20px)); }
.rally-ui #app #ov-mods .mods-workbench {
  flex: 1 1 0;
  min-height: 0;
  height: 0;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
  gap: 7px;
}
.rally-ui #app #ov-mods #mods-list {
  min-height: 0;
  grid-auto-rows: minmax(72px, auto);
  align-content: stretch;
  gap: 4px;
  padding: 1px;
  overflow: auto;
}
.rally-ui #app #ov-mods .mods-option {
  grid-template-rows: minmax(15px, 1fr) auto auto;
  gap: 2px;
  padding: 4px 5px;
}
.rally-ui #app #ov-mods .mods-action { min-height: 0; padding: 2px 4px; }
.rally-ui #app #ov-mods-groups .panel-title { font-size: 19px; line-height: 1.15; }

.rally-ui #app :is(#ov-shop,#ov-garage) .compact-toolbar {
  height: auto;
  padding: 0;
}
.rally-ui #app #ov-garage #garage-resale {
  position: static;
  min-height: 44px;
  height: auto;
  padding: 4px 8px;
}
.rally-ui #app #ov-garage .gar { grid-template-rows: auto minmax(0, 1fr); gap: 5px 8px; }
.rally-ui #app #ov-garage .tab { min-height: 44px; }
.rally-ui #app #ov-garage .garage-wallet,
.rally-ui #app #ov-shop .garage-wallet {
  position: static;
  flex: 0 0 auto;
  height: auto;
  min-height: 0;
  padding: 4px 8px;
  font-size: clamp(13px, calc(14px * var(--ui-text-scale, 1)), 21px);
}
.rally-ui #app #ov-garage .gar:has(.tabc:is([data-tabc="paint"],[data-tabc="wheel"],[data-tabc="flag"]).on) .gar-l {
  overflow: hidden;
}
.rally-ui #app #ov-garage .gar:has(.tabc:is([data-tabc="paint"],[data-tabc="wheel"],[data-tabc="flag"]).on) :is(#gar-pw,#gar-stats) {
  display: none;
}
.rally-ui #app #ov-garage .gar:has(.tabc:is([data-tabc="paint"],[data-tabc="wheel"],[data-tabc="flag"]).on) #gar-prev {
  width: 100%;
  flex: 1 1 0;
  height: 0;
  min-height: 0;
  aspect-ratio: auto;
}
.rally-ui #app #ov-garage .gar-name {
  flex-shrink: 0;
  margin: 0;
  max-width: 100%;
  padding: 2px 8px;
  line-height: 1.15;
  white-space: normal;
  overflow-wrap: anywhere;
}

.rally-ui #app #ov-shop .loadout { min-height: 44px; }
.rally-ui #app #ov-shop .loadout-item {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1px 4px;
  width: 100%;
  height: auto;
  min-height: 44px;
  padding: 2px 3px;
}
.rally-ui #app #ov-shop .loadout-item>svg { width: 18px; height: 18px; flex-shrink: 0; }
.rally-ui #app #ov-shop .loadout-name { overflow-wrap: anywhere; white-space: normal; }
.rally-ui #app #ov-shop .loadout-mark { flex-basis: 100%; }
.rally-ui #app #ov-quests .tabs { flex: 1 1 auto; min-width: 0; justify-content: flex-start; }
.rally-ui #app #ov-quests .tabs .tab { min-height: 44px; padding: 4px 8px; white-space: normal; }
.rally-ui #app #ov-quests .tabc.on { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.rally-ui #app #ov-quests .tabc>.list { flex: 1 1 0; min-height: 0; max-height: none; }
.rally-ui #app #ov-road #road-list { flex: 1 1 auto; min-height: 0; max-height: none; align-items: center; }
.rally-ui #app #ov-road #road-league { min-height: 0; padding: 2px 5px; gap: 5px; margin: 0; }
.rally-ui #app #ov-rooms .compact-toolbar+.hint { margin: 0; padding: 0 3px; }
.rally-ui #app #ov-leaderboard #lb-list { flex: 1 1 auto; min-height: 0; max-height: none; }
.rally-ui #app :is(#ov-online,#ov-training)>.panel>.panel-title {
  font-size: clamp(17px, calc(19px * var(--ui-text-scale, 1)), 26px);
  line-height: 1.15;
  min-height: 38px;
  display: grid;
  align-items: center;
}
@media (prefers-reduced-motion: reduce) {
  .rally-ui #app :is(#ov-fitting,#ov-mods)>.panel { animation: none; }
}

/* Secondary game windows keep their own controls and use the same insets. */
.rally-ui #app :is(#ov-pause,#ov-result,#ov-testdrive-intro,#ov-testdrive-result,#ov-room-create,#ov-room-password,#ov-chest,#ov-acc,#ov-help,#ov-adult-mode)>.panel {
  gap: 6px;
  padding-block: 7px;
}
.rally-ui #app :is(#ov-pause,#ov-result,#ov-testdrive-intro,#ov-testdrive-result,#ov-room-create,#ov-room-password,#ov-chest,#ov-acc,#ov-help,#ov-adult-mode)>.panel>.panel-title {
  font-size: clamp(17px, calc(20px * var(--ui-text-scale, 1)), 27px);
  line-height: 1.15;
}
.rally-ui #app :is(#ov-result,#ov-testdrive-result)>.panel :is(.res-btns,.testdrive-actions) {
  margin-block-start: 0;
  gap: 5px;
}
.rally-ui #app #ov-room-create .room-create-controls { gap: 5px; }
dialog.driver-profile .dp-head { padding-block: 1px; }
dialog.driver-profile .dp-head h2 { margin-block: 0; line-height: 1.15; }
#support-dialog .is-head { padding-block: 2px; }
#support-form { gap: 5px; padding-block: 6px; }
/* The shared leaderboard renders outside #app in this game. */
.rally-ui #mdUnifiedDialog.md-leaderboard .md-heading {
  padding: 6px 12px !important;
  gap: 7px !important;
  font-size: 19px !important;
}
.rally-ui #mdUnifiedDialog.md-leaderboard .md-heading::before { width: 29px; height: 29px; }
.rally-ui #mdUnifiedDialog.md-leaderboard .md-actions { padding: 4px 10px 6px !important; }
.rally-ui #mdUnifiedDialog.md-leaderboard .md-actions button { min-height: 44px !important; padding: 5px 10px !important; }
